mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-23 18:38:30 +08:00
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 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@271464 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user