From 44d209d7e2652a5a3a1eb8ee24d65edcebf13e7e Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 2 Oct 2013 20:21:52 +0000 Subject: [PATCH] re PR libstdc++/58569 (Compilation error when a class contains multiple std::function) 2013-10-02 Jonathan Wakely Daniel Krugler PR libstdc++/58569 * include/std/functional (function::_CheckResult): Move to namespace scope and rename to __check_func_return_type. * testsuite/20_util/function/58569.cc: New. Co-Authored-By: Daniel Kruegler From-SVN: r203132 --- libstdc++-v3/ChangeLog | 8 +++++ libstdc++-v3/include/std/functional | 14 ++++----- .../testsuite/20_util/function/58569.cc | 29 +++++++++++++++++++ 3 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 libstdc++-v3/testsuite/20_util/function/58569.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 3041e8738f3..c17ca807fac 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2013-10-02 Jonathan Wakely + Daniel Krugler + + PR libstdc++/58569 + * include/std/functional (function::_CheckResult): Move to namespace + scope and rename to __check_func_return_type. + * testsuite/20_util/function/58569.cc: New. + 2013-10-02 Jonathan Wakely PR libstdc++/58594 diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index 73cddfe0f7a..eaa4509a420 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -2128,6 +2128,10 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) } }; + template + using __check_func_return_type + = __or_, is_convertible<_From, _To>>; + /** * @brief Primary class template for std::function. * @ingroup functors @@ -2145,16 +2149,8 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) using _Invoke = decltype(__callable_functor(std::declval<_Functor&>()) (std::declval<_ArgTypes>()...) ); - template - struct _CheckResult - : is_convertible<_CallRes, _Res1> { }; - - template - struct _CheckResult<_CallRes, void> - : true_type { }; - template - using _Callable = _CheckResult<_Invoke<_Functor>, _Res>; + using _Callable = __check_func_return_type<_Invoke<_Functor>, _Res>; template using _Requires = typename enable_if<_Cond::value, _Tp>::type; diff --git a/libstdc++-v3/testsuite/20_util/function/58569.cc b/libstdc++-v3/testsuite/20_util/function/58569.cc new file mode 100644 index 00000000000..f1e67bc5ab9 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/58569.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } +// Copyright (C) 2013 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 +// . + +// libstdc++/58569 + +#include + +struct foo { + std::function x; + std::function y; +}; + +foo a;