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
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: e5407178d6789ccf462dbb39ad0acc5cbde6581c
diff --git a/include/functional b/include/functional
index 9bed783..2c4a96e 100644
--- a/include/functional
+++ b/include/functional
@@ -1234,11 +1234,11 @@
 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 @@
     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 @@
 namespace __function
 {
 
-template<class _Rp, class ..._ArgTypes>
+template<class _Rp>
 struct __maybe_derive_from_unary_function
 {
 };
@@ -1294,7 +1300,7 @@
 {
 };
 
-template<class _Rp, class ..._ArgTypes>
+template<class _Rp>
 struct __maybe_derive_from_binary_function
 {
 };
@@ -1305,6 +1311,12 @@
 {
 };
 
+} // namespace __function
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+namespace __function {
+
 template<class _Fp> class __base;
 
 template<class _Rp, class ..._ArgTypes>
@@ -1848,6 +1860,12 @@
 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 @@
 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 @@
 
 // struct hash<T*> in <memory>
 
+
+////////////////////////////////////////////////////////////////////////////////
+//                            FUNCTIONAL 03
+//==============================================================================
+
+#ifdef _LIBCPP_HAS_NO_VARIADICS
+#include <__functional_03>
+#endif
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_FUNCTIONAL