On 1/15/2016 7:00 PM, Nevin Liber wrote:
On 14 January 2016 at 22:41, Marshall Clow
wrote: 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.
This is a very good point. However, nothing stops us from internally mapping `std::char_traits<CharT>` to `boost::detail::constexpr_char_traits<CharT>` when the compiler supports C++14 constexpr. Regards, -- Agustín K-ballo Bergé.- http://talesofcpp.fusionfenix.com