diff options
author | Eric Fiselier <eric@efcs.ca> | 2015-07-22 04:14:38 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2015-07-22 04:14:38 +0000 |
commit | e5407178d6789ccf462dbb39ad0acc5cbde6581c (patch) | |
tree | 78d1ebdeb16f9920c3c44c03fbedb10cbd138f78 /libcxx/include/functional | |
parent | ccffdaf7edbba53e1a5cc35257e0d4a13accdb89 (diff) | |
download | bcm5719-llvm-e5407178d6789ccf462dbb39ad0acc5cbde6581c.tar.gz bcm5719-llvm-e5407178d6789ccf462dbb39ad0acc5cbde6581c.zip |
Cleanup <__functional_03>
<__functional_03> provides the C++03 definitions for std::memfun and
std::function. However the interaction between <functional> and <__functional_03>
is ugly and duplicates code needlessly. This patch cleans up how the two
headers work together.
The major changes are:
- Provide placeholders, is_bind_expression and is_placeholder in <functional>
for both C++03 and C++11.
- Provide bad_function_call, function fwd decl,
__maybe_derive_from_unary_function and __maybe_derive_from_binary_function
in <functional> for both C++03 and C++11.
- Move the <__functional_03> include to the bottom of <functional>. This makes
it easier to see how <__functional_03> interacts with <functional>
- Remove a commented out implementation of bind in C++03. It's never going
to get implemented.
- Mark almost all std::bind tests as unsupported in C++03. std::is_placeholder
works in C++03 and C++11. std::is_bind_expression is provided in C++03 but
always returns false.
llvm-svn: 242870
Diffstat (limited to 'libcxx/include/functional')
-rw-r--r-- | libcxx/include/functional | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/libcxx/include/functional b/libcxx/include/functional index 9bed783153e..2c4a96ed2ba 100644 --- a/libcxx/include/functional +++ b/libcxx/include/functional @@ -1234,11 +1234,11 @@ const_mem_fun1_ref_t<_Sp,_Tp,_Ap> mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const) {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} -#ifdef _LIBCPP_HAS_NO_VARIADICS - -#include <__functional_03> +//////////////////////////////////////////////////////////////////////////////// +// MEMFUN +//============================================================================== -#else // _LIBCPP_HAS_NO_VARIADICS +#ifndef _LIBCPP_HAS_NO_VARIADICS template <class _Tp> class __mem_fn @@ -1271,6 +1271,12 @@ mem_fn(_Rp _Tp::* __pm) return __mem_fn<_Rp _Tp::*>(__pm); } +#endif // _LIBCPP_HAS_NO_VARIADICS + +//////////////////////////////////////////////////////////////////////////////// +// FUNCTION +//============================================================================== + // bad_function_call class _LIBCPP_EXCEPTION_ABI bad_function_call @@ -1283,7 +1289,7 @@ template<class _Fp> class _LIBCPP_TYPE_VIS_ONLY function; // undefined namespace __function { -template<class _Rp, class ..._ArgTypes> +template<class _Rp> struct __maybe_derive_from_unary_function { }; @@ -1294,7 +1300,7 @@ struct __maybe_derive_from_unary_function<_Rp(_A1)> { }; -template<class _Rp, class ..._ArgTypes> +template<class _Rp> struct __maybe_derive_from_binary_function { }; @@ -1305,6 +1311,12 @@ struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)> { }; +} // namespace __function + +#ifndef _LIBCPP_HAS_NO_VARIADICS + +namespace __function { + template<class _Fp> class __base; template<class _Rp, class ..._ArgTypes> @@ -1848,6 +1860,12 @@ void swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT {return __x.swap(__y);} +#endif // _LIBCPP_HAS_NO_VARIADICS + +//////////////////////////////////////////////////////////////////////////////// +// BIND +//============================================================================== + template<class _Tp> struct __is_bind_expression : public false_type {}; template<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_bind_expression : public __is_bind_expression<typename remove_cv<_Tp>::type> {}; @@ -1878,6 +1896,9 @@ template<int _Np> struct __is_placeholder<placeholders::__ph<_Np> > : public integral_constant<int, _Np> {}; + +#ifndef _LIBCPP_HAS_NO_VARIADICS + template <class _Tp, class _Uj> inline _LIBCPP_INLINE_VISIBILITY _Tp& @@ -2458,6 +2479,15 @@ invoke(_Fn&& __f, _Args&&... __args) { // struct hash<T*> in <memory> + +//////////////////////////////////////////////////////////////////////////////// +// FUNCTIONAL 03 +//============================================================================== + +#ifdef _LIBCPP_HAS_NO_VARIADICS +#include <__functional_03> +#endif + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_FUNCTIONAL |