In playback mode, 2-phase search.
You need to enable overloading using ADL, so lexical_cast will find it in the second phase.
So you have to move the overload to the mandala namespace
Here's a fully fixed example (you should also use std::skipws ):
Live on coliru
#include <iostream> #include <boost/lexical_cast.hpp> namespace mandala { struct vec2_t { float x,y; }; } namespace mandala { std::istream& operator>>(std::istream& istream, vec2_t& v) { return istream >> std::skipws >> vx >> vy; } } int main() { auto v = boost::lexical_cast<mandala::vec2_t>("123.1 15.2"); std::cout << "Parsed: " << vx << ", " << vy << "\n"; }

source share