On Friday, 5 February 2016 at 09:36:37 UTC, Andrea Fontana wrote:
On Wednesday, 3 February 2016 at 22:45:47 UTC, Timon Gehr wrote:
I would use enum forceCTFE(alias expr)=expr; though. With
alias it won't force compile-time evaluation of expressions
that can be interpreted as symbols.
I've a code that build a JSON object using a wrapper over
std.json.
This code:
----
enum forceCTFE(alias expr)=expr;
auto j = forceCTFE!(
JSOB
(
"hello", JSOB("world", 3),
"arr", JSAB("hello", JSOB("world", 1))
)
);
j.put("/hello/world", "!");
j.put("/hello/blah", 42);
// Here j ==
{"arr":["hello",{"world":1}],"hello":{"blah":42,"world":"!"}}
Reading/parsing a JSON or a XML using std.json / std.xml could be
done on CTFE ?