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.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242870 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2015-07-22 04:14:38 +00:00
parent 7cc7106776
commit 45f63bc07e
11 changed files with 92 additions and 309 deletions

View File

@@ -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
////////////////////////////////////////////////////////////////////////////////
// MEMFUN
//==============================================================================
#include <__functional_03>
#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