[libcxx] r254283 - Implement more of P0006; Type Traits Variable Templates.
Marshall Clow via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 29 20:30:02 PST 2015
Author: marshall
Date: Sun Nov 29 22:30:02 2015
New Revision: 254283
URL: http://llvm.org/viewvc/llvm-project?rev=254283&view=rev
Log:
Implement more of P0006; Type Traits Variable Templates.
Modified:
libcxx/trunk/include/type_traits
libcxx/trunk/test/std/utilities/meta/meta.rel/is_base_of.pass.cpp
libcxx/trunk/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp
libcxx/trunk/test/std/utilities/meta/meta.rel/is_same.pass.cpp
libcxx/trunk/test/std/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp
libcxx/trunk/test/std/utilities/meta/meta.unary.prop.query/extent.pass.cpp
libcxx/trunk/test/std/utilities/meta/meta.unary.prop.query/rank.pass.cpp
Modified: libcxx/trunk/include/type_traits
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=254283&r1=254282&r2=254283&view=diff
==============================================================================
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Sun Nov 29 22:30:02 2015
@@ -1079,6 +1079,11 @@ template <class _Tp> struct _LIBCPP_TYPE
template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[_Np]>
: public integral_constant<size_t, rank<_Tp>::value + 1> {};
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool rank_v
+ = rank<_Tp>::value;
+#endif
+
// extent
template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TYPE_VIS_ONLY extent
@@ -1092,6 +1097,11 @@ template <class _Tp, size_t _Np> struct
template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], _Ip>
: public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp, unsigned _Ip = 0> _LIBCPP_CONSTEXPR bool extent_v
+ = extent<_Tp, _Ip>::value;
+#endif
+
// remove_extent
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent
@@ -1218,6 +1228,11 @@ struct _LIBCPP_TYPE_VIS_ONLY is_base_of
#endif // _LIBCPP_HAS_IS_BASE_OF
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Bp, class _Dp> _LIBCPP_CONSTEXPR bool is_base_of_v
+ = is_base_of<_Bp, _Dp>::value;
+#endif
+
// is_convertible
#if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
@@ -1345,6 +1360,11 @@ template <class _T1, class _T2> struct _
#endif // __has_feature(is_convertible_to)
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _From, class _To> _LIBCPP_CONSTEXPR bool is_convertible_v
+ = is_convertible<_From, _To>::value;
+#endif
+
// is_empty
#if __has_feature(is_empty) || (_GNUC_VER >= 407)
@@ -1430,6 +1450,11 @@ template <class _Tp> _LIBCPP_CONSTEXPR b
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY alignment_of
: public integral_constant<size_t, __alignof__(_Tp)> {};
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template <class _Tp> _LIBCPP_CONSTEXPR bool alignment_of_v
+ = alignment_of<_Tp>::value;
+#endif
+
// aligned_storage
template <class _Hp, class _Tp>
Modified: libcxx/trunk/test/std/utilities/meta/meta.rel/is_base_of.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.rel/is_base_of.pass.cpp?rev=254283&r1=254282&r2=254283&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/meta/meta.rel/is_base_of.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/meta/meta.rel/is_base_of.pass.cpp Sun Nov 29 22:30:02 2015
@@ -13,6 +13,8 @@
#include <type_traits>
+#include "test_macros.h"
+
template <class T, class U>
void test_is_base_of()
{
@@ -20,6 +22,12 @@ void test_is_base_of()
static_assert((std::is_base_of<const T, U>::value), "");
static_assert((std::is_base_of<T, const U>::value), "");
static_assert((std::is_base_of<const T, const U>::value), "");
+#if TEST_STD_VERS > 14
+ static_assert((std::is_base_of_v<T, U>), "");
+ static_assert((std::is_base_of_v<const T, U>), "");
+ static_assert((std::is_base_of_v<T, const U>), "");
+ static_assert((std::is_base_of_v<const T, const U>), "");
+#endif
}
template <class T, class U>
Modified: libcxx/trunk/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp?rev=254283&r1=254282&r2=254283&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp Sun Nov 29 22:30:02 2015
@@ -13,6 +13,8 @@
#include <type_traits>
+#include "test_macros.h"
+
template <class T, class U>
void test_is_convertible()
{
@@ -20,6 +22,12 @@ void test_is_convertible()
static_assert((std::is_convertible<const T, U>::value), "");
static_assert((std::is_convertible<T, const U>::value), "");
static_assert((std::is_convertible<const T, const U>::value), "");
+#if TEST_STD_VERS > 14
+ static_assert((std::is_convertible_v<T, U>), "");
+ static_assert((std::is_convertible_v<const T, U>), "");
+ static_assert((std::is_convertible_v<T, const U>), "");
+ static_assert((std::is_convertible_v<const T, const U>), "");
+#endif
}
template <class T, class U>
@@ -29,6 +37,12 @@ void test_is_not_convertible()
static_assert((!std::is_convertible<const T, U>::value), "");
static_assert((!std::is_convertible<T, const U>::value), "");
static_assert((!std::is_convertible<const T, const U>::value), "");
+#if TEST_STD_VERS > 14
+ static_assert((!std::is_convertible_v<T, U>), "");
+ static_assert((!std::is_convertible_v<const T, U>), "");
+ static_assert((!std::is_convertible_v<T, const U>), "");
+ static_assert((!std::is_convertible_v<const T, const U>), "");
+#endif
}
typedef void Function();
Modified: libcxx/trunk/test/std/utilities/meta/meta.rel/is_same.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.rel/is_same.pass.cpp?rev=254283&r1=254282&r2=254283&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/meta/meta.rel/is_same.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/meta/meta.rel/is_same.pass.cpp Sun Nov 29 22:30:02 2015
@@ -13,13 +13,21 @@
#include <type_traits>
+#include "test_macros.h"
+
template <class T, class U>
void test_is_same()
{
- static_assert((std::is_same<T, U>::value), "");
+ static_assert(( std::is_same<T, U>::value), "");
static_assert((!std::is_same<const T, U>::value), "");
static_assert((!std::is_same<T, const U>::value), "");
- static_assert((std::is_same<const T, const U>::value), "");
+ static_assert(( std::is_same<const T, const U>::value), "");
+#if TEST_STD_VERS > 14
+ static_assert(( std::is_same_v<T, U>), "");
+ static_assert((!std::is_same_v<const T, U>), "");
+ static_assert((!std::is_same_v<T, const U>), "");
+ static_assert(( std::is_same_v<const T, const U>), "");
+#endif
}
template <class T, class U>
@@ -29,6 +37,12 @@ void test_is_same_ref()
static_assert((std::is_same<const T, U>::value), "");
static_assert((std::is_same<T, const U>::value), "");
static_assert((std::is_same<const T, const U>::value), "");
+#if TEST_STD_VERS > 14
+ static_assert((std::is_same_v<T, U>), "");
+ static_assert((std::is_same_v<const T, U>), "");
+ static_assert((std::is_same_v<T, const U>), "");
+ static_assert((std::is_same_v<const T, const U>), "");
+#endif
}
template <class T, class U>
Modified: libcxx/trunk/test/std/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp?rev=254283&r1=254282&r2=254283&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp Sun Nov 29 22:30:02 2015
@@ -14,6 +14,8 @@
#include <type_traits>
#include <cstdint>
+#include "test_macros.h"
+
template <class T, unsigned A>
void test_alignment_of()
{
@@ -21,6 +23,12 @@ void test_alignment_of()
static_assert( std::alignment_of<const T>::value == A, "");
static_assert( std::alignment_of<volatile T>::value == A, "");
static_assert( std::alignment_of<const volatile T>::value == A, "");
+#if TEST_STD_VERS > 14
+ static_assert( std::alignment_of_v<T> == A, "");
+ static_assert( std::alignment_of_v<const T> == A, "");
+ static_assert( std::alignment_of_v<volatile T> == A, "");
+ static_assert( std::alignment_of_v<const volatile T> == A, "");
+#endif
}
class Class
Modified: libcxx/trunk/test/std/utilities/meta/meta.unary.prop.query/extent.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary.prop.query/extent.pass.cpp?rev=254283&r1=254282&r2=254283&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/meta/meta.unary.prop.query/extent.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/meta/meta.unary.prop.query/extent.pass.cpp Sun Nov 29 22:30:02 2015
@@ -13,6 +13,8 @@
#include <type_traits>
+#include "test_macros.h"
+
template <class T, unsigned A>
void test_extent()
{
@@ -20,6 +22,12 @@ void test_extent()
static_assert((std::extent<const T>::value == A), "");
static_assert((std::extent<volatile T>::value == A), "");
static_assert((std::extent<const volatile T>::value == A), "");
+#if TEST_STD_VERS > 14
+ static_assert((std::extent_v<T> == A), "");
+ static_assert((std::extent_v<const T> == A), "");
+ static_assert((std::extent_v<volatile T> == A), "");
+ static_assert((std::extent_v<const volatile T> == A), "");
+#endif
}
template <class T, unsigned A>
@@ -29,6 +37,12 @@ void test_extent1()
static_assert((std::extent<const T, 1>::value == A), "");
static_assert((std::extent<volatile T, 1>::value == A), "");
static_assert((std::extent<const volatile T, 1>::value == A), "");
+#if TEST_STD_VERS > 14
+ static_assert((std::extent_v<T, 1> == A), "");
+ static_assert((std::extent_v<const T, 1> == A), "");
+ static_assert((std::extent_v<volatile T, 1> == A), "");
+ static_assert((std::extent_v<const volatile T, 1> == A), "");
+#endif
}
class Class
Modified: libcxx/trunk/test/std/utilities/meta/meta.unary.prop.query/rank.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary.prop.query/rank.pass.cpp?rev=254283&r1=254282&r2=254283&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/meta/meta.unary.prop.query/rank.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/meta/meta.unary.prop.query/rank.pass.cpp Sun Nov 29 22:30:02 2015
@@ -13,6 +13,8 @@
#include <type_traits>
+#include "test_macros.h"
+
template <class T, unsigned A>
void test_rank()
{
@@ -20,6 +22,12 @@ void test_rank()
static_assert( std::rank<const T>::value == A, "");
static_assert( std::rank<volatile T>::value == A, "");
static_assert( std::rank<const volatile T>::value == A, "");
+#if TEST_STD_VERS > 14
+ static_assert( std::rank_v<T> == A, "");
+ static_assert( std::rank_v<const T> == A, "");
+ static_assert( std::rank_v<volatile T> == A, "");
+ static_assert( std::rank_v<const volatile T> == A, "");
+#endif
}
class Class
More information about the cfe-commits
mailing list