On 14 January 2016 at 22:41, Marshall Clow
On Wed, Jan 13, 2016 at 11:43 AM, Niall Douglas
wrote:
Sadly, the current proposal for string_view does not provide a default Traits length function which is constexpr for const char *. Yes, I find that very daft as a default design choice for a string_view, but the macro at least makes it not too irritating.
It uses the existing char_traits classes, which, as you note, are not constexpr. (for some *very odd* reasons).
But writing your own traits class that has constexpr len/compare/etc is really, really simple. Maybe I'll do that this weekend, and add it to boost. :-)
Because it gets passed in as a template parameter, it isn't really all that
general a solution, as it makes your string and string_view types different
than std::string and std::experimental_string_view.
If it is only used for initializing the static_map, that would probably be
fine, but if it appears anywhere else in the interface, it just makes the
static_map harder to use. You really want
static_map