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:
Eric Fiselier
2016-06-02 01:25:41 +00:00
parent a27cbf8a13
commit c230822a61
4 changed files with 627 additions and 4 deletions

View File

@@ -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();
}