"Ross Smith" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Aleksandr Golovanov wrote: > > Hello, I'm pretty new here, but I've extensively used boost library for > > about a year. > > Yesterday, I ran into a small problem, lexical_cast accepts copy instead of > > (const)? reference to a source. I have a class which I would prefer to be > > noncopyable and castable with laxical_cast at the same time. I've been > > forced to reject noncopyable concept because of that strange feature of the > > lexical_cast. Is there any particular reason of such feature? And if not, is > > it possible to fix it in new release? > > Wrap the object in boost::cref().
Unfortunately, cref won't work because lexical_cast propagates the source type as a template parameter to various helper/standard templates: std::numeric_limits<Source>::is_specialized typedef typename widest_char< typename stream_char<Target>::type, typename stream_char<Source>::type>::type char_type; A simpler solution is explicit providing of the source type: std::string result = boost::lexical_cast<std::string, T const&>( T() ); And that solution works fine on my very old version of lexical_cast, but it has the same problem as cref with new version. Thanks. Aleksandr Golovanov, MetaCommunications Engineering. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost