diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2014-04-15 16:25:52 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2014-04-15 16:25:52 +0100 |
commit | 4803acceb2e0e70449ad1b251466a4625f702299 (patch) | |
tree | 08ba9afc60e42d4430bd3418282fa5e572e7c5d0 | |
parent | d00e4baae7c2518ebe24cfc8536b52354096d562 (diff) | |
download | gcc-4803acceb2e0e70449ad1b251466a4625f702299.zip gcc-4803acceb2e0e70449ad1b251466a4625f702299.tar.gz gcc-4803acceb2e0e70449ad1b251466a4625f702299.tar.bz2 |
re PR libstdc++/60594 (std::function of a type with a declared (but not defined) return type fails to compile)
PR libstdc++/60594
* include/std/functional (function::_Callable): Exclude own type
from the callable checks.
* testsuite/20_util/function/60594.cc: New.
From-SVN: r209422
-rw-r--r-- | libstdc++-v3/ChangeLog | 5 | ||||
-rw-r--r-- | libstdc++-v3/include/std/functional | 11 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/20_util/function/60594.cc | 36 |
3 files changed, 50 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index ab757d4..e9b4a7c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -7,6 +7,11 @@ * include/std/atomic (atomic<_Tp>): Add static assertion. * testsuite/29_atomics/atomic/60695.cc: New. + PR libstdc++/60594 + * include/std/functional (function::_Callable): Exclude own type + from the callable checks. + * testsuite/20_util/function/60594.cc: New. + 2014-04-14 Jonathan Wakely <jwakely@redhat.com> * include/bits/stl_vector.h (_Vector_base::_Vector_impl, diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index 5a987d9..0e80fa3 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -2149,8 +2149,15 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) using _Invoke = decltype(__callable_functor(std::declval<_Functor&>()) (std::declval<_ArgTypes>()...) ); + // Used so the return type convertibility checks aren't done when + // performing overload resolution for copy construction/assignment. + template<typename _Tp> + using _NotSelf = __not_<is_same<_Tp, function>>; + template<typename _Functor> - using _Callable = __check_func_return_type<_Invoke<_Functor>, _Res>; + using _Callable + = __and_<_NotSelf<_Functor>, + __check_func_return_type<_Invoke<_Functor>, _Res>>; template<typename _Cond, typename _Tp> using _Requires = typename enable_if<_Cond::value, _Tp>::type; @@ -2291,7 +2298,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) * reference_wrapper<F>, this function will not throw. */ template<typename _Functor> - _Requires<_Callable<_Functor>, function&> + _Requires<_Callable<typename decay<_Functor>::type>, function&> operator=(_Functor&& __f) { function(std::forward<_Functor>(__f)).swap(*this); diff --git a/libstdc++-v3/testsuite/20_util/function/60594.cc b/libstdc++-v3/testsuite/20_util/function/60594.cc new file mode 100644 index 0000000..be80b3f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/60594.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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/>. + +// libstdc++/60594 + +#include <functional> +#include <type_traits> +struct bar; +using F = std::function<bar()>; +// check for copy constructible and assignable while 'bar' is incomplete +constexpr int c = std::is_copy_constructible<F>::value; +constexpr int a = std::is_copy_assignable<F>::value; +struct bar { }; +bar func(); +void test() +{ + F g{ &func }; + g = func; +} |