[PATCH] D49647: [libcxx] Library support for contracts (C++2a)
Marshall Clow via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 23 10:11:23 PDT 2018
mclow.lists added a comment.
> Testing whether it's actually hooked up correctly is quite problematic; it isn't meant to be instantiable. What's the best way to proceed with this?
The compiler is supposed to create these - right?
Does clang currently do this?
- If not, we should wait for them to catch up.
- If so, then we should have tests that have a contract violation, and pass these around.
Since the method for hooking up a CV proc is implementation-defined, those tests will probably have to go into `test/libcxx`.
================
Comment at: test/std/language.support/support.contract/contract_violation.pass.cpp:27
+
+ ASSERT_NOEXCEPT(violation.line_number());
+ ASSERT_NOEXCEPT(violation.file_name());
----------------
You can do this better with static_assert and declval:
static_assert(noexcept(std::declval<const contract_violation&>().line_number()), "");
and same with the types:
static_assert(std::is_same_v<decltype(std::declval<const contract_violation&>().line_number()>, std::uint_least32_t>, "");
(It's shorter to write `using CV = const contract_violation;` and then `declval<CV&>()`)
https://reviews.llvm.org/D49647
More information about the cfe-commits
mailing list