Boost logo

Boost Users :

Subject: Re: [Boost-users] [Objective-C++] Specializing boost::lexical_cast
From: Chris Cleeland (chris.cleeland_at_[hidden])
Date: 2011-10-15 15:48:07


On Fri, Oct 14, 2011 at 8:37 PM, Kelvin Chung <kelvSYC_at_[hidden]> wrote:
> 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.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net