Closed ashtum closed 10 months ago
@pdimov, do you have any suggestions on how to add a test to verify that get_child doesn't compile with temporary default values? Can I use a concept and include it as a test for C++20 and higher? (although it doesn't look elegant)
Use a compile-fail test.
Use a compile-fail test.
Just out of curiosity, is there any alternative way to test it without using a separate compilation unit? I mean, in complex scenarios, the compilation failure could be due to other reasons as well.
There probably is but I wouldn't recommend it.
Something like https://godbolt.org/z/j7MaTGTcd.
Something like https://godbolt.org/z/j7MaTGTcd.
Do you discourage it because of the possibility of the expression becoming invalid for other reasons and not manifesting itself in the test? If that's the case, can't we mitigate this by also testing valid expressions, like so:
static_assert(mp_valid<accepts_default_of_type, ptree&>::value, "");
static_assert(mp_valid<accepts_default_of_type, const ptree&>::value, "");
It's too complicated, requires specialized knowledge to understand, and is therefore hard to maintain.
Resolves #42