diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 937e20517a5..a02b401aa90 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +2017-12-12 Jonathan Wakely + + PR libstdc++/83395 + * include/std/type_traits (__is_invocable_impl): Remove partial + specialization for INVOKE and restore is_void check in + primary template. + (__is_nt_invocable_impl): Likewise. + * testsuite/20_util/is_invocable/83395.cc: New test. + * testsuite/20_util/is_nothrow_invocable/83395.cc: New test. + 2017-12-01 Jonathan Wakely Backport from mainline diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 096429dc058..baacfb006dd 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -2755,12 +2755,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct __is_invocable_impl<_Result, _Ret, __void_t> - : is_convertible::type - { }; - - template - struct __is_invocable_impl<_Result, void, __void_t> - : true_type + : __or_, is_convertible>::type { }; template @@ -2865,14 +2860,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct __is_nt_invocable_impl<_Result, _Ret, __void_t> - : __and_, - is_nothrow_constructible<_Ret, typename _Result::type>> - { }; - - template - struct __is_nt_invocable_impl<_Result, void, - __void_t> - : true_type + : __or_, + __and_, + is_nothrow_constructible<_Ret, typename _Result::type>>> { }; /// std::is_nothrow_invocable_r diff --git a/libstdc++-v3/testsuite/20_util/is_invocable/83395.cc b/libstdc++-v3/testsuite/20_util/is_invocable/83395.cc new file mode 100644 index 00000000000..53020255819 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_invocable/83395.cc @@ -0,0 +1,28 @@ +// Copyright (C) 2017 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 +// . + +// { dg-options "-std=gnu++17" } +// { dg-do compile { target c++1z } } + +#include + +// PR libstdc++/83395 +using F = int(*)(); +static_assert(std::is_invocable_r::value); +static_assert(std::is_invocable_r::value); +static_assert(std::is_invocable_r::value); +static_assert(std::is_invocable_r::value); diff --git a/libstdc++-v3/testsuite/20_util/is_nothrow_invocable/83395.cc b/libstdc++-v3/testsuite/20_util/is_nothrow_invocable/83395.cc new file mode 100644 index 00000000000..0051a5489f2 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_nothrow_invocable/83395.cc @@ -0,0 +1,28 @@ +// Copyright (C) 2017 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 +// . + +// { dg-options "-std=gnu++17" } +// { dg-do compile { target c++1z } } + +#include + +// PR libstdc++/83395 +using F = int(*)() noexcept; +static_assert(std::is_nothrow_invocable_r::value); +static_assert(std::is_nothrow_invocable_r::value); +static_assert(std::is_nothrow_invocable_r::value); +static_assert(std::is_nothrow_invocable_r::value);