Flyweight: constexpr user defined literals
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); I've seen nothing about "constexpr" in the doc.
Akim Demaille
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
participants (2)
-
Akim Demaille
-
Joaquín M Lopez Munoz