Commit 28d5436f by Jonathan Wakely Committed by Jonathan Wakely

functional (mem_fn): Qualify to prevent ADL.

	* include/std/functional (mem_fn): Qualify to prevent ADL.
	* testsuite/20_util/function_objects/mem_fn/adl.cc: New.

From-SVN: r185895
parent 8c6d71c0
2012-03-27 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/std/functional (mem_fn): Qualify to prevent ADL.
* testsuite/20_util/function_objects/mem_fn/adl.cc: New.
2012-03-27 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/std/type_traits (result_of): Fix handling of cv-quals.
* testsuite/20_util/result_of/1.cc: New.
* testsuite/20_util/result_of/2.cc: New.
......
// <functional> -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
// 2011 Free Software Foundation, Inc.
// 2011, 2012 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
......@@ -245,7 +245,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
>::type
__invoke(_Functor& __f, _Args&&... __args)
{
return mem_fn(__f)(std::forward<_Args>(__args)...);
return std::mem_fn(__f)(std::forward<_Args>(__args)...);
}
// To pick up function references (that will become function pointers)
......@@ -1709,12 +1709,12 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
template<typename _Member, typename _Class>
inline _Mem_fn<_Member _Class::*>
__callable_functor(_Member _Class::* &__p)
{ return mem_fn(__p); }
{ return std::mem_fn(__p); }
template<typename _Member, typename _Class>
inline _Mem_fn<_Member _Class::*>
__callable_functor(_Member _Class::* const &__p)
{ return mem_fn(__p); }
{ return std::mem_fn(__p); }
template<typename _Signature>
class function;
......@@ -1970,7 +1970,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
static _Res
_M_invoke(const _Any_data& __functor, _ArgTypes... __args)
{
return mem_fn(_Base::_M_get_pointer(__functor)->__value)(
return std::mem_fn(_Base::_M_get_pointer(__functor)->__value)(
std::forward<_ArgTypes>(__args)...);
}
};
......@@ -2010,7 +2010,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
static void
_M_invoke(const _Any_data& __functor, _ArgTypes... __args)
{
mem_fn(_Base::_M_get_pointer(__functor)->__value)(
std::mem_fn(_Base::_M_get_pointer(__functor)->__value)(
std::forward<_ArgTypes>(__args)...);
}
};
......
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// Copyright (C) 2012 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/>.
#include <functional>
namespace n {
struct X { int i; };
void mem_fn(int X::*);
}
using n::X;
X x{};
int X::* p = &X::i;
int test01()
{
auto ref = std::ref(p);
return ref(x);
}
int test02()
{
std::function<int(X)> fun(p);
return fun(x);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment