[C++-sig] Re: Must be CopyConstructible for stringification?
dave at boost-consulting.com
Fri Feb 27 01:37:19 CET 2004
Andreas Kloeckner <ak at ixion.net> writes:
> Hi all,
> I've discovered that in order to have a __str__ method, i.e. to be able to
> .def( self_ns::str(self))
> on a class_, it has to be CopyConstructible, or rather, is copy
> constructed when passed to boost::lexical_cast. This strikes me as
> slightly odd, since a reference would have done just as well, and not
> everything that can be sensibly stringified is also copyconstructible
> (or cheaply so, thinking matrices and lists).
> In short: Wouldn't it make sense to pass lexical_cast a reference
> instead of a copy?
You don't get to choose whether you're pasing a reference or a copy;
the signature of the called function does that. You need to take it
up with the author of lexical_cast.
More information about the Cplusplus-sig