I am trying to write my own library for competitive programming contests, and I need such code:
#include <functional>
#include <algorithm>
template <typename T>
using binop = std::function<T (T, T)>;
int main()
{
binop<int> op = std::max<int>;
}
Unfortunately, it produces the following error:
error: conversion from '<unresolved overloaded function type>' to non-scalar type 'binop<int> {aka std::function<int(int, int)>}' requested
But when I remove the line
#include <algorithm>
it magically compiles. (though there shouldn't really be a max function defined)
The question is: how can I compile the code without removing "algorithm"?
Note that I have also tried this:
binop<int> op = (int(*)(int, int)) std::max<int>;
which produces
error: insufficient contextual information to determine type