Make rvalue metaprogramming traits work in C++03.
The next step is to get move and forward working in C++03. llvm-svn: 364053
This commit is contained in:
parent
fa1c7d9bdf
commit
87cf92d9cb
|
@ -808,15 +808,11 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : pub
|
||||||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};
|
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};
|
||||||
|
|
||||||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {};
|
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {};
|
||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
|
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
|
||||||
#endif
|
|
||||||
|
|
||||||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {};
|
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {};
|
||||||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {};
|
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {};
|
||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {};
|
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {};
|
||||||
#endif
|
|
||||||
|
|
||||||
#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
|
#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
|
||||||
template <class _Tp>
|
template <class _Tp>
|
||||||
|
@ -1130,9 +1126,7 @@ template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
|
||||||
|
|
||||||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
|
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
|
||||||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
|
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
|
||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
|
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
|
||||||
#endif
|
|
||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
|
template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
|
||||||
|
@ -1150,8 +1144,6 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference
|
||||||
template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
|
template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
|
|
||||||
template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _LIBCPP_NODEBUG_TYPE _Tp type; };
|
template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _LIBCPP_NODEBUG_TYPE _Tp type; };
|
||||||
template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG_TYPE _Tp&& type; };
|
template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG_TYPE _Tp&& type; };
|
||||||
|
|
||||||
|
@ -1162,10 +1154,6 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference
|
||||||
template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
|
template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
|
|
||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
|
|
||||||
template <class _Tp> _Tp&& __declval(int);
|
template <class _Tp> _Tp&& __declval(int);
|
||||||
template <class _Tp> _Tp __declval(long);
|
template <class _Tp> _Tp __declval(long);
|
||||||
|
|
||||||
|
@ -1173,14 +1161,6 @@ template <class _Tp>
|
||||||
decltype(_VSTD::__declval<_Tp>(0))
|
decltype(_VSTD::__declval<_Tp>(0))
|
||||||
declval() _NOEXCEPT;
|
declval() _NOEXCEPT;
|
||||||
|
|
||||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
|
|
||||||
template <class _Tp>
|
|
||||||
typename add_lvalue_reference<_Tp>::type
|
|
||||||
declval();
|
|
||||||
|
|
||||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
|
|
||||||
// __uncvref
|
// __uncvref
|
||||||
|
|
||||||
template <class _Tp>
|
template <class _Tp>
|
||||||
|
|
|
@ -58,23 +58,19 @@ int main(int, char**)
|
||||||
// LWG 2101 specifically talks about add_lvalue_reference and functions.
|
// LWG 2101 specifically talks about add_lvalue_reference and functions.
|
||||||
// The term of art is "a referenceable type", which a cv- or ref-qualified function is not.
|
// The term of art is "a referenceable type", which a cv- or ref-qualified function is not.
|
||||||
test_function0<void()>();
|
test_function0<void()>();
|
||||||
#if TEST_STD_VER >= 11
|
|
||||||
test_function1<void() const>();
|
test_function1<void() const>();
|
||||||
test_function1<void() &>();
|
test_function1<void() &>();
|
||||||
test_function1<void() &&>();
|
test_function1<void() &&>();
|
||||||
test_function1<void() const &>();
|
test_function1<void() const &>();
|
||||||
test_function1<void() const &&>();
|
test_function1<void() const &&>();
|
||||||
#endif
|
|
||||||
|
|
||||||
// But a cv- or ref-qualified member function *is* "a referenceable type"
|
// But a cv- or ref-qualified member function *is* "a referenceable type"
|
||||||
test_function0<void (Foo::*)()>();
|
test_function0<void (Foo::*)()>();
|
||||||
#if TEST_STD_VER >= 11
|
|
||||||
test_function0<void (Foo::*)() const>();
|
test_function0<void (Foo::*)() const>();
|
||||||
test_function0<void (Foo::*)() &>();
|
test_function0<void (Foo::*)() &>();
|
||||||
test_function0<void (Foo::*)() &&>();
|
test_function0<void (Foo::*)() &&>();
|
||||||
test_function0<void (Foo::*)() const &>();
|
test_function0<void (Foo::*)() const &>();
|
||||||
test_function0<void (Foo::*)() const &&>();
|
test_function0<void (Foo::*)() const &&>();
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
// UNSUPPORTED: c++98, c++03
|
|
||||||
|
|
||||||
// type_traits
|
// type_traits
|
||||||
|
|
||||||
// add_rvalue_reference
|
// add_rvalue_reference
|
||||||
|
|
|
@ -36,13 +36,11 @@ int main(int, char**)
|
||||||
test_remove_reference<int*&, int*>();
|
test_remove_reference<int*&, int*>();
|
||||||
test_remove_reference<const int*&, const int*>();
|
test_remove_reference<const int*&, const int*>();
|
||||||
|
|
||||||
#if TEST_STD_VER >= 11
|
|
||||||
test_remove_reference<int&&, int>();
|
test_remove_reference<int&&, int>();
|
||||||
test_remove_reference<const int&&, const int>();
|
test_remove_reference<const int&&, const int>();
|
||||||
test_remove_reference<int(&&)[3], int[3]>();
|
test_remove_reference<int(&&)[3], int[3]>();
|
||||||
test_remove_reference<int*&&, int*>();
|
test_remove_reference<int*&&, int*>();
|
||||||
test_remove_reference<const int*&&, const int*>();
|
test_remove_reference<const int*&&, const int*>();
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,6 @@
|
||||||
|
|
||||||
// is_lvalue_reference
|
// is_lvalue_reference
|
||||||
|
|
||||||
// UNSUPPORTED: c++98, c++03
|
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <cstddef> // for std::nullptr_t
|
#include <cstddef> // for std::nullptr_t
|
||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
|
|
|
@ -10,8 +10,6 @@
|
||||||
|
|
||||||
// is_rvalue_reference
|
// is_rvalue_reference
|
||||||
|
|
||||||
// UNSUPPORTED: c++98, c++03
|
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <cstddef> // for std::nullptr_t
|
#include <cstddef> // for std::nullptr_t
|
||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
// UNSUPPORTED: c++98, c++03
|
|
||||||
|
|
||||||
// type_traits
|
// type_traits
|
||||||
|
|
||||||
// rvalue_ref
|
// rvalue_ref
|
||||||
|
|
|
@ -75,10 +75,7 @@ typedef void (*FunctionPtr)();
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
test_is_reference<int&>();
|
test_is_reference<int&>();
|
||||||
#if TEST_STD_VER >= 11
|
|
||||||
test_is_reference<int&&>();
|
test_is_reference<int&&>();
|
||||||
#endif
|
|
||||||
|
|
||||||
test_is_not_reference<std::nullptr_t>();
|
test_is_not_reference<std::nullptr_t>();
|
||||||
test_is_not_reference<void>();
|
test_is_not_reference<void>();
|
||||||
test_is_not_reference<int>();
|
test_is_not_reference<int>();
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
// UNSUPPORTED: c++98, c++03
|
|
||||||
|
|
||||||
// type_traits
|
// type_traits
|
||||||
|
|
||||||
// rvalue_ref
|
// rvalue_ref
|
||||||
|
|
|
@ -23,11 +23,7 @@ class A
|
||||||
|
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
#if TEST_STD_VER >= 11
|
|
||||||
static_assert((std::is_same<decltype(std::declval<A>()), A&&>::value), "");
|
static_assert((std::is_same<decltype(std::declval<A>()), A&&>::value), "");
|
||||||
#else
|
|
||||||
static_assert((std::is_same<decltype(std::declval<A>()), A&>::value), "");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue