: __is_location_invariant<_Tp>
{ };
- // Converts a reference to a function object into a callable
- // function object.
- template<typename _Functor>
- inline _Functor&
- __callable_functor(_Functor& __f)
- { return __f; }
-
- template<typename _Member, typename _Class>
- inline _Mem_fn<_Member _Class::*>
- __callable_functor(_Member _Class::* &__p)
- { return std::mem_fn(__p); }
-
- template<typename _Member, typename _Class>
- inline _Mem_fn<_Member _Class::*>
- __callable_functor(_Member _Class::* const &__p)
- { return std::mem_fn(__p); }
-
- template<typename _Member, typename _Class>
- inline _Mem_fn<_Member _Class::*>
- __callable_functor(_Member _Class::* volatile &__p)
- { return std::mem_fn(__p); }
-
- template<typename _Member, typename _Class>
- inline _Mem_fn<_Member _Class::*>
- __callable_functor(_Member _Class::* const volatile &__p)
- { return std::mem_fn(__p); }
-
template<typename _Signature>
class function;
static _Res
_M_invoke(const _Any_data& __functor, _ArgTypes&&... __args)
{
- return std::__callable_functor(**_Base::_M_get_pointer(__functor))(
- std::forward<_ArgTypes>(__args)...);
+ return std::__invoke(**_Base::_M_get_pointer(__functor),
+ std::forward<_ArgTypes>(__args)...);
}
};
static void
_M_invoke(const _Any_data& __functor, _ArgTypes&&... __args)
{
- std::__callable_functor(**_Base::_M_get_pointer(__functor))(
- std::forward<_ArgTypes>(__args)...);
+ std::__invoke(**_Base::_M_get_pointer(__functor),
+ std::forward<_ArgTypes>(__args)...);
}
};
static _Res
_M_invoke(const _Any_data& __functor, _ArgTypes&&... __args)
{
- return std::mem_fn(_Base::_M_get_pointer(__functor)->__value)(
- std::forward<_ArgTypes>(__args)...);
+ return std::__invoke(_Base::_M_get_pointer(__functor)->__value,
+ std::forward<_ArgTypes>(__args)...);
}
};
static void
_M_invoke(const _Any_data& __functor, _ArgTypes&&... __args)
{
- std::mem_fn(_Base::_M_get_pointer(__functor)->__value)(
- std::forward<_ArgTypes>(__args)...);
+ std::__invoke(_Base::_M_get_pointer(__functor)->__value,
+ std::forward<_ArgTypes>(__args)...);
}
};
typedef _Res _Signature_type(_ArgTypes...);
template<typename _Func,
- typename _Res2 = typename result_of<_Func(_ArgTypes...)>::type>
+ typename _Res2 = typename result_of<_Func&(_ArgTypes...)>::type>
struct _Callable : __check_func_return_type<_Res2, _Res> { };
// Used so the return type convertibility checks aren't done when
__x.swap(*this);
}
- // TODO: needs allocator_arg_t
-
/**
* @brief Builds a %function that targets a copy of the incoming
* function object.
std::swap(_M_invoker, __x._M_invoker);
}
- // TODO: needs allocator_arg_t
- /*
- template<typename _Functor, typename _Alloc>
- void
- assign(_Functor&& __f, const _Alloc& __a)
- {
- function(allocator_arg, __a,
- std::forward<_Functor>(__f)).swap(*this);
- }
- */
-
// [3.7.2.3] function capacity
/**
--- /dev/null
+// Copyright (C) 2016 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-do compile { target c++11 } }
+
+#include <functional>
+
+struct F {
+ void operator()() && { }
+ int operator()() & { return 0; }
+};
+
+int main() {
+ F f;
+ std::function<int()> ff{f};
+ return ff();
+}