diff options
author | Eric Fiselier <eric@efcs.ca> | 2016-06-02 01:25:41 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2016-06-02 01:25:41 +0000 |
commit | 5725756791452eb91e23e37cb9958687771cb10a (patch) | |
tree | 500212f9a7deda8f50d4ebea40b2bd9ef856cdc4 /libcxx/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp | |
parent | 5a7159c4162ccef33ee82a150d2b35d3372b0b6e (diff) | |
download | bcm5719-llvm-5725756791452eb91e23e37cb9958687771cb10a.tar.gz bcm5719-llvm-5725756791452eb91e23e37cb9958687771cb10a.zip |
Add C++17 std::not_fn negator.
Summary:
Exactly what it sounds like.
I plan to commit this in a couple of days assuming no objections.
Reviewers: mclow.lists, EricWF
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D20799
llvm-svn: 271464
Diffstat (limited to 'libcxx/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp')
-rw-r--r-- | libcxx/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/libcxx/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp b/libcxx/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp index 3f02c7c4c81..e78323f5ae8 100644 --- a/libcxx/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp @@ -304,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; + CopyThrows arg; + static_assert(noexcept(std::invoke(obj))); + static_assert(!noexcept(std::invoke(obj, arg))); + static_assert(noexcept(std::invoke(obj, std::move(arg)))); + } + { + ThrowsCallable obj; + static_assert(!noexcept(std::invoke(obj))); + } + { + MemberObj obj{42}; + static_assert(noexcept(std::invoke(&MemberObj::x, obj))); + } +} + int main() { bullet_one_two_tests(); bullet_three_four_tests(); bullet_five_tests(); + noexcept_test(); } |