mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-25 19:11:21 +08:00
PR libstdc++/87538 Verify fix for std::experimental::not_fn
PR libstdc++/87538 * testsuite/experimental/functional/87538.cc: New test. From-SVN: r264922
This commit is contained in:
parent
606f6be67b
commit
aca0dcde1f
@ -1,5 +1,8 @@
|
||||
2018-10-08 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
PR libstdc++/87538
|
||||
* testsuite/experimental/functional/87538.cc: New test.
|
||||
|
||||
PR libstdc++/87538
|
||||
* include/std/functional (_Not_fn::operator()): Check value of
|
||||
__is_nothrow_invocable as well.
|
||||
|
48
libstdc++-v3/testsuite/experimental/functional/87538.cc
Normal file
48
libstdc++-v3/testsuite/experimental/functional/87538.cc
Normal file
@ -0,0 +1,48 @@
|
||||
// Copyright (C) 2018 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do run { target c++14 } }
|
||||
|
||||
#include <experimental/functional>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
struct N {
|
||||
int operator()(int i) { if (i == 0) throw -1; return i; }
|
||||
};
|
||||
|
||||
void
|
||||
test01()
|
||||
{
|
||||
N n;
|
||||
auto not_n = std::experimental::not_fn(n);
|
||||
static_assert( !noexcept(not_n(1)), "can throw" );
|
||||
VERIFY(not_n(1) == 0);
|
||||
int exception = 0;
|
||||
try {
|
||||
not_n(0);
|
||||
}
|
||||
catch (int e) {
|
||||
exception = e;
|
||||
}
|
||||
VERIFY(exception == -1);
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user