Commit 57c4fbc6 by Jonathan Wakely Committed by Jonathan Wakely

Simplify reference_wrapper nested typedefs

	* include/std/functional (_Reference_wrapper_base_impl): Remove.
	(_Refwrap_base_arg1, _Refwrap_base_arg2): New helpers using __void_t.
	(_Reference_wrapper_base): Inherit from new helpers.

From-SVN: r241151
parent 6fd9c6f4
2016-10-14 Jonathan Wakely <jwakely@redhat.com>
* include/std/functional (_Reference_wrapper_base_impl): Remove.
(_Refwrap_base_arg1, _Refwrap_base_arg2): New helpers using __void_t.
(_Reference_wrapper_base): Inherit from new helpers.
2016-10-13 Paolo Carlini <paolo.carlini@oracle.com> 2016-10-13 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/24_iterators/container_access.cc: Remove 'test' variables. * testsuite/24_iterators/container_access.cc: Remove 'test' variables.
......
...@@ -207,51 +207,34 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -207,51 +207,34 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
#endif #endif
/** // Detect nested argument_type.
* Knowing which of unary_function and binary_function _Tp derives template<typename _Tp, typename = __void_t<>>
* from, derives from the same and ensures that reference_wrapper struct _Refwrap_base_arg1
* will have a weak result type. See cases below.
*/
template<bool _Unary, bool _Binary, typename _Tp>
struct _Reference_wrapper_base_impl;
// None of the nested argument types.
template<typename _Tp>
struct _Reference_wrapper_base_impl<false, false, _Tp>
: _Weak_result_type<_Tp>
{ }; { };
// Nested argument_type only. // Nested argument_type.
template<typename _Tp> template<typename _Tp>
struct _Reference_wrapper_base_impl<true, false, _Tp> struct _Refwrap_base_arg1<_Tp,
: _Weak_result_type<_Tp> __void_t<typename _Tp::argument_type>>
{ {
typedef typename _Tp::argument_type argument_type; typedef typename _Tp::argument_type argument_type;
}; };
// Nested first_argument_type and second_argument_type only. // Detect nested first_argument_type and second_argument_type.
template<typename _Tp> template<typename _Tp, typename = __void_t<>>
struct _Reference_wrapper_base_impl<false, true, _Tp> struct _Refwrap_base_arg2
: _Weak_result_type<_Tp> { };
{
typedef typename _Tp::first_argument_type first_argument_type;
typedef typename _Tp::second_argument_type second_argument_type;
};
// All the nested argument types. // Nested first_argument_type and second_argument_type.
template<typename _Tp> template<typename _Tp>
struct _Reference_wrapper_base_impl<true, true, _Tp> struct _Refwrap_base_arg2<_Tp,
: _Weak_result_type<_Tp> __void_t<typename _Tp::first_argument_type,
typename _Tp::second_argument_type>>
{ {
typedef typename _Tp::argument_type argument_type;
typedef typename _Tp::first_argument_type first_argument_type; typedef typename _Tp::first_argument_type first_argument_type;
typedef typename _Tp::second_argument_type second_argument_type; typedef typename _Tp::second_argument_type second_argument_type;
}; };
_GLIBCXX_HAS_NESTED_TYPE(argument_type)
_GLIBCXX_HAS_NESTED_TYPE(first_argument_type)
_GLIBCXX_HAS_NESTED_TYPE(second_argument_type)
/** /**
* Derives from unary_function or binary_function when it * Derives from unary_function or binary_function when it
* can. Specializations handle all of the easy cases. The primary * can. Specializations handle all of the easy cases. The primary
...@@ -260,11 +243,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -260,11 +243,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/ */
template<typename _Tp> template<typename _Tp>
struct _Reference_wrapper_base struct _Reference_wrapper_base
: _Reference_wrapper_base_impl< : _Weak_result_type<_Tp>, _Refwrap_base_arg1<_Tp>, _Refwrap_base_arg2<_Tp>
__has_argument_type<_Tp>::value,
__has_first_argument_type<_Tp>::value
&& __has_second_argument_type<_Tp>::value,
_Tp>
{ }; { };
// - a function type (unary) // - a function type (unary)
......
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