
On Fri, Oct 14, 2011 at 8:37 PM, Kelvin Chung
I'm trying to specialize boost::lexical_cast to convert Objective-C objects into various standard C++ classes (for example, leveraging NSNumber::-intValue to create lexical_cast<int>(NSNumber*)). However, as Objective-C objects exist as pointers, I would imagine that they would fail the requirements of needing well-defined streaming operator<<() in order to use the stock boost::lexical_cast. Any words of advice on how to do this in a way that will do as little damage as possible?
I haven't looked at the impl for lexical_cast, but this comes to mind off the top of my head... Perhaps consider a C++ wrapper around the ObjC ptr that knows how to query the ObjC object for its type and turn it into the correct C++ type. Then provide a partial specialization for lexical_cast<> and that type.