Boost logo

Boost :

Subject: Re: [boost] [offtopic] user-defined raw string literals
From: Abel Sinkovics (abel_at_[hidden])
Date: 2014-02-01 03:54:08

Hi Adam,

On 2014-01-30 17:25, Adam Wulkiewicz wrote:
> Ok so now the tricky part. It should be parsed in compile-time, the
> type of the geometry retrieved from the string literal and proper type
> returned (bg::polygon<> in this case).
> Unfortunately string literals can't be handled as raw literals, e.g.
> using the variadic-template version of operator"":
> template <char...>
> void operator "" ()
> Why? Is there a reason for this?
> If we had the ability to use the compile-time version with string
> literals it would be possible to implement various compile-time
> parsers, not only for the mentioned WKT.
> So what do you think about it?

I don't know the reason for the string literal limitation, but I have a
workaround for it. You can use the MPLLIBS_STRING macro from Metaparse -
not in Boost yet. (see
Using that you can parse string literals at compile-time.

Metaparse itself is a library supporting the creation of parsers for
DSLs that are parsed at compile time. You might be able to create an
interface like this using that:

auto polygon = WKT("POLYGON((30 10,40 40,20 40,10 20,30 10))");
auto point = WKT("POINT(30 10)");
// ...

where WKT is a macro expanding to a template metaprogram-based parser
invocation. If you are interested in trying it out, there is a tutorial
which helps you getting started:


Boost list run by bdawes at, gregod at, cpdaniel at, john at