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
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 http://abel.web.elte.hu/mpllibs/metaparse/manual.html#the-input-of-the-parse... and http://abel.web.elte.hu/mpllibs/metaparse/MPLLIBS_STRING.html). 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: https://github.com/sabel83/metaparse_tutorial#metaparse-tutorial. Regards, Ábel