
On Wed, Apr 11, 2012 at 5:18 PM, Eric Niebler <eric@boostpro.com> wrote:
You have to construct a string somewhere, don't you? If you have one already, you could use iterator_range<const char*> instead to avoid a copy.
Yes, I see that lexical_cast has optimizations for iterator_range<wchar_t const *> and a few other, sufficiently 'string-like' types. But sub_match essentially *is* a string-like iterator_range. (It's a std::pair of iterators.) I'm genuinely surprised
Is it? Does it have begin() and end() for example? Why not use std::iterator_range instead of std::pair?
there's no way to tell lexical_cast that. Instead I have to just know (a) which are the magical types lexical_cast is optimized for and (b) for which it can determine the correct underlying stream character type (hint: the docs are unclear or out of date), and massage my type into one of those before calling lexical_cast. Why?
How could it automatically determine the necessary character type? Olaf