aboutsummaryrefslogtreecommitdiff
path: root/include/functional
diff options
context:
space:
mode:
Diffstat (limited to 'include/functional')
-rw-r--r--include/functional118
1 files changed, 81 insertions, 37 deletions
diff --git a/include/functional b/include/functional
index d14b46bb76af..5ee941763020 100644
--- a/include/functional
+++ b/include/functional
@@ -504,7 +504,9 @@ struct _LIBCPP_TYPE_VIS_ONLY plus<void>
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
- { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
@@ -529,7 +531,9 @@ struct _LIBCPP_TYPE_VIS_ONLY minus<void>
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
- { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
@@ -554,7 +558,9 @@ struct _LIBCPP_TYPE_VIS_ONLY multiplies<void>
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
- { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
@@ -579,7 +585,9 @@ struct _LIBCPP_TYPE_VIS_ONLY divides<void>
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
- { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
@@ -604,7 +612,9 @@ struct _LIBCPP_TYPE_VIS_ONLY modulus<void>
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
- { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
@@ -629,7 +639,9 @@ struct _LIBCPP_TYPE_VIS_ONLY negate<void>
template <class _Tp>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
auto operator()(_Tp&& __x) const
- { return -_VSTD::forward<_Tp>(__x); }
+ _NOEXCEPT_(noexcept(- _VSTD::forward<_Tp>(__x)))
+ -> decltype (- _VSTD::forward<_Tp>(__x))
+ { return - _VSTD::forward<_Tp>(__x); }
typedef void is_transparent;
};
#endif
@@ -654,7 +666,9 @@ struct _LIBCPP_TYPE_VIS_ONLY equal_to<void>
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
- { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); }
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
@@ -679,7 +693,9 @@ struct _LIBCPP_TYPE_VIS_ONLY not_equal_to<void>
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
- { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); }
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
@@ -704,7 +720,9 @@ struct _LIBCPP_TYPE_VIS_ONLY greater<void>
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
- { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); }
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
@@ -731,7 +749,9 @@ struct _LIBCPP_TYPE_VIS_ONLY greater_equal<void>
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
- { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); }
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
@@ -756,7 +776,9 @@ struct _LIBCPP_TYPE_VIS_ONLY less_equal<void>
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
- { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); }
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
@@ -781,7 +803,9 @@ struct _LIBCPP_TYPE_VIS_ONLY logical_and<void>
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
- { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); }
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
@@ -806,7 +830,9 @@ struct _LIBCPP_TYPE_VIS_ONLY logical_or<void>
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
- { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); }
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
@@ -831,7 +857,9 @@ struct _LIBCPP_TYPE_VIS_ONLY logical_not<void>
template <class _Tp>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
auto operator()(_Tp&& __x) const
- { return !_VSTD::forward<_Tp>(__x); }
+ _NOEXCEPT_(noexcept(!_VSTD::forward<_Tp>(__x)))
+ -> decltype (!_VSTD::forward<_Tp>(__x))
+ { return !_VSTD::forward<_Tp>(__x); }
typedef void is_transparent;
};
#endif
@@ -856,7 +884,9 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_and<void>
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
- { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
@@ -881,7 +911,9 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_or<void>
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
- { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
@@ -906,7 +938,9 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_xor<void>
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
- { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); }
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
@@ -927,7 +961,9 @@ struct _LIBCPP_TYPE_VIS_ONLY bit_not<void>
template <class _Tp>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
auto operator()(_Tp&& __x) const
- { return ~_VSTD::forward<_Tp>(__x); }
+ _NOEXCEPT_(noexcept(~_VSTD::forward<_Tp>(__x)))
+ -> decltype (~_VSTD::forward<_Tp>(__x))
+ { return ~_VSTD::forward<_Tp>(__x); }
typedef void is_transparent;
};
#endif
@@ -1331,7 +1367,8 @@ template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
__base<_Rp(_ArgTypes...)>*
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const
{
- typedef typename _Alloc::template rebind<__func>::other _Ap;
+ typedef allocator_traits<_Alloc> __alloc_traits;
+ typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
_Ap __a(__f_.second());
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@@ -1357,7 +1394,8 @@ template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
void
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT
{
- typedef typename _Alloc::template rebind<__func>::other _Ap;
+ typedef allocator_traits<_Alloc> __alloc_traits;
+ typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
_Ap __a(__f_.second());
__f_.~__compressed_pair<_Fp, _Alloc>();
__a.deallocate(this, 1);
@@ -1367,7 +1405,8 @@ template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
_Rp
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg)
{
- return __invoke(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...);
+ typedef __invoke_void_return_wrapper<_Rp> _Invoker;
+ return _Invoker::__call(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...);
}
#ifndef _LIBCPP_NO_RTTI
@@ -1429,7 +1468,7 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_ArgTypes...)>
template <class _Fp>
struct __callable<_Fp, true>
{
- static const bool value =
+ static const bool value = is_same<void, _Rp>::value ||
is_convertible<typename __invoke_of<_Fp&, _ArgTypes...>::type,
_Rp>::value;
};
@@ -1617,13 +1656,7 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp _
if (__not_null(__f))
{
typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF;
- typedef typename __alloc_traits::template
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
- rebind_alloc<_FF>
-#else
- rebind_alloc<_FF>::other
-#endif
- _Ap;
+ typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
_Ap __a(__a0);
if (sizeof(_FF) <= sizeof(__buf_) &&
is_nothrow_copy_constructible<_Fp>::value && is_nothrow_copy_constructible<_Ap>::value)
@@ -1963,27 +1996,27 @@ struct __mu_return
};
template <class _Fp, class _BoundArgs, class _TupleUj>
-struct _is_valid_bind_return
+struct __is_valid_bind_return
{
static const bool value = false;
};
template <class _Fp, class ..._BoundArgs, class _TupleUj>
-struct _is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj>
+struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj>
{
static const bool value = __invokable<_Fp,
typename __mu_return<_BoundArgs, _TupleUj>::type...>::value;
};
template <class _Fp, class ..._BoundArgs, class _TupleUj>
-struct _is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
+struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
{
static const bool value = __invokable<_Fp,
typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value;
};
template <class _Fp, class _BoundArgs, class _TupleUj,
- bool = _is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
+ bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
struct __bind_return;
template <class _Fp, class ..._BoundArgs, class _TupleUj>
@@ -2153,12 +2186,13 @@ public:
typename enable_if
<
is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type,
- result_type>::value,
+ result_type>::value || is_void<_Rp>::value,
result_type
>::type
operator()(_Args&& ...__args)
{
- return base::operator()(_VSTD::forward<_Args>(__args)...);
+ typedef __invoke_void_return_wrapper<_Rp> _Invoker;
+ return _Invoker::__call(static_cast<base&>(*this), _VSTD::forward<_Args>(__args)...);
}
template <class ..._Args>
@@ -2166,12 +2200,13 @@ public:
typename enable_if
<
is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,
- result_type>::value,
+ result_type>::value || is_void<_Rp>::value,
result_type
>::type
operator()(_Args&& ...__args) const
{
- return base::operator()(_VSTD::forward<_Args>(__args)...);
+ typedef __invoke_void_return_wrapper<_Rp> _Invoker;
+ return _Invoker::__call(static_cast<base const&>(*this), _VSTD::forward<_Args>(__args)...);
}
};
@@ -2412,6 +2447,15 @@ struct _LIBCPP_TYPE_VIS_ONLY hash
};
#endif
+
+#if _LIBCPP_STD_VER > 14
+template <class _Fn, class ..._Args>
+result_of_t<_Fn&&(_Args&&...)>
+invoke(_Fn&& __f, _Args&&... __args) {
+ return __invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...);
+}
+#endif
+
// struct hash<T*> in <memory>
_LIBCPP_END_NAMESPACE_STD