Templates coupled with abusing operator overloading and escaping rules.
Basically, the layout is a red herring to an extent. E.g. the "\" in the shapes is only there for visuals - it's allowed because it's escaping the following linefeed, but not necessary.
If you strip out the "filler" it boils down to constructing an expression, using types and overloaded operators to represent an expression tree that is then evaluated by the C++ template processing to satisfy type constraints.
The "asserts" of sorts works by using templates to create a type that accepts only the corresponding type generated by the "literal" shapes as argument to the constructor.
It looks harder than it is because it's hard to "see" operators. Consider that e.g. "o---o" is "(o--) - o". and a rectangle boils down to "((o--) - o) | (!(!(!((o--)-o))))" or so (hope I got the parentheses right).
Sort-of. I've not bothered deciphering the exact details of how it's processed. The overall mechanism of using types and operator overloading to represent expressions is pretty well established in C++ template meta-programming, though, and is also used elsewhere. E.g. a lot of Ruby ORM query building and other DSLs is often using similar methods.
Basically, the layout is a red herring to an extent. E.g. the "\" in the shapes is only there for visuals - it's allowed because it's escaping the following linefeed, but not necessary.
If you strip out the "filler" it boils down to constructing an expression, using types and overloaded operators to represent an expression tree that is then evaluated by the C++ template processing to satisfy type constraints.
The "asserts" of sorts works by using templates to create a type that accepts only the corresponding type generated by the "literal" shapes as argument to the constructor.
It looks harder than it is because it's hard to "see" operators. Consider that e.g. "o---o" is "(o--) - o". and a rectangle boils down to "((o--) - o) | (!(!(!((o--)-o))))" or so (hope I got the parentheses right).
Sort-of. I've not bothered deciphering the exact details of how it's processed. The overall mechanism of using types and operator overloading to represent expressions is pretty well established in C++ template meta-programming, though, and is also used elsewhere. E.g. a lot of Ruby ORM query building and other DSLs is often using similar methods.