From 51072bd6bf79ef2bc6a922079bff57c31c1effbc Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 23 Jul 2016 20:47:26 +0000 Subject: Vendor import of libc++ release_39 branch r276489: https://llvm.org/svn/llvm-project/libcxx/branches/release_39@276489 --- .../function.objects/func.invoke/invoke.pass.cpp | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) (limited to 'test/std/utilities/function.objects/func.invoke/invoke.pass.cpp') diff --git a/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp b/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp index 97b0b4d158a0c..d1ae6b7809ce8 100644 --- a/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp +++ b/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp @@ -172,6 +172,32 @@ void bullet_one_two_tests() { test_b12(std::move(cl)); test_b12(std::move(cl)); } + { + TestClass cl_obj(42); + std::reference_wrapper cl(cl_obj); + test_b12(cl); + test_b12(cl); + test_b12(cl); + test_b12(cl); + + test_b12(std::move(cl)); + test_b12(std::move(cl)); + test_b12(std::move(cl)); + test_b12(std::move(cl)); + } + { + DerivedFromTestClass cl_obj(42); + std::reference_wrapper cl(cl_obj); + test_b12(cl); + test_b12(cl); + test_b12(cl); + test_b12(cl); + + test_b12(std::move(cl)); + test_b12(std::move(cl)); + test_b12(std::move(cl)); + test_b12(std::move(cl)); + } { TestClass cl_obj(42); TestClass *cl = &cl_obj; @@ -217,6 +243,22 @@ void bullet_three_four_tests() { test_b34(static_cast(cl)); test_b34(static_cast(cl)); } + { + typedef TestClass Fn; + Fn cl(42); + test_b34(std::reference_wrapper(cl)); + test_b34(std::reference_wrapper(cl)); + test_b34(std::reference_wrapper(cl)); + test_b34(std::reference_wrapper(cl)); + } + { + typedef DerivedFromTestClass Fn; + Fn cl(42); + test_b34(std::reference_wrapper(cl)); + test_b34(std::reference_wrapper(cl)); + test_b34(std::reference_wrapper(cl)); + test_b34(std::reference_wrapper(cl)); + } { typedef TestClass Fn; Fn cl_obj(42); @@ -262,8 +304,46 @@ void bullet_five_tests() { } } +struct CopyThrows { + CopyThrows() {} + CopyThrows(CopyThrows const&) {} + CopyThrows(CopyThrows&&) noexcept {} +}; + +struct NoThrowCallable { + void operator()() noexcept {} + void operator()(CopyThrows) noexcept {} +}; + +struct ThrowsCallable { + void operator()() {} +}; + +struct MemberObj { + int x; +}; + +void noexcept_test() { + { + NoThrowCallable obj; ((void)obj); // suppress unused warning + CopyThrows arg; ((void)arg); // suppress unused warning + static_assert(noexcept(std::invoke(obj)), ""); + static_assert(!noexcept(std::invoke(obj, arg)), ""); + static_assert(noexcept(std::invoke(obj, std::move(arg))), ""); + } + { + ThrowsCallable obj; ((void)obj); // suppress unused warning + static_assert(!noexcept(std::invoke(obj)), ""); + } + { + MemberObj obj{42}; ((void)obj); // suppress unused warning. + static_assert(noexcept(std::invoke(&MemberObj::x, obj)), ""); + } +} + int main() { bullet_one_two_tests(); bullet_three_four_tests(); bullet_five_tests(); + noexcept_test(); } -- cgit v1.2.3