I'm having trouble compiling the following snippet
int temp; vector<int> origins; vector<string> originTokens = OTUtils::tokenize(buffer, ",");
where is the function in question
// the third parameter should be one of std::hex, std::dec or std::oct template <class T> bool FromString(T& t, const std::string& s, std::ios_base& (*f)(std::ios_base&) = std::dec) { std::istringstream iss(s); return !(iss >> f >> t).fail(); }
I get an error
1>Compiling with Intel(R) C++ 11.0.074 [IA-32]... (Intel C++ Environment) 1>C:\projects\svn\bdk\Source\deps\boost_1_42_0\boost/bind/bind.hpp(303): internal error: assertion failed: copy_default_arg_expr: rout NULL, no error (shared/edgcpfe/il.c, line 13919) 1> 1> return unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]); 1> ^ 1> 1>icl: error
Google is unusually useless, so I hope someone here can give some ideas.
UPDATE : @gf's answer answers the question, but it is interesting that the original function was not entirely correct, since it saved the result of the conversion operation (failed / failed), and not the converted value itself. I changed the signature, returned the converted value directly, and the compiler was able to correctly determine the type of binding.
// new signature T FromString(const std::string& s, std::ios_base& (*f)(std::ios_base&) = std::dec); // revised calling syntax - note that bind<int> is not required. transform(originTokens.begin(), originTokens.end(), origins.begin(), bind(&FromString<int>, _1, std::dec));