Boost logo

Boost :

Subject: Re: [boost] Static constexpr map (was: Re: [gsoc16] Can I quickly check if the below really is the best approach?)
From: Nevin Liber (nevin_at_[hidden])
Date: 2016-01-15 17:00:31


On 14 January 2016 at 22:41, Marshall Clow <mclow.lists_at_[hidden]> wrote:

> On Wed, Jan 13, 2016 at 11:43 AM, Niall Douglas <s_sourceforge_at_[hidden]
> >
> 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<std::experimental::string_view, value> to just work so that you
can do runtime lookups using C string literals and std:string directly.

-- 
 Nevin ":-)" Liber  <mailto:nevin_at_[hidden] <nevin_at_[hidden]>>
+1-847-691-1404

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