Boost logo

Boost :

Subject: Re: [boost] is_lexical_convertible
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2014-11-23 16:40:49


On Sunday 23 November 2014 23:54:26 endight . wrote:
> Is there something like `boost::is_lexical_convertible` (like
> `boost::is_convertible`)?

You mean a trait that tells if lexical_cast will work for your type? I don't
think so. Your best bet is has_left_shift and has_right_shift, with the left
operand type being the stream and the right one your type. But that doesn't
tell that lexical_cast will actually succeed because the stream operators can
be not reversible. In general there is no way to tell that the operators are
reversible, so without some help from the user such a trait cannot be
implemented.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk