diff options
author | Joey Ye <joey.ye@arm.com> | 2019-10-25 08:50:08 +0000 |
---|---|---|
committer | Joey Ye <joey.ye@arm.com> | 2019-10-25 08:50:08 +0000 |
commit | ba3b46f8b8bd573be85661d2c51c494611a49114 (patch) | |
tree | 3f3cb93cc306405a492c1ce8f5cb1adca5173e89 /libstdc++-v3/testsuite/20_util/function_objects/invoke/3.cc | |
parent | 06b962b09cc4dadfb62a02be9fedd44f5052e5d6 (diff) | |
parent | 384826fb0df1448f1e413a8bfc77dfce48dafe7b (diff) |
merge with gcc-9-branch@277432ARM/arm-9-branch
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/ARM/arm-9-branch@277439 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/20_util/function_objects/invoke/3.cc')
-rw-r--r-- | libstdc++-v3/testsuite/20_util/function_objects/invoke/3.cc | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/20_util/function_objects/invoke/3.cc b/libstdc++-v3/testsuite/20_util/function_objects/invoke/3.cc new file mode 100644 index 00000000000..74999eca0c3 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function_objects/invoke/3.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2016-2019 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-options "-std=gnu++17" } +// { dg-do compile { target c++17 } } + +#include <functional> + +struct abstract { + virtual ~abstract() = 0; + void operator()() noexcept; +}; + +static_assert( noexcept(std::__invoke(std::declval<abstract>())), + "It should be possible to use abstract types with INVOKE" ); +static_assert( noexcept(std::invoke(std::declval<abstract>())), + "It should be possible to use abstract types with INVOKE" ); + +struct F { + void operator()() &; + void operator()() && noexcept; + int operator()(int); + double* operator()(int, int) noexcept; +}; +struct D { D(void*); }; + +static_assert( !noexcept(std::__invoke(std::declval<F&>())), "" ); +static_assert( noexcept(std::__invoke(std::declval<F>())), "" ); +static_assert( !noexcept(std::__invoke(std::declval<F>(), 1)), "" ); +static_assert( noexcept(std::__invoke(std::declval<F>(), 1, 2)), "" ); + +static_assert( !noexcept(std::invoke(std::declval<F&>())), "" ); +static_assert( noexcept(std::invoke(std::declval<F>())), "" ); +static_assert( !noexcept(std::invoke(std::declval<F>(), 1)), "" ); +static_assert( noexcept(std::invoke(std::declval<F>(), 1, 2)), "" ); |