Topic: Generalize the ability to analyse strings at compile-time.


Author: snk_kid <korcanh@googlemail.com>
Date: Wed, 28 Oct 2009 11:08:05 CST
Raw View
 From what I've gathered only constexpr literal operator overload using
variadic template of non-type char parameter gives us the ability to
do this with string literals but this is a bit of silly restriction.

This should work with any kind of constexpr variadic template
functions not just user-defined literals.

Ocaml and F# support analysing strings a compile-time in any function,
using a  parametric type which the compiler treats specially. The
compiler deduces the type of the function given a format string and
gives the generated function type to the special format type's type
variable (and therefore doesn't require the use of variadic
functions).

Anyway my point is this feature should be more general, and therefore
more useful and require less hacks than using user-defined literals
and doing things like returning proxy objects.

--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]