The below code compiles without error using VS 2012 but with g++ 4.1.2 I get this error:
Here is the code:
main.cpp: In function 'int main(int, char**)':
main.cpp:37: error: no matching function for call to 'StringHelper::stringToNumeric(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
This is part of a larger program so in reality StringHelper has more static functions but this example does produce the error the same as the code when in the larger program.
// Modify in place and return to enable assignment
static T stringToNumeric(std::string& value)
retval = boost::lexical_cast<T>(value);
retval = boost::lexical_cast<T>(0);
int main(int argc, char* argv)
int i = StringHelper::stringToNumeric<int>(s.substr(0,2));
To get it to compile under g++ I had to assign the return value from substr() to a string and pass that string to stringToNumeric. Why do I have to do this for g++ and not VS? Do I have something wrong with my template function that g++ is calling out and VS is not?
Any help is appreciated.