Implement LWG#2101 'Some transformation types can produce impossible types' Introduced a new (internal) type trait '__is_referenceable' with tests. Use that trait in add_lvalue_reference, add_rvalue_reference and add_pointer.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@258418 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -957,6 +957,38 @@ template <class _Tp> _LIBCPP_CONSTEXPR bool is_compound_v
|
||||
= is_compound<_Tp>::value;
|
||||
#endif
|
||||
|
||||
|
||||
// __is_referenceable [defns.referenceable]
|
||||
template <class _Tp> struct __is_referenceable
|
||||
: public std::integral_constant<bool, is_object<_Tp>::value || is_reference<_Tp>::value> {};
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
template <class _Ret, class... _Args>
|
||||
struct __is_referenceable<_Ret(_Args...)> : public std::true_type {};
|
||||
|
||||
template <class _Ret, class... _Args>
|
||||
struct __is_referenceable<_Ret(_Args..., ...)> : public std::true_type {};
|
||||
#else
|
||||
template <class _Ret>
|
||||
struct __is_referenceable<_Ret()> : public std::true_type {};
|
||||
template <class _Ret, class _A0>
|
||||
struct __is_referenceable<_Ret(_A0)> : public std::true_type {};
|
||||
template <class _Ret, class _A0, class _A1>
|
||||
struct __is_referenceable<_Ret(_A0, _A1)> : public std::true_type {};
|
||||
template <class _Ret, class _A0, class _A1, class _A2>
|
||||
struct __is_referenceable<_Ret(_A0, _A1, _A2)> : public std::true_type {};
|
||||
|
||||
template <class _Ret>
|
||||
struct __is_referenceable<_Ret(...)> : public std::true_type {};
|
||||
template <class _Ret, class _A0>
|
||||
struct __is_referenceable<_Ret(_A0, ...)> : public std::true_type {};
|
||||
template <class _Ret, class _A0, class _A1>
|
||||
struct __is_referenceable<_Ret(_A0, _A1, ...)> : public std::true_type {};
|
||||
template <class _Ret, class _A0, class _A1, class _A2>
|
||||
struct __is_referenceable<_Ret(_A0, _A1, _A2, ...)> : public std::true_type {};
|
||||
#endif
|
||||
|
||||
|
||||
// add_const
|
||||
|
||||
template <class _Tp, bool = is_reference<_Tp>::value ||
|
||||
@@ -1014,12 +1046,11 @@ template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::
|
||||
|
||||
// add_lvalue_reference
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef _Tp& type;};
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<_Tp&> {typedef _Tp& type;}; // for older compiler
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<void> {typedef void type;};
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const void> {typedef const void type;};
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<volatile void> {typedef volatile void type;};
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const volatile void> {typedef const volatile void type;};
|
||||
template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _Tp type; };
|
||||
template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _Tp& type; };
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference
|
||||
{typedef typename __add_lvalue_reference_impl<_Tp>::type type;};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
|
||||
@@ -1027,11 +1058,11 @@ template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_referenc
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef _Tp&& type;};
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<void> {typedef void type;};
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const void> {typedef const void type;};
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<volatile void> {typedef volatile void type;};
|
||||
template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const volatile void> {typedef const volatile void type;};
|
||||
template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _Tp type; };
|
||||
template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _Tp&& type; };
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference
|
||||
{typedef typename __add_rvalue_reference_impl<_Tp>::type type;};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
|
||||
@@ -1072,8 +1103,16 @@ template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type
|
||||
|
||||
// add_pointer
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_pointer
|
||||
template <class _Tp,
|
||||
bool = __is_referenceable<_Tp>::value ||
|
||||
is_same<typename remove_cv<_Tp>::type, void>::value>
|
||||
struct __add_pointer_impl
|
||||
{typedef typename remove_reference<_Tp>::type* type;};
|
||||
template <class _Tp> struct __add_pointer_impl<_Tp, false>
|
||||
{typedef _Tp type;};
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_pointer
|
||||
{typedef typename __add_pointer_impl<_Tp>::type type;};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
|
||||
|
||||
153
test/libcxx/utilities/meta/is_referenceable.pass.cpp
Normal file
153
test/libcxx/utilities/meta/is_referenceable.pass.cpp
Normal file
@@ -0,0 +1,153 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
|
||||
// __is_referenceable<Tp>
|
||||
//
|
||||
// [defns.referenceable] defines "a referenceable type" as:
|
||||
// An object type, a function type that does not have cv-qualifiers
|
||||
// or a ref-qualifier, or a reference type.
|
||||
//
|
||||
|
||||
#include <type_traits>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
struct Foo {};
|
||||
|
||||
static_assert((!std::__is_referenceable<void>::value), "");
|
||||
static_assert(( std::__is_referenceable<int>::value), "");
|
||||
static_assert(( std::__is_referenceable<int[3]>::value), "");
|
||||
static_assert(( std::__is_referenceable<int &>::value), "");
|
||||
static_assert(( std::__is_referenceable<const int &>::value), "");
|
||||
static_assert(( std::__is_referenceable<int *>::value), "");
|
||||
static_assert(( std::__is_referenceable<const int *>::value), "");
|
||||
static_assert(( std::__is_referenceable<Foo>::value), "");
|
||||
static_assert(( std::__is_referenceable<const Foo>::value), "");
|
||||
static_assert(( std::__is_referenceable<Foo &>::value), "");
|
||||
static_assert(( std::__is_referenceable<const Foo &>::value), "");
|
||||
static_assert(( std::__is_referenceable<Foo &&>::value), "");
|
||||
static_assert(( std::__is_referenceable<const Foo &&>::value), "");
|
||||
|
||||
// Functions without cv-qualifiers are referenceable
|
||||
static_assert(( std::__is_referenceable<void ()>::value), "");
|
||||
static_assert((!std::__is_referenceable<void () const>::value), "");
|
||||
static_assert((!std::__is_referenceable<void () &>::value), "");
|
||||
static_assert((!std::__is_referenceable<void () &&>::value), "");
|
||||
static_assert((!std::__is_referenceable<void () const &>::value), "");
|
||||
static_assert((!std::__is_referenceable<void () const &&>::value), "");
|
||||
|
||||
static_assert(( std::__is_referenceable<void (int)>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int) const>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int) &>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int) &&>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int) const &>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int) const &&>::value), "");
|
||||
|
||||
static_assert(( std::__is_referenceable<void (int, float)>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, float) const>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, float) &>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, float) &&>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, float) const &>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, float) const &&>::value), "");
|
||||
|
||||
static_assert(( std::__is_referenceable<void (int, float, Foo &)>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, float, Foo &) const>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, float, Foo &) &>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, float, Foo &) &&>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, float, Foo &) const &>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, float, Foo &) const &&>::value), "");
|
||||
|
||||
static_assert(( std::__is_referenceable<void (...)>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (...) const>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (...) &>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (...) &&>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (...) const &>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (...) const &&>::value), "");
|
||||
|
||||
static_assert(( std::__is_referenceable<void (int, ...)>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, ...) const>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, ...) &>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, ...) &&>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, ...) const &>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, ...) const &&>::value), "");
|
||||
|
||||
static_assert(( std::__is_referenceable<void (int, float, ...)>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, float, ...) const>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, float, ...) &>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, float, ...) &&>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, float, ...) const &>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, float, ...) const &&>::value), "");
|
||||
|
||||
static_assert(( std::__is_referenceable<void (int, float, Foo &, ...)>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, float, Foo &, ...) const>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, float, Foo &, ...) &>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, float, Foo &, ...) &&>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, float, Foo &, ...) const &>::value), "");
|
||||
static_assert((!std::__is_referenceable<void (int, float, Foo &, ...) const &&>::value), "");
|
||||
|
||||
// member functions with or without cv-qualifiers are referenceable
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)()>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)() const>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)() &>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)() &&>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)() const &>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)() const &&>::value), "");
|
||||
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int)>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int) const>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int) &>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int) &&>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int) const &>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int) const &&>::value), "");
|
||||
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float)>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float) const>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float) &>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float) &&>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float) const &>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float) const &&>::value), "");
|
||||
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &)>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &) const>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &) &>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &) &&>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &) const &>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &) const &&>::value), "");
|
||||
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(...)>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(...) const>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(...) &>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(...) &&>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(...) const &>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(...) const &&>::value), "");
|
||||
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, ...)>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, ...) const>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, ...) &>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, ...) &&>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, ...) const &>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, ...) const &&>::value), "");
|
||||
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...)>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...) const>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...) &>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...) &&>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...) const &>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...) const &&>::value), "");
|
||||
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...)>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...) const>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...) &>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...) &&>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...) const &>::value), "");
|
||||
static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...) const &&>::value), "");
|
||||
|
||||
int main () {}
|
||||
@@ -10,18 +10,42 @@
|
||||
// type_traits
|
||||
|
||||
// add_pointer
|
||||
// If T names a referenceable type or a (possibly cv-qualified) void type then
|
||||
// the member typedef type shall name the same type as remove_reference_t<T>*;
|
||||
// otherwise, type shall name T.
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T, class U>
|
||||
void test_add_pointer()
|
||||
{
|
||||
static_assert((std::is_same<typename std::add_pointer<T>::type, U>::value), "");
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
#if TEST_STD_VER > 11
|
||||
static_assert((std::is_same<std::add_pointer_t<T>, U>::value), "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class F>
|
||||
void test_function0()
|
||||
{
|
||||
static_assert((std::is_same<typename std::add_pointer<F>::type, F*>::value), "");
|
||||
#if TEST_STD_VER > 11
|
||||
static_assert((std::is_same<std::add_pointer_t<F>, F*>::value), "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class F>
|
||||
void test_function1()
|
||||
{
|
||||
static_assert((std::is_same<typename std::add_pointer<F>::type, F>::value), "");
|
||||
#if TEST_STD_VER > 11
|
||||
static_assert((std::is_same<std::add_pointer_t<F>, F>::value), "");
|
||||
#endif
|
||||
}
|
||||
|
||||
struct Foo {};
|
||||
|
||||
int main()
|
||||
{
|
||||
test_add_pointer<void, void*>();
|
||||
@@ -31,4 +55,26 @@ int main()
|
||||
test_add_pointer<const int&, const int*>();
|
||||
test_add_pointer<int*, int**>();
|
||||
test_add_pointer<const int*, const int**>();
|
||||
test_add_pointer<Foo, Foo*>();
|
||||
|
||||
// LWG 2101 specifically talks about add_pointer and functions.
|
||||
// The term of art is "a referenceable type", which a cv- or ref-qualified function is not.
|
||||
test_function0<void()>();
|
||||
#if TEST_STD_VER >= 11
|
||||
test_function1<void() const>();
|
||||
test_function1<void() &>();
|
||||
test_function1<void() &&>();
|
||||
test_function1<void() const &>();
|
||||
test_function1<void() const &&>();
|
||||
#endif
|
||||
|
||||
// But a cv- or ref-qualified member function *is* "a referenceable type"
|
||||
test_function0<void (Foo::*)()>();
|
||||
#if TEST_STD_VER >= 11
|
||||
test_function0<void (Foo::*)() const>();
|
||||
test_function0<void (Foo::*)() &>();
|
||||
test_function0<void (Foo::*)() &&>();
|
||||
test_function0<void (Foo::*)() const &>();
|
||||
test_function0<void (Foo::*)() const &&>();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -12,12 +12,13 @@
|
||||
// remove_pointer
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T, class U>
|
||||
void test_remove_pointer()
|
||||
{
|
||||
static_assert((std::is_same<typename std::remove_pointer<T>::type, U>::value), "");
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
#if TEST_STD_VER > 11
|
||||
static_assert((std::is_same<std::remove_pointer_t<T>, U>::value), "");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -10,14 +10,17 @@
|
||||
// type_traits
|
||||
|
||||
// add_lvalue_reference
|
||||
// If T names a referenceable type then the member typedef type
|
||||
// shall name T&; otherwise, type shall name T.
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T, class U>
|
||||
void test_add_lvalue_reference()
|
||||
{
|
||||
static_assert((std::is_same<typename std::add_lvalue_reference<T>::type, U>::value), "");
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
#if TEST_STD_VER > 11
|
||||
static_assert((std::is_same<std::add_lvalue_reference_t<T>, U>::value), "");
|
||||
#endif
|
||||
}
|
||||
@@ -26,7 +29,7 @@ template <class F>
|
||||
void test_function0()
|
||||
{
|
||||
static_assert((std::is_same<typename std::add_lvalue_reference<F>::type, F&>::value), "");
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
#if TEST_STD_VER > 11
|
||||
static_assert((std::is_same<std::add_lvalue_reference_t<F>, F&>::value), "");
|
||||
#endif
|
||||
}
|
||||
@@ -35,7 +38,7 @@ template <class F>
|
||||
void test_function1()
|
||||
{
|
||||
static_assert((std::is_same<typename std::add_lvalue_reference<F>::type, F>::value), "");
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
#if TEST_STD_VER > 11
|
||||
static_assert((std::is_same<std::add_lvalue_reference_t<F>, F>::value), "");
|
||||
#endif
|
||||
}
|
||||
@@ -51,20 +54,26 @@ int main()
|
||||
test_add_lvalue_reference<const int&, const int&>();
|
||||
test_add_lvalue_reference<int*, int*&>();
|
||||
test_add_lvalue_reference<const int*, const int*&>();
|
||||
test_add_lvalue_reference<Foo, Foo&>();
|
||||
|
||||
// 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.
|
||||
test_function0<void()>();
|
||||
// test_function1<void() const>();
|
||||
// test_function1<void() &>();
|
||||
// test_function1<void() &&>();
|
||||
// test_function1<void() const &>();
|
||||
// test_function1<void() const &&>();
|
||||
#if TEST_STD_VER >= 11
|
||||
test_function1<void() const>();
|
||||
test_function1<void() &>();
|
||||
test_function1<void() &&>();
|
||||
test_function1<void() const &>();
|
||||
test_function1<void() const &&>();
|
||||
#endif
|
||||
|
||||
// But a cv- or ref-qualified member function *is* "a referenceable type"
|
||||
test_function0<void (Foo::*)()>();
|
||||
#if TEST_STD_VER >= 11
|
||||
test_function0<void (Foo::*)() const>();
|
||||
test_function0<void (Foo::*)() &>();
|
||||
test_function0<void (Foo::*)() &&>();
|
||||
test_function0<void (Foo::*)() const &>();
|
||||
test_function0<void (Foo::*)() const &&>();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -10,8 +10,11 @@
|
||||
// type_traits
|
||||
|
||||
// add_rvalue_reference
|
||||
// If T names a referenceable type then the member typedef type
|
||||
// shall name T&&; otherwise, type shall name T.
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
@@ -19,13 +22,32 @@ template <class T, class U>
|
||||
void test_add_rvalue_reference()
|
||||
{
|
||||
static_assert((std::is_same<typename std::add_rvalue_reference<T>::type, U>::value), "");
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
#if TEST_STD_VER > 11
|
||||
static_assert((std::is_same<std::add_rvalue_reference_t<T>, U>::value), "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class F>
|
||||
void test_function0()
|
||||
{
|
||||
static_assert((std::is_same<typename std::add_rvalue_reference<F>::type, F&&>::value), "");
|
||||
#if TEST_STD_VER > 11
|
||||
static_assert((std::is_same<std::add_rvalue_reference_t<F>, F&&>::value), "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class F>
|
||||
void test_function1()
|
||||
{
|
||||
static_assert((std::is_same<typename std::add_rvalue_reference<F>::type, F>::value), "");
|
||||
#if TEST_STD_VER > 11
|
||||
static_assert((std::is_same<std::add_rvalue_reference_t<F>, F>::value), "");
|
||||
#endif
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
struct Foo {};
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
@@ -36,5 +58,27 @@ int main()
|
||||
test_add_rvalue_reference<const int&, const int&>();
|
||||
test_add_rvalue_reference<int*, int*&&>();
|
||||
test_add_rvalue_reference<const int*, const int*&&>();
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
test_add_rvalue_reference<Foo, Foo&&>();
|
||||
|
||||
// LWG 2101 specifically talks about add_rvalue_reference and functions.
|
||||
// The term of art is "a referenceable type", which a cv- or ref-qualified function is not.
|
||||
test_function0<void()>();
|
||||
#if TEST_STD_VER >= 11
|
||||
test_function1<void() const>();
|
||||
test_function1<void() &>();
|
||||
test_function1<void() &&>();
|
||||
test_function1<void() const &>();
|
||||
test_function1<void() const &&>();
|
||||
#endif
|
||||
|
||||
// But a cv- or ref-qualified member function *is* "a referenceable type"
|
||||
test_function0<void (Foo::*)()>();
|
||||
#if TEST_STD_VER >= 11
|
||||
test_function0<void (Foo::*)() const>();
|
||||
test_function0<void (Foo::*)() &>();
|
||||
test_function0<void (Foo::*)() &&>();
|
||||
test_function0<void (Foo::*)() const &>();
|
||||
test_function0<void (Foo::*)() const &&>();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -12,12 +12,13 @@
|
||||
// remove_reference
|
||||
|
||||
#include <type_traits>
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T, class U>
|
||||
void test_remove_reference()
|
||||
{
|
||||
static_assert((std::is_same<typename std::remove_reference<T>::type, U>::value), "");
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
#if TEST_STD_VER > 11
|
||||
static_assert((std::is_same<std::remove_reference_t<T>, U>::value), "");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@
|
||||
<tr><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#1169">1169</a></td><td><tt>num_get</tt> not fully compatible with <tt>strto*</tt></td><td>Kona</td><td></td></tr>
|
||||
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2072">2072</a></td><td>Unclear wording about capacity of temporary buffers</td><td>Kona</td><td>Complete</td></tr>
|
||||
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2101">2101</a></td><td>Some transformation types can produce impossible types</td><td>Kona</td><td></td></tr>
|
||||
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2101">2101</a></td><td>Some transformation types can produce impossible types</td><td>Kona</td><td>Complete</td></tr>
|
||||
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2111">2111</a></td><td>Which <tt>unexpected</tt>/<tt>terminate</tt> handler is called from the exception handling runtime?</td><td>Kona</td><td>Complete</td></tr>
|
||||
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2119">2119</a></td><td>Missing <tt>hash</tt> specializations for extended integer types</td><td>Kona</td><td></td></tr>
|
||||
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2127">2127</a></td><td>Move-construction with <tt>raw_storage_iterator</tt></td><td>Kona</td><td>Complete</td></tr>
|
||||
@@ -192,7 +192,7 @@
|
||||
<!-- <tr><td></td><td></td><td></td><td></td></tr> -->
|
||||
</table>
|
||||
|
||||
<p>Last Updated: 5-Oct-2015</p>
|
||||
<p>Last Updated: 21-Jan-2016</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user