Subject: [boost] [offtopic] user-defined raw string literals
From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2014-01-30 11:25:49
I have some idea related to the usage of UDLs in Boost.Geometry library
but the way I'd like to handle it is AFAIK not supported.
A little introduction first. There are many text-based languages of
defining data. One of them is WKT
(http://en.wikipedia.org/wiki/Well-known_text) which allows to define
vector data e.g. a polygon like this:
|POLYGON((30 10, 40 40, 20 40, 10 20, 30 10))|
So my thought was: why not use C++11 UDLs for this purpose? There are
operators in the WKT language so I should probably use string literal,
put WKT in it and be happy with it. The use case could look like this:
|auto ||polygon = "POLYGON((30 10,40 40,20 40,10 20,30 10))|"_wkt;
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"":
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?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk