|
Boost Users : |
Subject: Re: [Boost-users] Flyweight: constexpr user defined literals
From: JoaquÃn M Lopez Munoz (joaquin_at_[hidden])
Date: 2014-11-07 15:52:52
Akim Demaille <akim <at> lrde.epita.fr> writes:
>
> Hi all, Hi Joaquin,
>
> I'm using flyweights of strings (aka symbols) for my "format" arguments: a
> key that specifies the kind of output that should be produced
> by the printing routines.
>
> Sometimes, I have code that roughly resembles to:
>
> print_entry_(src, dst, o, dot2tex_ ? symbol("latex") : symbol("text"));
>
> My question is: do we have constexpr constructors with Flyweight
> in such a way that I could have something like:
>
> print_entry_(src, dst, o, dot2tex_ ? "latex"sym : "text"sym);
>
> and have a single construction of these guys not matter how many
> times I go throw this piece of code, or should I build them once for
> all in say a member?
>
> print_entry_(src, dst, o, dot2tex_ ? sym_latex : sym_text);
boost::flyweight can't have a constexpr ctor because it's not a literal type
(and can't be made one). "latex"sum would work the same way as
"latex"s produces a std::string yet it's not constexpr.
JoaquÃn M López Muñoz
Telefónica
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net