No C++11 or Boost allowed.
I am trying to get the following code to compile but I'm having problems. std::ptr_fun
doesn't seem to like parameters that are references.
#include <algorithm>
#include <functional>
#include <vector>
struct Something
{
};
template<class T>
T Function(const T& x, int s)
{
// blah blah
return x;
}
int main()
{
std::vector<Something> data(20);
std::transform(data.begin(), data.end(), data.begin(), std::bind2nd(std::ptr_fun(Function<Something>), 8));
}
VS2013 error message: error C2535: 'Something std::binder2nd>::operator ()(const Something &) const' : member function already defined or declared
But if I change the parameter in Function
to T x
it works!
Is there any way to get this working conveniently without modifying Function
?
Live examples: