forked from OSchip/llvm-project
Don't use C++17 terse static assert. Patch from STL@microsoft.com
llvm-svn: 273353
This commit is contained in:
parent
060ecaf672
commit
7a580d0a72
|
@ -327,17 +327,17 @@ void noexcept_test() {
|
||||||
{
|
{
|
||||||
NoThrowCallable obj; ((void)obj); // suppress unused warning
|
NoThrowCallable obj; ((void)obj); // suppress unused warning
|
||||||
CopyThrows arg; ((void)arg); // suppress unused warning
|
CopyThrows arg; ((void)arg); // suppress unused warning
|
||||||
static_assert(noexcept(std::invoke(obj)));
|
static_assert(noexcept(std::invoke(obj)), "");
|
||||||
static_assert(!noexcept(std::invoke(obj, arg)));
|
static_assert(!noexcept(std::invoke(obj, arg)), "");
|
||||||
static_assert(noexcept(std::invoke(obj, std::move(arg))));
|
static_assert(noexcept(std::invoke(obj, std::move(arg))), "");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ThrowsCallable obj; ((void)obj); // suppress unused warning
|
ThrowsCallable obj; ((void)obj); // suppress unused warning
|
||||||
static_assert(!noexcept(std::invoke(obj)));
|
static_assert(!noexcept(std::invoke(obj)), "");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
MemberObj obj{42}; ((void)obj); // suppress unused warning.
|
MemberObj obj{42}; ((void)obj); // suppress unused warning.
|
||||||
static_assert(noexcept(std::invoke(&MemberObj::x, obj)));
|
static_assert(noexcept(std::invoke(&MemberObj::x, obj)), "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -250,10 +250,10 @@ void constructor_tests()
|
||||||
using T = MoveOnlyCallable<bool>;
|
using T = MoveOnlyCallable<bool>;
|
||||||
T value(true);
|
T value(true);
|
||||||
using RetT = decltype(std::not_fn(std::move(value)));
|
using RetT = decltype(std::not_fn(std::move(value)));
|
||||||
static_assert(std::is_move_constructible<RetT>::value);
|
static_assert(std::is_move_constructible<RetT>::value, "");
|
||||||
static_assert(!std::is_copy_constructible<RetT>::value);
|
static_assert(!std::is_copy_constructible<RetT>::value, "");
|
||||||
static_assert(!std::is_move_assignable<RetT>::value);
|
static_assert(!std::is_move_assignable<RetT>::value, "");
|
||||||
static_assert(!std::is_copy_assignable<RetT>::value);
|
static_assert(!std::is_copy_assignable<RetT>::value, "");
|
||||||
auto ret = std::not_fn(std::move(value));
|
auto ret = std::not_fn(std::move(value));
|
||||||
// test it was moved from
|
// test it was moved from
|
||||||
assert(value.value == false);
|
assert(value.value == false);
|
||||||
|
@ -271,10 +271,10 @@ void constructor_tests()
|
||||||
using T = CopyCallable<bool>;
|
using T = CopyCallable<bool>;
|
||||||
T value(false);
|
T value(false);
|
||||||
using RetT = decltype(std::not_fn(value));
|
using RetT = decltype(std::not_fn(value));
|
||||||
static_assert(std::is_move_constructible<RetT>::value);
|
static_assert(std::is_move_constructible<RetT>::value, "");
|
||||||
static_assert(std::is_copy_constructible<RetT>::value);
|
static_assert(std::is_copy_constructible<RetT>::value, "");
|
||||||
static_assert(!std::is_move_assignable<RetT>::value);
|
static_assert(!std::is_move_assignable<RetT>::value, "");
|
||||||
static_assert(!std::is_copy_assignable<RetT>::value);
|
static_assert(!std::is_copy_assignable<RetT>::value, "");
|
||||||
auto ret = std::not_fn(value);
|
auto ret = std::not_fn(value);
|
||||||
// test that value is unchanged (copied not moved)
|
// test that value is unchanged (copied not moved)
|
||||||
assert(value.value == false);
|
assert(value.value == false);
|
||||||
|
@ -292,10 +292,10 @@ void constructor_tests()
|
||||||
T value(true);
|
T value(true);
|
||||||
T value2(false);
|
T value2(false);
|
||||||
using RetT = decltype(std::not_fn(value));
|
using RetT = decltype(std::not_fn(value));
|
||||||
static_assert(std::is_move_constructible<RetT>::value);
|
static_assert(std::is_move_constructible<RetT>::value, "");
|
||||||
static_assert(std::is_copy_constructible<RetT>::value);
|
static_assert(std::is_copy_constructible<RetT>::value, "");
|
||||||
static_assert(std::is_move_assignable<RetT>::value);
|
static_assert(std::is_move_assignable<RetT>::value, "");
|
||||||
static_assert(std::is_copy_assignable<RetT>::value);
|
static_assert(std::is_copy_assignable<RetT>::value, "");
|
||||||
auto ret = std::not_fn(value);
|
auto ret = std::not_fn(value);
|
||||||
assert(ret() == false);
|
assert(ret() == false);
|
||||||
auto ret2 = std::not_fn(value2);
|
auto ret2 = std::not_fn(value2);
|
||||||
|
@ -309,10 +309,10 @@ void constructor_tests()
|
||||||
T value(true);
|
T value(true);
|
||||||
T value2(false);
|
T value2(false);
|
||||||
using RetT = decltype(std::not_fn(std::move(value)));
|
using RetT = decltype(std::not_fn(std::move(value)));
|
||||||
static_assert(std::is_move_constructible<RetT>::value);
|
static_assert(std::is_move_constructible<RetT>::value, "");
|
||||||
static_assert(!std::is_copy_constructible<RetT>::value);
|
static_assert(!std::is_copy_constructible<RetT>::value, "");
|
||||||
static_assert(std::is_move_assignable<RetT>::value);
|
static_assert(std::is_move_assignable<RetT>::value, "");
|
||||||
static_assert(!std::is_copy_assignable<RetT>::value);
|
static_assert(!std::is_copy_assignable<RetT>::value, "");
|
||||||
auto ret = std::not_fn(std::move(value));
|
auto ret = std::not_fn(std::move(value));
|
||||||
assert(ret() == false);
|
assert(ret() == false);
|
||||||
auto ret2 = std::not_fn(std::move(value2));
|
auto ret2 = std::not_fn(std::move(value2));
|
||||||
|
@ -328,21 +328,21 @@ void return_type_tests()
|
||||||
{
|
{
|
||||||
using T = CopyCallable<bool>;
|
using T = CopyCallable<bool>;
|
||||||
auto ret = std::not_fn(T{false});
|
auto ret = std::not_fn(T{false});
|
||||||
static_assert(is_same<decltype(ret()), bool>::value);
|
static_assert(is_same<decltype(ret()), bool>::value, "");
|
||||||
static_assert(is_same<decltype(ret("abc")), bool>::value);
|
static_assert(is_same<decltype(ret("abc")), bool>::value, "");
|
||||||
assert(ret() == true);
|
assert(ret() == true);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
using T = CopyCallable<ExplicitBool>;
|
using T = CopyCallable<ExplicitBool>;
|
||||||
auto ret = std::not_fn(T{true});
|
auto ret = std::not_fn(T{true});
|
||||||
static_assert(is_same<decltype(ret()), bool>::value);
|
static_assert(is_same<decltype(ret()), bool>::value, "");
|
||||||
static_assert(is_same<decltype(ret(std::string("abc"))), bool>::value);
|
static_assert(is_same<decltype(ret(std::string("abc"))), bool>::value, "");
|
||||||
assert(ret() == false);
|
assert(ret() == false);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
using T = CopyCallable<EvilBool>;
|
using T = CopyCallable<EvilBool>;
|
||||||
auto ret = std::not_fn(T{false});
|
auto ret = std::not_fn(T{false});
|
||||||
static_assert(is_same<decltype(ret()), EvilBool>::value);
|
static_assert(is_same<decltype(ret()), EvilBool>::value, "");
|
||||||
EvilBool::bang_called = 0;
|
EvilBool::bang_called = 0;
|
||||||
auto value_ret = ret();
|
auto value_ret = ret();
|
||||||
assert(EvilBool::bang_called == 1);
|
assert(EvilBool::bang_called == 1);
|
||||||
|
@ -420,26 +420,26 @@ void throws_in_constructor_test()
|
||||||
void call_operator_sfinae_test() {
|
void call_operator_sfinae_test() {
|
||||||
{ // wrong number of arguments
|
{ // wrong number of arguments
|
||||||
using T = decltype(std::not_fn(returns_true));
|
using T = decltype(std::not_fn(returns_true));
|
||||||
static_assert(std::is_callable<T()>::value); // callable only with no args
|
static_assert(std::is_callable<T()>::value, ""); // callable only with no args
|
||||||
static_assert(!std::is_callable<T(bool)>::value);
|
static_assert(!std::is_callable<T(bool)>::value, "");
|
||||||
}
|
}
|
||||||
{ // violates const correctness (member function pointer)
|
{ // violates const correctness (member function pointer)
|
||||||
using T = decltype(std::not_fn(&MemFunCallable::return_value_nc));
|
using T = decltype(std::not_fn(&MemFunCallable::return_value_nc));
|
||||||
static_assert(std::is_callable<T(MemFunCallable&)>::value);
|
static_assert(std::is_callable<T(MemFunCallable&)>::value, "");
|
||||||
static_assert(!std::is_callable<T(const MemFunCallable&)>::value);
|
static_assert(!std::is_callable<T(const MemFunCallable&)>::value, "");
|
||||||
}
|
}
|
||||||
{ // violates const correctness (call object)
|
{ // violates const correctness (call object)
|
||||||
using Obj = CopyCallable<bool>;
|
using Obj = CopyCallable<bool>;
|
||||||
using NCT = decltype(std::not_fn(Obj{true}));
|
using NCT = decltype(std::not_fn(Obj{true}));
|
||||||
using CT = const NCT;
|
using CT = const NCT;
|
||||||
static_assert(std::is_callable<NCT()>::value);
|
static_assert(std::is_callable<NCT()>::value, "");
|
||||||
static_assert(!std::is_callable<CT()>::value);
|
static_assert(!std::is_callable<CT()>::value, "");
|
||||||
}
|
}
|
||||||
{ // returns bad type with no operator!
|
{ // returns bad type with no operator!
|
||||||
auto fn = [](auto x) { return x; };
|
auto fn = [](auto x) { return x; };
|
||||||
using T = decltype(std::not_fn(fn));
|
using T = decltype(std::not_fn(fn));
|
||||||
static_assert(std::is_callable<T(bool)>::value);
|
static_assert(std::is_callable<T(bool)>::value, "");
|
||||||
static_assert(!std::is_callable<T(std::string)>::value);
|
static_assert(!std::is_callable<T(std::string)>::value, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,24 +46,24 @@ int main()
|
||||||
// INVOKE bullet 1, 2 and 3
|
// INVOKE bullet 1, 2 and 3
|
||||||
{
|
{
|
||||||
// Bullet 1
|
// Bullet 1
|
||||||
static_assert(std::is_callable<Fn(Tag&, int)>::value);
|
static_assert(std::is_callable<Fn(Tag&, int)>::value, "");
|
||||||
static_assert(std::is_callable<Fn(DerFromTag&, int)>::value);
|
static_assert(std::is_callable<Fn(DerFromTag&, int)>::value, "");
|
||||||
static_assert(std::is_callable<RFn(Tag&&, int)>::value);
|
static_assert(std::is_callable<RFn(Tag&&, int)>::value, "");
|
||||||
static_assert(!std::is_callable<RFn(Tag&, int)>::value);
|
static_assert(!std::is_callable<RFn(Tag&, int)>::value, "");
|
||||||
static_assert(!std::is_callable<Fn(Tag&)>::value);
|
static_assert(!std::is_callable<Fn(Tag&)>::value, "");
|
||||||
static_assert(!std::is_callable<Fn(Tag const&, int)>::value);
|
static_assert(!std::is_callable<Fn(Tag const&, int)>::value, "");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Bullet 2
|
// Bullet 2
|
||||||
using T = std::reference_wrapper<Tag>;
|
using T = std::reference_wrapper<Tag>;
|
||||||
using DT = std::reference_wrapper<DerFromTag>;
|
using DT = std::reference_wrapper<DerFromTag>;
|
||||||
using CT = std::reference_wrapper<const Tag>;
|
using CT = std::reference_wrapper<const Tag>;
|
||||||
static_assert(std::is_callable<Fn(T&, int)>::value);
|
static_assert(std::is_callable<Fn(T&, int)>::value, "");
|
||||||
static_assert(std::is_callable<Fn(DT&, int)>::value);
|
static_assert(std::is_callable<Fn(DT&, int)>::value, "");
|
||||||
static_assert(std::is_callable<Fn(const T&, int)>::value);
|
static_assert(std::is_callable<Fn(const T&, int)>::value, "");
|
||||||
static_assert(std::is_callable<Fn(T&&, int)>::value);
|
static_assert(std::is_callable<Fn(T&&, int)>::value, "");
|
||||||
static_assert(!std::is_callable<Fn(CT&, int)>::value);
|
static_assert(!std::is_callable<Fn(CT&, int)>::value, "");
|
||||||
static_assert(!std::is_callable<RFn(T, int)>::value);
|
static_assert(!std::is_callable<RFn(T, int)>::value, "");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Bullet 3
|
// Bullet 3
|
||||||
|
@ -71,36 +71,36 @@ int main()
|
||||||
using DT = DerFromTag*;
|
using DT = DerFromTag*;
|
||||||
using CT = const Tag*;
|
using CT = const Tag*;
|
||||||
using ST = std::unique_ptr<Tag>;
|
using ST = std::unique_ptr<Tag>;
|
||||||
static_assert(std::is_callable<Fn(T&, int)>::value);
|
static_assert(std::is_callable<Fn(T&, int)>::value, "");
|
||||||
static_assert(std::is_callable<Fn(DT&, int)>::value);
|
static_assert(std::is_callable<Fn(DT&, int)>::value, "");
|
||||||
static_assert(std::is_callable<Fn(const T&, int)>::value);
|
static_assert(std::is_callable<Fn(const T&, int)>::value, "");
|
||||||
static_assert(std::is_callable<Fn(T&&, int)>::value);
|
static_assert(std::is_callable<Fn(T&&, int)>::value, "");
|
||||||
static_assert(std::is_callable<Fn(ST, int)>::value);
|
static_assert(std::is_callable<Fn(ST, int)>::value, "");
|
||||||
static_assert(!std::is_callable<Fn(CT&, int)>::value);
|
static_assert(!std::is_callable<Fn(CT&, int)>::value, "");
|
||||||
static_assert(!std::is_callable<RFn(T, int)>::value);
|
static_assert(!std::is_callable<RFn(T, int)>::value, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Bullets 4, 5 and 6
|
// Bullets 4, 5 and 6
|
||||||
using Fn = int (Tag::*);
|
using Fn = int (Tag::*);
|
||||||
static_assert(!std::is_callable<Fn()>::value);
|
static_assert(!std::is_callable<Fn()>::value, "");
|
||||||
{
|
{
|
||||||
// Bullet 4
|
// Bullet 4
|
||||||
static_assert(std::is_callable<Fn(Tag&)>::value);
|
static_assert(std::is_callable<Fn(Tag&)>::value, "");
|
||||||
static_assert(std::is_callable<Fn(DerFromTag&)>::value);
|
static_assert(std::is_callable<Fn(DerFromTag&)>::value, "");
|
||||||
static_assert(std::is_callable<Fn(Tag&&)>::value);
|
static_assert(std::is_callable<Fn(Tag&&)>::value, "");
|
||||||
static_assert(std::is_callable<Fn(Tag const&)>::value);
|
static_assert(std::is_callable<Fn(Tag const&)>::value, "");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Bullet 5
|
// Bullet 5
|
||||||
using T = std::reference_wrapper<Tag>;
|
using T = std::reference_wrapper<Tag>;
|
||||||
using DT = std::reference_wrapper<DerFromTag>;
|
using DT = std::reference_wrapper<DerFromTag>;
|
||||||
using CT = std::reference_wrapper<const Tag>;
|
using CT = std::reference_wrapper<const Tag>;
|
||||||
static_assert(std::is_callable<Fn(T&)>::value);
|
static_assert(std::is_callable<Fn(T&)>::value, "");
|
||||||
static_assert(std::is_callable<Fn(DT&)>::value);
|
static_assert(std::is_callable<Fn(DT&)>::value, "");
|
||||||
static_assert(std::is_callable<Fn(const T&)>::value);
|
static_assert(std::is_callable<Fn(const T&)>::value, "");
|
||||||
static_assert(std::is_callable<Fn(T&&)>::value);
|
static_assert(std::is_callable<Fn(T&&)>::value, "");
|
||||||
static_assert(std::is_callable<Fn(CT&)>::value);
|
static_assert(std::is_callable<Fn(CT&)>::value, "");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Bullet 6
|
// Bullet 6
|
||||||
|
@ -108,12 +108,12 @@ int main()
|
||||||
using DT = DerFromTag*;
|
using DT = DerFromTag*;
|
||||||
using CT = const Tag*;
|
using CT = const Tag*;
|
||||||
using ST = std::unique_ptr<Tag>;
|
using ST = std::unique_ptr<Tag>;
|
||||||
static_assert(std::is_callable<Fn(T&)>::value);
|
static_assert(std::is_callable<Fn(T&)>::value, "");
|
||||||
static_assert(std::is_callable<Fn(DT&)>::value);
|
static_assert(std::is_callable<Fn(DT&)>::value, "");
|
||||||
static_assert(std::is_callable<Fn(const T&)>::value);
|
static_assert(std::is_callable<Fn(const T&)>::value, "");
|
||||||
static_assert(std::is_callable<Fn(T&&)>::value);
|
static_assert(std::is_callable<Fn(T&&)>::value, "");
|
||||||
static_assert(std::is_callable<Fn(ST)>::value);
|
static_assert(std::is_callable<Fn(ST)>::value, "");
|
||||||
static_assert(std::is_callable<Fn(CT&)>::value);
|
static_assert(std::is_callable<Fn(CT&)>::value, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -121,20 +121,20 @@ int main()
|
||||||
{
|
{
|
||||||
// Function pointer
|
// Function pointer
|
||||||
using Fp = void(*)(Tag&, int);
|
using Fp = void(*)(Tag&, int);
|
||||||
static_assert(std::is_callable<Fp(Tag&, int)>::value);
|
static_assert(std::is_callable<Fp(Tag&, int)>::value, "");
|
||||||
static_assert(std::is_callable<Fp(DerFromTag&, int)>::value);
|
static_assert(std::is_callable<Fp(DerFromTag&, int)>::value, "");
|
||||||
static_assert(!std::is_callable<Fp(const Tag&, int)>::value);
|
static_assert(!std::is_callable<Fp(const Tag&, int)>::value, "");
|
||||||
static_assert(!std::is_callable<Fp()>::value);
|
static_assert(!std::is_callable<Fp()>::value, "");
|
||||||
static_assert(!std::is_callable<Fp(Tag&)>::value);
|
static_assert(!std::is_callable<Fp(Tag&)>::value, "");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Function reference
|
// Function reference
|
||||||
using Fp = void(&)(Tag&, int);
|
using Fp = void(&)(Tag&, int);
|
||||||
static_assert(std::is_callable<Fp(Tag&, int)>::value);
|
static_assert(std::is_callable<Fp(Tag&, int)>::value, "");
|
||||||
static_assert(std::is_callable<Fp(DerFromTag&, int)>::value);
|
static_assert(std::is_callable<Fp(DerFromTag&, int)>::value, "");
|
||||||
static_assert(!std::is_callable<Fp(const Tag&, int)>::value);
|
static_assert(!std::is_callable<Fp(const Tag&, int)>::value, "");
|
||||||
static_assert(!std::is_callable<Fp()>::value);
|
static_assert(!std::is_callable<Fp()>::value, "");
|
||||||
static_assert(!std::is_callable<Fp(Tag&)>::value);
|
static_assert(!std::is_callable<Fp(Tag&)>::value, "");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Function object
|
// Function object
|
||||||
|
@ -146,15 +146,15 @@ int main()
|
||||||
{
|
{
|
||||||
// Check that the conversion to the return type is properly checked
|
// Check that the conversion to the return type is properly checked
|
||||||
using Fn = int(*)();
|
using Fn = int(*)();
|
||||||
static_assert(std::is_callable<Fn(), Implicit>::value);
|
static_assert(std::is_callable<Fn(), Implicit>::value, "");
|
||||||
static_assert(std::is_callable<Fn(), double>::value);
|
static_assert(std::is_callable<Fn(), double>::value, "");
|
||||||
static_assert(std::is_callable<Fn(), const volatile void>::value);
|
static_assert(std::is_callable<Fn(), const volatile void>::value, "");
|
||||||
static_assert(!std::is_callable<Fn(), Explicit>::value);
|
static_assert(!std::is_callable<Fn(), Explicit>::value, "");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Check for is_callable_v
|
// Check for is_callable_v
|
||||||
using Fn = void(*)();
|
using Fn = void(*)();
|
||||||
static_assert(std::is_callable_v<Fn()>);
|
static_assert(std::is_callable_v<Fn()>, "");
|
||||||
static_assert(!std::is_callable_v<Fn(int)>);
|
static_assert(!std::is_callable_v<Fn(int)>, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,16 +58,16 @@ void test_noexcept_function_pointers()
|
||||||
{
|
{
|
||||||
// Check that PMF's and function pointers *work*. is_nothrow_callable will always
|
// Check that PMF's and function pointers *work*. is_nothrow_callable will always
|
||||||
// return false because 'noexcept' is not part of the function type.
|
// return false because 'noexcept' is not part of the function type.
|
||||||
static_assert(throws_callable<decltype(&Dummy::foo)(Dummy&)>());
|
static_assert(throws_callable<decltype(&Dummy::foo)(Dummy&)>(), "");
|
||||||
static_assert(throws_callable<decltype(&Dummy::bar)()>());
|
static_assert(throws_callable<decltype(&Dummy::bar)()>(), "");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
// Check that PMF's and function pointers actually work and that
|
// Check that PMF's and function pointers actually work and that
|
||||||
// is_nothrow_callable returns true for noexcept PMF's and function
|
// is_nothrow_callable returns true for noexcept PMF's and function
|
||||||
// pointers.
|
// pointers.
|
||||||
static_assert(std::is_nothrow_callable<decltype(&Dummy::foo)(Dummy&)>::value);
|
static_assert(std::is_nothrow_callable<decltype(&Dummy::foo)(Dummy&)>::value, "");
|
||||||
static_assert(std::is_nothrow_callable<decltype(&Dummy::bar)()>::value);
|
static_assert(std::is_nothrow_callable<decltype(&Dummy::bar)()>::value, "");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -77,39 +77,39 @@ int main()
|
||||||
{
|
{
|
||||||
// Check that the conversion to the return type is properly checked
|
// Check that the conversion to the return type is properly checked
|
||||||
using Fn = CallObject<true, int>;
|
using Fn = CallObject<true, int>;
|
||||||
static_assert(std::is_nothrow_callable<Fn(), Implicit>::value);
|
static_assert(std::is_nothrow_callable<Fn(), Implicit>::value, "");
|
||||||
static_assert(std::is_nothrow_callable<Fn(), double>::value);
|
static_assert(std::is_nothrow_callable<Fn(), double>::value, "");
|
||||||
static_assert(std::is_nothrow_callable<Fn(), const volatile void>::value);
|
static_assert(std::is_nothrow_callable<Fn(), const volatile void>::value, "");
|
||||||
static_assert(throws_callable<Fn(), ThrowsImplicit>());
|
static_assert(throws_callable<Fn(), ThrowsImplicit>(), "");
|
||||||
static_assert(!std::is_nothrow_callable<Fn(), Explicit>());
|
static_assert(!std::is_nothrow_callable<Fn(), Explicit>(), "");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Check that the conversion to the parameters is properly checked
|
// Check that the conversion to the parameters is properly checked
|
||||||
using Fn = CallObject<true, void, const Implicit&, const ThrowsImplicit&>;
|
using Fn = CallObject<true, void, const Implicit&, const ThrowsImplicit&>;
|
||||||
static_assert(std::is_nothrow_callable<Fn(Implicit&, ThrowsImplicit&)>::value);
|
static_assert(std::is_nothrow_callable<Fn(Implicit&, ThrowsImplicit&)>::value, "");
|
||||||
static_assert(std::is_nothrow_callable<Fn(int, ThrowsImplicit&)>::value);
|
static_assert(std::is_nothrow_callable<Fn(int, ThrowsImplicit&)>::value, "");
|
||||||
static_assert(throws_callable<Fn(int, int)>());
|
static_assert(throws_callable<Fn(int, int)>(), "");
|
||||||
static_assert(!std::is_nothrow_callable<Fn()>::value);
|
static_assert(!std::is_nothrow_callable<Fn()>::value, "");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Check that the noexcept-ness of function objects is checked.
|
// Check that the noexcept-ness of function objects is checked.
|
||||||
using Fn = CallObject<true, void>;
|
using Fn = CallObject<true, void>;
|
||||||
using Fn2 = CallObject<false, void>;
|
using Fn2 = CallObject<false, void>;
|
||||||
static_assert(std::is_nothrow_callable<Fn()>::value);
|
static_assert(std::is_nothrow_callable<Fn()>::value, "");
|
||||||
static_assert(throws_callable<Fn2()>());
|
static_assert(throws_callable<Fn2()>(), "");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Check that PMD derefs are noexcept
|
// Check that PMD derefs are noexcept
|
||||||
using Fn = int (Tag::*);
|
using Fn = int (Tag::*);
|
||||||
static_assert(std::is_nothrow_callable<Fn(Tag&)>::value);
|
static_assert(std::is_nothrow_callable<Fn(Tag&)>::value, "");
|
||||||
static_assert(std::is_nothrow_callable<Fn(Tag&), Implicit>::value);
|
static_assert(std::is_nothrow_callable<Fn(Tag&), Implicit>::value, "");
|
||||||
static_assert(throws_callable<Fn(Tag&), ThrowsImplicit>());
|
static_assert(throws_callable<Fn(Tag&), ThrowsImplicit>(), "");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Check for is_nothrow_callable_v
|
// Check for is_nothrow_callable_v
|
||||||
using Fn = CallObject<true, int>;
|
using Fn = CallObject<true, int>;
|
||||||
static_assert(std::is_nothrow_callable_v<Fn()>);
|
static_assert(std::is_nothrow_callable_v<Fn()>, "");
|
||||||
static_assert(!std::is_nothrow_callable_v<Fn(int)>);
|
static_assert(!std::is_nothrow_callable_v<Fn(int)>, "");
|
||||||
}
|
}
|
||||||
test_noexcept_function_pointers();
|
test_noexcept_function_pointers();
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ int main()
|
||||||
static_assert(!std::is_nothrow_swappable<B>::value
|
static_assert(!std::is_nothrow_swappable<B>::value
|
||||||
&& std::is_swappable<B>::value, "");
|
&& std::is_swappable<B>::value, "");
|
||||||
static_assert(!std::is_nothrow_swappable<ThrowingMove>::value
|
static_assert(!std::is_nothrow_swappable<ThrowingMove>::value
|
||||||
&& std::is_swappable<ThrowingMove>::value);
|
&& std::is_swappable<ThrowingMove>::value, "");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Test that it doesn't drop the qualifiers
|
// Test that it doesn't drop the qualifiers
|
||||||
|
@ -77,7 +77,7 @@ int main()
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// test for presence of is_nothrow_swappable_v
|
// test for presence of is_nothrow_swappable_v
|
||||||
static_assert(std::is_nothrow_swappable_v<int>);
|
static_assert(std::is_nothrow_swappable_v<int>, "");
|
||||||
static_assert(!std::is_nothrow_swappable_v<void>);
|
static_assert(!std::is_nothrow_swappable_v<void>, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,14 +68,14 @@ int main()
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// test we guard against cv void inputs as required.
|
// test we guard against cv void inputs as required.
|
||||||
static_assert(!std::is_nothrow_swappable_with_v<void, int>);
|
static_assert(!std::is_nothrow_swappable_with_v<void, int>, "");
|
||||||
static_assert(!std::is_nothrow_swappable_with_v<int, void>);
|
static_assert(!std::is_nothrow_swappable_with_v<int, void>, "");
|
||||||
static_assert(!std::is_nothrow_swappable_with_v<const void, const volatile void>);
|
static_assert(!std::is_nothrow_swappable_with_v<const void, const volatile void>, "");
|
||||||
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// test for presense of is_nothrow_swappable_with_v
|
// test for presense of is_nothrow_swappable_with_v
|
||||||
static_assert(std::is_nothrow_swappable_with_v<int&, int&>);
|
static_assert(std::is_nothrow_swappable_with_v<int&, int&>, "");
|
||||||
static_assert(!std::is_nothrow_swappable_with_v<int&&, int&&>);
|
static_assert(!std::is_nothrow_swappable_with_v<int&&, int&&>, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ int main()
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// test for presense of is_swappable_v
|
// test for presense of is_swappable_v
|
||||||
static_assert(std::is_swappable_v<int>);
|
static_assert(std::is_swappable_v<int>, "");
|
||||||
static_assert(!std::is_swappable_v<M>);
|
static_assert(!std::is_swappable_v<M>, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,13 +66,13 @@ int main()
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// test that cv void is guarded against as required.
|
// test that cv void is guarded against as required.
|
||||||
static_assert(!std::is_swappable_with_v<void, int>);
|
static_assert(!std::is_swappable_with_v<void, int>, "");
|
||||||
static_assert(!std::is_swappable_with_v<int, void>);
|
static_assert(!std::is_swappable_with_v<int, void>, "");
|
||||||
static_assert(!std::is_swappable_with_v<const void, const volatile void>);
|
static_assert(!std::is_swappable_with_v<const void, const volatile void>, "");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// test for presence of is_swappable_with_v
|
// test for presence of is_swappable_with_v
|
||||||
static_assert(std::is_swappable_with_v<int&, int&>);
|
static_assert(std::is_swappable_with_v<int&, int&>, "");
|
||||||
static_assert(!std::is_swappable_with_v<D&, C&>);
|
static_assert(!std::is_swappable_with_v<D&, C&>, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue