summaryrefslogtreecommitdiffstats
path: root/libcxx
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx')
-rw-r--r--libcxx/include/__functional_03304
-rw-r--r--libcxx/include/functional42
-rw-r--r--libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp2
-rw-r--r--libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp2
-rw-r--r--libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp2
-rw-r--r--libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp2
-rw-r--r--libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp2
-rw-r--r--libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp2
-rw-r--r--libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp2
-rw-r--r--libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp2
-rw-r--r--libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression_03.pass.cpp39
11 files changed, 92 insertions, 309 deletions
diff --git a/libcxx/include/__functional_03 b/libcxx/include/__functional_03
index 13c38d8548d..bf55e23482f 100644
--- a/libcxx/include/__functional_03
+++ b/libcxx/include/__functional_03
@@ -196,39 +196,7 @@ mem_fn(_Rp (_Tp::* __pm)(_A0, _A1, _A2) const volatile)
return __mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) const volatile>(__pm);
}
-// bad_function_call
-
-class _LIBCPP_EXCEPTION_ABI bad_function_call
- : public exception
-{
-};
-
-template<class _Fp> class _LIBCPP_TYPE_VIS_ONLY function; // undefined
-
-namespace __function
-{
-
-template<class _Fp>
-struct __maybe_derive_from_unary_function
-{
-};
-
-template<class _Rp, class _A1>
-struct __maybe_derive_from_unary_function<_Rp(_A1)>
- : public unary_function<_A1, _Rp>
-{
-};
-
-template<class _Fp>
-struct __maybe_derive_from_binary_function
-{
-};
-
-template<class _Rp, class _A1, class _A2>
-struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)>
- : public binary_function<_A1, _A2, _Rp>
-{
-};
+namespace __function {
template<class _Fp> class __base;
@@ -1856,274 +1824,4 @@ void
swap(function<_Fp>& __x, function<_Fp>& __y)
{return __x.swap(__y);}
-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> {};
-
-template<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {};
-template<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_placeholder
- : public __is_placeholder<typename remove_cv<_Tp>::type> {};
-
-namespace placeholders
-{
-
-template <int _Np> struct __ph {};
-
-extern __ph<1> _1;
-extern __ph<2> _2;
-extern __ph<3> _3;
-extern __ph<4> _4;
-extern __ph<5> _5;
-extern __ph<6> _6;
-extern __ph<7> _7;
-extern __ph<8> _8;
-extern __ph<9> _9;
-extern __ph<10> _10;
-
-} // placeholders
-
-template<int _Np>
-struct __is_placeholder<placeholders::__ph<_Np> >
- : public integral_constant<int, _Np> {};
-
-template <class _Tp, class _Uj>
-inline _LIBCPP_INLINE_VISIBILITY
-_Tp&
-__mu(reference_wrapper<_Tp> __t, _Uj&)
-{
- return __t.get();
-}
-/*
-template <bool _IsBindExpr, class _Ti, class ..._Uj>
-struct __mu_return1 {};
-
-template <class _Ti, class ..._Uj>
-struct __mu_return1<true, _Ti, _Uj...>
-{
- typedef typename result_of<_Ti(_Uj...)>::type type;
-};
-
-template <class _Ti, class ..._Uj, size_t ..._Indx>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __mu_return1<true, _Ti, _Uj...>::type
-__mu_expand(_Ti& __ti, tuple<_Uj...>&& __uj, __tuple_indices<_Indx...>)
-{
- __ti(_VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj))...);
-}
-
-template <class _Ti, class ..._Uj>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- is_bind_expression<_Ti>::value,
- typename __mu_return1<is_bind_expression<_Ti>::value, _Ti, _Uj...>::type
->::type
-__mu(_Ti& __ti, tuple<_Uj...>& __uj)
-{
- typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices;
- return __mu_expand(__ti, __uj, __indices());
-}
-
-template <bool IsPh, class _Ti, class _Uj>
-struct __mu_return2 {};
-
-template <class _Ti, class _Uj>
-struct __mu_return2<true, _Ti, _Uj>
-{
- typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type;
-};
-
-template <class _Ti, class _Uj>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- 0 < is_placeholder<_Ti>::value,
- typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type
->::type
-__mu(_Ti&, _Uj& __uj)
-{
- const size_t _Indx = is_placeholder<_Ti>::value - 1;
- // compiler bug workaround
- typename tuple_element<_Indx, _Uj>::type __t = _VSTD::get<_Indx>(__uj);
- return __t;
-// return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj));
-}
-
-template <class _Ti, class _Uj>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- !is_bind_expression<_Ti>::value &&
- is_placeholder<_Ti>::value == 0 &&
- !__is_reference_wrapper<_Ti>::value,
- _Ti&
->::type
-__mu(_Ti& __ti, _Uj& __uj)
-{
- return __ti;
-}
-
-template <class _Ti, bool IsBindEx, bool IsPh, class _TupleUj>
-struct ____mu_return;
-
-template <class _Ti, class ..._Uj>
-struct ____mu_return<_Ti, true, false, tuple<_Uj...> >
-{
- typedef typename result_of<_Ti(_Uj...)>::type type;
-};
-
-template <class _Ti, class _TupleUj>
-struct ____mu_return<_Ti, false, true, _TupleUj>
-{
- typedef typename tuple_element<is_placeholder<_Ti>::value - 1,
- _TupleUj>::type&& type;
-};
-
-template <class _Ti, class _TupleUj>
-struct ____mu_return<_Ti, false, false, _TupleUj>
-{
- typedef _Ti& type;
-};
-
-template <class _Ti, class _TupleUj>
-struct __mu_return
- : public ____mu_return<_Ti,
- is_bind_expression<_Ti>::value,
- 0 < is_placeholder<_Ti>::value,
- _TupleUj>
-{
-};
-
-template <class _Ti, class _TupleUj>
-struct __mu_return<reference_wrapper<_Ti>, _TupleUj>
-{
- typedef _Ti& type;
-};
-
-template <class _Fp, class _BoundArgs, class _TupleUj>
-struct __bind_return;
-
-template <class _Fp, class ..._BoundArgs, class _TupleUj>
-struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj>
-{
- typedef typename __ref_return
- <
- _Fp&,
- typename __mu_return
- <
- _BoundArgs,
- _TupleUj
- >::type...
- >::type type;
-};
-
-template <class _Fp, class ..._BoundArgs, class _TupleUj>
-struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
-{
- typedef typename __ref_return
- <
- _Fp&,
- typename __mu_return
- <
- const _BoundArgs,
- _TupleUj
- >::type...
- >::type type;
-};
-
-template <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __bind_return<_Fp, _BoundArgs, _Args>::type
-__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
- _Args&& __args)
-{
- return __invoke(__f, __mu(_VSTD::get<_Indx>(__bound_args), __args)...);
-}
-
-template<class _Fp, class ..._BoundArgs>
-class __bind
-{
- _Fp __f_;
- tuple<_BoundArgs...> __bound_args_;
-
- typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices;
-public:
- template <class _Gp, class ..._BA>
- explicit __bind(_Gp&& __f, _BA&& ...__bound_args)
- : __f_(_VSTD::forward<_Gp>(__f)),
- __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {}
-
- template <class ..._Args>
- typename __bind_return<_Fp, tuple<_BoundArgs...>, tuple<_Args&&...> >::type
- operator()(_Args&& ...__args)
- {
- // compiler bug workaround
- return __apply_functor(__f_, __bound_args_, __indices(),
- tuple<_Args&&...>(__args...));
- }
-
- template <class ..._Args>
- typename __bind_return<_Fp, tuple<_BoundArgs...>, tuple<_Args&&...> >::type
- operator()(_Args&& ...__args) const
- {
- return __apply_functor(__f_, __bound_args_, __indices(),
- tuple<_Args&&...>(__args...));
- }
-};
-
-template<class _Fp, class ..._BoundArgs>
-struct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {};
-
-template<class _Rp, class _Fp, class ..._BoundArgs>
-class __bind_r
- : public __bind<_Fp, _BoundArgs...>
-{
- typedef __bind<_Fp, _BoundArgs...> base;
-public:
- typedef _Rp result_type;
-
- template <class _Gp, class ..._BA>
- explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args)
- : base(_VSTD::forward<_Gp>(__f),
- _VSTD::forward<_BA>(__bound_args)...) {}
-
- template <class ..._Args>
- result_type
- operator()(_Args&& ...__args)
- {
- typedef __invoke_void_return_wrapper<_Rp> _Invoker;
- return _Invoker::__call(static_cast<base&>(*this), _VSTD::forward<_Args>(__args)...);
- }
-
- template <class ..._Args>
- result_type
- operator()(_Args&& ...__args) const
- {
- typedef __invoke_void_return_wrapper<_Rp> _Invoker;
- return _Invoker::__call(static_cast<base const&>(*this), _VSTD::forward<_Args>(__args)...);
- }
-};
-
-template<class _Rp, class _Fp, class ..._BoundArgs>
-struct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {};
-
-template<class _Fp, class ..._BoundArgs>
-inline _LIBCPP_INLINE_VISIBILITY
-__bind<typename decay<_Fp>::type, typename decay<_BoundArgs>::type...>
-bind(_Fp&& __f, _BoundArgs&&... __bound_args)
-{
- typedef __bind<typename decay<_Fp>::type, typename decay<_BoundArgs>::type...> type;
- return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
-}
-
-template<class _Rp, class _Fp, class ..._BoundArgs>
-inline _LIBCPP_INLINE_VISIBILITY
-__bind_r<_Rp, typename decay<_Fp>::type, typename decay<_BoundArgs>::type...>
-bind(_Fp&& __f, _BoundArgs&&... __bound_args)
-{
- typedef __bind_r<_Rp, typename decay<_Fp>::type, typename decay<_BoundArgs>::type...> type;
- return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
-}
-*/
-
#endif // _LIBCPP_FUNCTIONAL_03
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
diff --git a/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp b/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp
index 6315598125c..ad03e8fb6bb 100644
--- a/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <functional>
// template<CopyConstructible Fn, CopyConstructible... Types>
diff --git a/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp b/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp
index 33bf0185590..4577d0bf4d5 100644
--- a/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <functional>
// template<CopyConstructible Fn, CopyConstructible... Types>
diff --git a/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp b/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp
index ab4dd59534d..815096f6b15 100644
--- a/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <functional>
// template<CopyConstructible Fn, CopyConstructible... Types>
diff --git a/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp b/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp
index af5efe464d5..f69afbf5766 100644
--- a/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <functional>
// template<CopyConstructible Fn, CopyConstructible... Types>
diff --git a/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp b/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp
index 4913a510c36..a1137ee388c 100644
--- a/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <functional>
// template<CopyConstructible Fn, CopyConstructible... Types>
diff --git a/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp b/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp
index b7874b77cf0..73f26e4b585 100644
--- a/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <functional>
// template<CopyConstructible Fn, CopyConstructible... Types>
diff --git a/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp b/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp
index 12720f7b550..f61d93aefd8 100644
--- a/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <functional>
// template<CopyConstructible Fn, CopyConstructible... Types>
diff --git a/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp b/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp
index 7f8dd4a98d2..83fa452fecb 100644
--- a/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <functional>
// template<class T> struct is_bind_expression
diff --git a/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression_03.pass.cpp b/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression_03.pass.cpp
new file mode 100644
index 00000000000..12a78dbc754
--- /dev/null
+++ b/libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression_03.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+//-----------------------------------------------------------------------------
+// TESTING template<class T> struct is_bind_expression
+//
+// bind is not implemented in C++03 so nothing is a bind expression. However
+// for compatibility reasons the trait is_bind_expression should be available
+// in C++03 and it should always return false.
+
+#include <functional>
+
+template <class T>
+void test() {
+ static_assert(!std::is_bind_expression<T>::value, "");
+}
+
+struct C {};
+
+int main() {
+ test<int>();
+ test<void>();
+ test<C>();
+ test<C&>();
+ test<C const&>();
+ test<C*>();
+ test<void()>();
+ test<int(*)()>();
+ test<int (C::*)()>();
+ test<decltype(std::placeholders::_2)>();
+}
OpenPOWER on IntegriCloud