diff options
Diffstat (limited to 'libcxx/test/std/utilities/meta')
105 files changed, 6008 insertions, 0 deletions
diff --git a/libcxx/test/std/utilities/meta/meta.hel/integral_constant.pass.cpp b/libcxx/test/std/utilities/meta/meta.hel/integral_constant.pass.cpp new file mode 100644 index 00000000000..1ad1adcc5cd --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.hel/integral_constant.pass.cpp @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// integral_constant + +#include <type_traits> +#include <cassert> + +int main() +{ + typedef std::integral_constant<int, 5> _5; + static_assert(_5::value == 5, ""); + static_assert((std::is_same<_5::value_type, int>::value), ""); + static_assert((std::is_same<_5::type, _5>::value), ""); +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + static_assert((_5() == 5), ""); +#else + assert(_5() == 5); +#endif + +#if _LIBCPP_STD_VER > 11 + static_assert ( _5{}() == 5, "" ); + static_assert ( std::true_type{}(), "" ); +#endif + + static_assert(std::false_type::value == false, ""); + static_assert((std::is_same<std::false_type::value_type, bool>::value), ""); + static_assert((std::is_same<std::false_type::type, std::false_type>::value), ""); + + static_assert(std::true_type::value == true, ""); + static_assert((std::is_same<std::true_type::value_type, bool>::value), ""); + static_assert((std::is_same<std::true_type::type, std::true_type>::value), ""); + + std::false_type f1; + std::false_type f2 = f1; + + std::true_type t1; + std::true_type t2 = t1; +} diff --git a/libcxx/test/std/utilities/meta/meta.rel/is_base_of.pass.cpp b/libcxx/test/std/utilities/meta/meta.rel/is_base_of.pass.cpp new file mode 100644 index 00000000000..0f90ae5c1ca --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.rel/is_base_of.pass.cpp @@ -0,0 +1,49 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_base_of + +#include <type_traits> + +template <class T, class U> +void test_is_base_of() +{ + static_assert((std::is_base_of<T, U>::value), ""); + 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), ""); +} + +template <class T, class U> +void test_is_not_base_of() +{ + static_assert((!std::is_base_of<T, U>::value), ""); +} + +struct B {}; +struct B1 : B {}; +struct B2 : B {}; +struct D : private B1, private B2 {}; + +int main() +{ + test_is_base_of<B, D>(); + test_is_base_of<B1, D>(); + test_is_base_of<B2, D>(); + test_is_base_of<B, B1>(); + test_is_base_of<B, B2>(); + test_is_base_of<B, B>(); + + test_is_not_base_of<D, B>(); + test_is_not_base_of<B&, D&>(); + test_is_not_base_of<B[3], D[3]>(); + test_is_not_base_of<int, int>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp b/libcxx/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp new file mode 100644 index 00000000000..718e0ff18cf --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp @@ -0,0 +1,189 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_convertible + +#include <type_traits> + +template <class T, class U> +void test_is_convertible() +{ + static_assert((std::is_convertible<T, U>::value), ""); + 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), ""); +} + +template <class T, class U> +void test_is_not_convertible() +{ + static_assert((!std::is_convertible<T, U>::value), ""); + 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), ""); +} + +typedef void Function(); +typedef char Array[1]; + +class NonCopyable { + NonCopyable(NonCopyable&); +}; + +int main() +{ + // void + test_is_convertible<void,void> (); + test_is_not_convertible<void,Function> (); + test_is_not_convertible<void,Function&> (); + test_is_not_convertible<void,Function*> (); + test_is_not_convertible<void,Array> (); + test_is_not_convertible<void,Array&> (); + test_is_not_convertible<void,char> (); + test_is_not_convertible<void,char&> (); + test_is_not_convertible<void,char*> (); + + // Function + test_is_not_convertible<Function, void> (); + test_is_not_convertible<Function, Function> (); + test_is_convertible<Function, Function&> (); + test_is_convertible<Function, Function*> (); + test_is_not_convertible<Function, Array> (); + test_is_not_convertible<Function, Array&> (); + test_is_not_convertible<Function, char> (); + test_is_not_convertible<Function, char&> (); + test_is_not_convertible<Function, char*> (); + + // Function& + test_is_not_convertible<Function&, void> (); + test_is_not_convertible<Function&, Function> (); + test_is_convertible<Function&, Function&> (); + + test_is_convertible<Function&, Function*> (); + test_is_not_convertible<Function&, Array> (); + test_is_not_convertible<Function&, Array&> (); + test_is_not_convertible<Function&, char> (); + test_is_not_convertible<Function&, char&> (); + test_is_not_convertible<Function&, char*> (); + + // Function* + test_is_not_convertible<Function*, void> (); + test_is_not_convertible<Function*, Function> (); + test_is_not_convertible<Function*, Function&> (); + test_is_convertible<Function*, Function*> (); + + test_is_not_convertible<Function*, Array> (); + test_is_not_convertible<Function*, Array&> (); + test_is_not_convertible<Function*, char> (); + test_is_not_convertible<Function*, char&> (); + test_is_not_convertible<Function*, char*> (); + + // Array + test_is_not_convertible<Array, void> (); + test_is_not_convertible<Array, Function> (); + test_is_not_convertible<Array, Function&> (); + test_is_not_convertible<Array, Function*> (); + test_is_not_convertible<Array, Array> (); + + static_assert((!std::is_convertible<Array, Array&>::value), ""); + static_assert(( std::is_convertible<Array, const Array&>::value), ""); + static_assert((!std::is_convertible<const Array, Array&>::value), ""); + static_assert(( std::is_convertible<const Array, const Array&>::value), ""); + + test_is_not_convertible<Array, char> (); + test_is_not_convertible<Array, char&> (); + + static_assert(( std::is_convertible<Array, char*>::value), ""); + static_assert(( std::is_convertible<Array, const char*>::value), ""); + static_assert((!std::is_convertible<const Array, char*>::value), ""); + static_assert(( std::is_convertible<const Array, const char*>::value), ""); + + // Array& + test_is_not_convertible<Array&, void> (); + test_is_not_convertible<Array&, Function> (); + test_is_not_convertible<Array&, Function&> (); + test_is_not_convertible<Array&, Function*> (); + test_is_not_convertible<Array&, Array> (); + + static_assert(( std::is_convertible<Array&, Array&>::value), ""); + static_assert(( std::is_convertible<Array&, const Array&>::value), ""); + static_assert((!std::is_convertible<const Array&, Array&>::value), ""); + static_assert(( std::is_convertible<const Array&, const Array&>::value), ""); + + test_is_not_convertible<Array&, char> (); + test_is_not_convertible<Array&, char&> (); + + static_assert(( std::is_convertible<Array&, char*>::value), ""); + static_assert(( std::is_convertible<Array&, const char*>::value), ""); + static_assert((!std::is_convertible<const Array&, char*>::value), ""); + static_assert(( std::is_convertible<const Array&, const char*>::value), ""); + + // char + test_is_not_convertible<char, void> (); + test_is_not_convertible<char, Function> (); + test_is_not_convertible<char, Function&> (); + test_is_not_convertible<char, Function*> (); + test_is_not_convertible<char, Array> (); + test_is_not_convertible<char, Array&> (); + + test_is_convertible<char, char> (); + + static_assert((!std::is_convertible<char, char&>::value), ""); + static_assert(( std::is_convertible<char, const char&>::value), ""); + static_assert((!std::is_convertible<const char, char&>::value), ""); + static_assert(( std::is_convertible<const char, const char&>::value), ""); + + test_is_not_convertible<char, char*> (); + + // char& + test_is_not_convertible<char&, void> (); + test_is_not_convertible<char&, Function> (); + test_is_not_convertible<char&, Function&> (); + test_is_not_convertible<char&, Function*> (); + test_is_not_convertible<char&, Array> (); + test_is_not_convertible<char&, Array&> (); + + test_is_convertible<char&, char> (); + + static_assert(( std::is_convertible<char&, char&>::value), ""); + static_assert(( std::is_convertible<char&, const char&>::value), ""); + static_assert((!std::is_convertible<const char&, char&>::value), ""); + static_assert(( std::is_convertible<const char&, const char&>::value), ""); + + test_is_not_convertible<char&, char*> (); + + // char* + test_is_not_convertible<char*, void> (); + test_is_not_convertible<char*, Function> (); + test_is_not_convertible<char*, Function&> (); + test_is_not_convertible<char*, Function*> (); + test_is_not_convertible<char*, Array> (); + test_is_not_convertible<char*, Array&> (); + + test_is_not_convertible<char*, char> (); + test_is_not_convertible<char*, char&> (); + + static_assert(( std::is_convertible<char*, char*>::value), ""); + static_assert(( std::is_convertible<char*, const char*>::value), ""); + static_assert((!std::is_convertible<const char*, char*>::value), ""); + static_assert(( std::is_convertible<const char*, const char*>::value), ""); + + // NonCopyable + static_assert((std::is_convertible<NonCopyable&, NonCopyable&>::value), ""); + static_assert((std::is_convertible<NonCopyable&, const NonCopyable&>::value), ""); + static_assert((std::is_convertible<NonCopyable&, const volatile NonCopyable&>::value), ""); + static_assert((std::is_convertible<NonCopyable&, volatile NonCopyable&>::value), ""); + static_assert((std::is_convertible<const NonCopyable&, const NonCopyable&>::value), ""); + static_assert((std::is_convertible<const NonCopyable&, const volatile NonCopyable&>::value), ""); + static_assert((std::is_convertible<volatile NonCopyable&, const volatile NonCopyable&>::value), ""); + static_assert((std::is_convertible<const volatile NonCopyable&, const volatile NonCopyable&>::value), ""); + static_assert((!std::is_convertible<const NonCopyable&, NonCopyable&>::value), ""); +} diff --git a/libcxx/test/std/utilities/meta/meta.rel/is_same.pass.cpp b/libcxx/test/std/utilities/meta/meta.rel/is_same.pass.cpp new file mode 100644 index 00000000000..7250d6ca773 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.rel/is_same.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_same + +#include <type_traits> + +template <class T, class U> +void test_is_same() +{ + 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), ""); +} + +template <class T, class U> +void test_is_same_ref() +{ + 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), ""); +} + +template <class T, class U> +void test_is_not_same() +{ + static_assert((!std::is_same<T, U>::value), ""); +} + +class Class +{ +public: + ~Class(); +}; + +int main() +{ + test_is_same<int, int>(); + test_is_same<void, void>(); + test_is_same<Class, Class>(); + test_is_same<int*, int*>(); + test_is_same_ref<int&, int&>(); + + test_is_not_same<int, void>(); + test_is_not_same<void, Class>(); + test_is_not_same<Class, int*>(); + test_is_not_same<int*, int&>(); + test_is_not_same<int&, int>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.rqmts/nothing_to_do.pass.cpp b/libcxx/test/std/utilities/meta/meta.rqmts/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.rqmts/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.arr/remove_all_extents.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.arr/remove_all_extents.pass.cpp new file mode 100644 index 00000000000..28bbedee174 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.arr/remove_all_extents.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// remove_all_extents + +#include <type_traits> + +enum Enum {zero, one_}; + +template <class T, class U> +void test_remove_all_extents() +{ + static_assert((std::is_same<typename std::remove_all_extents<T>::type, U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same<std::remove_all_extents_t<T>, U>::value), ""); +#endif +} + +int main() +{ + test_remove_all_extents<int, int> (); + test_remove_all_extents<const Enum, const Enum> (); + test_remove_all_extents<int[], int> (); + test_remove_all_extents<const int[], const int> (); + test_remove_all_extents<int[3], int> (); + test_remove_all_extents<const int[3], const int> (); + test_remove_all_extents<int[][3], int> (); + test_remove_all_extents<const int[][3], const int> (); + test_remove_all_extents<int[2][3], int> (); + test_remove_all_extents<const int[2][3], const int> (); + test_remove_all_extents<int[1][2][3], int> (); + test_remove_all_extents<const int[1][2][3], const int> (); +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.arr/remove_extent.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.arr/remove_extent.pass.cpp new file mode 100644 index 00000000000..c688c26b9a5 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.arr/remove_extent.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// remove_extent + +#include <type_traits> + +enum Enum {zero, one_}; + +template <class T, class U> +void test_remove_extent() +{ + static_assert((std::is_same<typename std::remove_extent<T>::type, U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same<std::remove_extent_t<T>, U>::value), ""); +#endif +} + + +int main() +{ + test_remove_extent<int, int> (); + test_remove_extent<const Enum, const Enum> (); + test_remove_extent<int[], int> (); + test_remove_extent<const int[], const int> (); + test_remove_extent<int[3], int> (); + test_remove_extent<const int[3], const int> (); + test_remove_extent<int[][3], int[3]> (); + test_remove_extent<const int[][3], const int[3]> (); + test_remove_extent<int[2][3], int[3]> (); + test_remove_extent<const int[2][3], const int[3]> (); + test_remove_extent<int[1][2][3], int[2][3]> (); + test_remove_extent<const int[1][2][3], const int[2][3]> (); +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.cv/add_const.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.cv/add_const.pass.cpp new file mode 100644 index 00000000000..19b1fb4d01b --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.cv/add_const.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// add_const + +#include <type_traits> + +template <class T, class U> +void test_add_const_imp() +{ + static_assert((std::is_same<typename std::add_const<T>::type, const U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same<std::add_const_t<T>, U>::value), ""); +#endif +} + +template <class T> +void test_add_const() +{ + test_add_const_imp<T, const T>(); + test_add_const_imp<const T, const T>(); + test_add_const_imp<volatile T, volatile const T>(); + test_add_const_imp<const volatile T, const volatile T>(); +} + +int main() +{ + test_add_const<void>(); + test_add_const<int>(); + test_add_const<int[3]>(); + test_add_const<int&>(); + test_add_const<const int&>(); + test_add_const<int*>(); + test_add_const<const int*>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.cv/add_cv.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.cv/add_cv.pass.cpp new file mode 100644 index 00000000000..4905e518e12 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.cv/add_cv.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// add_cv + +#include <type_traits> + +template <class T, class U> +void test_add_cv_imp() +{ + static_assert((std::is_same<typename std::add_cv<T>::type, const volatile U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same<std::add_cv_t<T>, U>::value), ""); +#endif +} + +template <class T> +void test_add_cv() +{ + test_add_cv_imp<T, const volatile T>(); + test_add_cv_imp<const T, const volatile T>(); + test_add_cv_imp<volatile T, volatile const T>(); + test_add_cv_imp<const volatile T, const volatile T>(); +} + +int main() +{ + test_add_cv<void>(); + test_add_cv<int>(); + test_add_cv<int[3]>(); + test_add_cv<int&>(); + test_add_cv<const int&>(); + test_add_cv<int*>(); + test_add_cv<const int*>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.cv/add_volatile.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.cv/add_volatile.pass.cpp new file mode 100644 index 00000000000..7a12c44a2c6 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.cv/add_volatile.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// add_volatile + +#include <type_traits> + +template <class T, class U> +void test_add_volatile_imp() +{ + static_assert((std::is_same<typename std::add_volatile<T>::type, volatile U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same<std::add_volatile_t<T>, U>::value), ""); +#endif +} + +template <class T> +void test_add_volatile() +{ + test_add_volatile_imp<T, volatile T>(); + test_add_volatile_imp<const T, const volatile T>(); + test_add_volatile_imp<volatile T, volatile T>(); + test_add_volatile_imp<const volatile T, const volatile T>(); +} + +int main() +{ + test_add_volatile<void>(); + test_add_volatile<int>(); + test_add_volatile<int[3]>(); + test_add_volatile<int&>(); + test_add_volatile<const int&>(); + test_add_volatile<int*>(); + test_add_volatile<const int*>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.cv/remove_const.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.cv/remove_const.pass.cpp new file mode 100644 index 00000000000..cd2faf786d8 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.cv/remove_const.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// remove_const + +#include <type_traits> + +template <class T, class U> +void test_remove_const_imp() +{ + static_assert((std::is_same<typename std::remove_const<T>::type, U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same<std::remove_const_t<T>, U>::value), ""); +#endif +} + +template <class T> +void test_remove_const() +{ + test_remove_const_imp<T, T>(); + test_remove_const_imp<const T, T>(); + test_remove_const_imp<volatile T, volatile T>(); + test_remove_const_imp<const volatile T, volatile T>(); +} + +int main() +{ + test_remove_const<void>(); + test_remove_const<int>(); + test_remove_const<int[3]>(); + test_remove_const<int&>(); + test_remove_const<const int&>(); + test_remove_const<int*>(); + test_remove_const<const int*>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.cv/remove_cv.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.cv/remove_cv.pass.cpp new file mode 100644 index 00000000000..3f6405c8280 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.cv/remove_cv.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// remove_cv + +#include <type_traits> + +template <class T, class U> +void test_remove_cv_imp() +{ + static_assert((std::is_same<typename std::remove_cv<T>::type, U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same<std::remove_cv_t<T>, U>::value), ""); +#endif +} + +template <class T> +void test_remove_cv() +{ + test_remove_cv_imp<T, T>(); + test_remove_cv_imp<const T, T>(); + test_remove_cv_imp<volatile T, T>(); + test_remove_cv_imp<const volatile T, T>(); +} + +int main() +{ + test_remove_cv<void>(); + test_remove_cv<int>(); + test_remove_cv<int[3]>(); + test_remove_cv<int&>(); + test_remove_cv<const int&>(); + test_remove_cv<int*>(); + test_remove_cv<const int*>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.cv/remove_volatile.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.cv/remove_volatile.pass.cpp new file mode 100644 index 00000000000..6258a9039b4 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.cv/remove_volatile.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// remove_volatile + +#include <type_traits> + +template <class T, class U> +void test_remove_volatile_imp() +{ + static_assert((std::is_same<typename std::remove_volatile<T>::type, U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same<std::remove_volatile_t<T>, U>::value), ""); +#endif +} + +template <class T> +void test_remove_volatile() +{ + test_remove_volatile_imp<T, T>(); + test_remove_volatile_imp<const T, const T>(); + test_remove_volatile_imp<volatile T, T>(); + test_remove_volatile_imp<const volatile T, const T>(); +} + +int main() +{ + test_remove_volatile<void>(); + test_remove_volatile<int>(); + test_remove_volatile<int[3]>(); + test_remove_volatile<int&>(); + test_remove_volatile<const int&>(); + test_remove_volatile<int*>(); + test_remove_volatile<volatile int*>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp new file mode 100644 index 00000000000..c87e99c46e8 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp @@ -0,0 +1,194 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// aligned_storage + +#include <type_traits> + +int main() +{ + { + typedef std::aligned_storage<10, 1 >::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_storage_t<10, 1>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 1, ""); + static_assert(sizeof(T1) == 10, ""); + } + { + typedef std::aligned_storage<10, 2 >::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_storage_t<10, 2>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 2, ""); + static_assert(sizeof(T1) == 10, ""); + } + { + typedef std::aligned_storage<10, 4 >::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_storage_t<10, 4>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 4, ""); + static_assert(sizeof(T1) == 12, ""); + } + { + typedef std::aligned_storage<10, 8 >::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_storage_t<10, 8>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 8, ""); + static_assert(sizeof(T1) == 16, ""); + } + { + typedef std::aligned_storage<10, 16 >::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_storage_t<10, 16>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 16, ""); + static_assert(sizeof(T1) == 16, ""); + } + { + typedef std::aligned_storage<10, 32 >::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_storage_t<10, 32>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 32, ""); + static_assert(sizeof(T1) == 32, ""); + } + { + typedef std::aligned_storage<20, 32 >::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_storage_t<20, 32>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 32, ""); + static_assert(sizeof(T1) == 32, ""); + } + { + typedef std::aligned_storage<40, 32 >::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_storage_t<40, 32>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 32, ""); + static_assert(sizeof(T1) == 64, ""); + } + { + typedef std::aligned_storage<12, 16 >::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_storage_t<12, 16>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 16, ""); + static_assert(sizeof(T1) == 16, ""); + } + { + typedef std::aligned_storage<1>::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_storage_t<1>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 1, ""); + static_assert(sizeof(T1) == 1, ""); + } + { + typedef std::aligned_storage<2>::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_storage_t<2>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 2, ""); + static_assert(sizeof(T1) == 2, ""); + } + { + typedef std::aligned_storage<3>::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_storage_t<3>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 2, ""); + static_assert(sizeof(T1) == 4, ""); + } + { + typedef std::aligned_storage<4>::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_storage_t<4>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 4, ""); + static_assert(sizeof(T1) == 4, ""); + } + { + typedef std::aligned_storage<5>::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_storage_t<5>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 4, ""); + static_assert(sizeof(T1) == 8, ""); + } + { + typedef std::aligned_storage<7>::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_storage_t<7>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 4, ""); + static_assert(sizeof(T1) == 8, ""); + } + { + typedef std::aligned_storage<8>::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_storage_t<8>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 8, ""); + static_assert(sizeof(T1) == 8, ""); + } + { + typedef std::aligned_storage<9>::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_storage_t<9>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 8, ""); + static_assert(sizeof(T1) == 16, ""); + } + { + typedef std::aligned_storage<15>::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_storage_t<15>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 8, ""); + static_assert(sizeof(T1) == 16, ""); + } + // Use alignof(std::max_align_t) below to find the max alignment instead of + // hardcoding it, because it's different on different platforms. + // (For example 8 on arm and 16 on x86.) +#if __cplusplus < 201103L +#define alignof __alignof__ +#endif + { + typedef std::aligned_storage<16>::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_storage_t<16>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == alignof(std::max_align_t), + ""); + static_assert(sizeof(T1) == 16, ""); + } + { + typedef std::aligned_storage<17>::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_storage_t<17>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == alignof(std::max_align_t), + ""); + static_assert(sizeof(T1) == 16 + alignof(std::max_align_t), ""); + } + { + typedef std::aligned_storage<10>::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_storage_t<10>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 8, ""); + static_assert(sizeof(T1) == 16, ""); + } +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.pass.cpp new file mode 100644 index 00000000000..ae849ca5455 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.pass.cpp @@ -0,0 +1,92 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// aligned_union<size_t Len, class ...Types> + +#include <type_traits> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_VARIADICS + { + typedef std::aligned_union<10, char >::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_union_t<10, char>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 1, ""); + static_assert(sizeof(T1) == 10, ""); + } + { + typedef std::aligned_union<10, short >::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_union_t<10, short>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 2, ""); + static_assert(sizeof(T1) == 10, ""); + } + { + typedef std::aligned_union<10, int >::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_union_t<10, int>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 4, ""); + static_assert(sizeof(T1) == 12, ""); + } + { + typedef std::aligned_union<10, double >::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_union_t<10, double>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 8, ""); + static_assert(sizeof(T1) == 16, ""); + } + { + typedef std::aligned_union<10, short, char >::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_union_t<10, short, char>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 2, ""); + static_assert(sizeof(T1) == 10, ""); + } + { + typedef std::aligned_union<10, char, short >::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_union_t<10, char, short>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 2, ""); + static_assert(sizeof(T1) == 10, ""); + } + { + typedef std::aligned_union<2, int, char, short >::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_union_t<2, int, char, short>, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 4, ""); + static_assert(sizeof(T1) == 4, ""); + } + { + typedef std::aligned_union<2, char, int, short >::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_union_t<2, char, int, short >, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 4, ""); + static_assert(sizeof(T1) == 4, ""); + } + { + typedef std::aligned_union<2, char, short, int >::type T1; +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_same<std::aligned_union_t<2, char, short, int >, T1>::value, "" ); +#endif + static_assert(std::alignment_of<T1>::value == 4, ""); + static_assert(sizeof(T1) == 4, ""); + } +#endif +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp new file mode 100644 index 00000000000..91bf7e7654e --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// common_type + +#include <type_traits> + +int main() +{ + static_assert((std::is_same<std::common_type<int>::type, int>::value), ""); + static_assert((std::is_same<std::common_type<char>::type, char>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same<std::common_type_t<int>, int>::value), ""); + static_assert((std::is_same<std::common_type_t<char>, char>::value), ""); +#endif + + static_assert((std::is_same<std::common_type< int>::type, int>::value), ""); + static_assert((std::is_same<std::common_type<const int>::type, int>::value), ""); + static_assert((std::is_same<std::common_type< volatile int>::type, int>::value), ""); + static_assert((std::is_same<std::common_type<const volatile int>::type, int>::value), ""); + + static_assert((std::is_same<std::common_type<int, int>::type, int>::value), ""); + static_assert((std::is_same<std::common_type<int, const int>::type, int>::value), ""); + + static_assert((std::is_same<std::common_type<long, const int>::type, long>::value), ""); + static_assert((std::is_same<std::common_type<const long, int>::type, long>::value), ""); + static_assert((std::is_same<std::common_type<long, volatile int>::type, long>::value), ""); + static_assert((std::is_same<std::common_type<volatile long, int>::type, long>::value), ""); + static_assert((std::is_same<std::common_type<const long, const int>::type, long>::value), ""); + + static_assert((std::is_same<std::common_type<double, char>::type, double>::value), ""); + static_assert((std::is_same<std::common_type<short, char>::type, int>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same<std::common_type_t<double, char>, double>::value), ""); + static_assert((std::is_same<std::common_type_t<short, char>, int>::value), ""); +#endif + + static_assert((std::is_same<std::common_type<double, char, long long>::type, double>::value), ""); + static_assert((std::is_same<std::common_type<unsigned, char, long long>::type, long long>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same<std::common_type_t<double, char, long long>, double>::value), ""); + static_assert((std::is_same<std::common_type_t<unsigned, char, long long>, long long>::value), ""); +#endif +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/conditional.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/conditional.pass.cpp new file mode 100644 index 00000000000..ac11e3a4ce8 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/conditional.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// conditional + +#include <type_traits> + +int main() +{ + static_assert((std::is_same<std::conditional<true, char, int>::type, char>::value), ""); + static_assert((std::is_same<std::conditional<false, char, int>::type, int>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same<std::conditional_t<true, char, int>, char>::value), ""); + static_assert((std::is_same<std::conditional_t<false, char, int>, int>::value), ""); +#endif +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp new file mode 100644 index 00000000000..bd8ae0e297b --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// decay + +#include <type_traits> + +template <class T, class U> +void test_decay() +{ + static_assert((std::is_same<typename std::decay<T>::type, U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same<std::decay_t<T>, U>::value), ""); +#endif +} + +int main() +{ + test_decay<void, void>(); + test_decay<int, int>(); + test_decay<const volatile int, int>(); + test_decay<int*, int*>(); + test_decay<int[3], int*>(); + test_decay<const int[3], const int*>(); + test_decay<void(), void (*)()>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/enable_if.fail.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/enable_if.fail.cpp new file mode 100644 index 00000000000..1ab07670fc2 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/enable_if.fail.cpp @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// enable_if + +#include <type_traits> + +int main() +{ + typedef std::enable_if<false>::type A; +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/enable_if.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/enable_if.pass.cpp new file mode 100644 index 00000000000..eb72b0f393b --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/enable_if.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// enable_if + +#include <type_traits> + +int main() +{ + static_assert((std::is_same<std::enable_if<true>::type, void>::value), ""); + static_assert((std::is_same<std::enable_if<true, int>::type, int>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same<std::enable_if_t<true>, void>::value), ""); + static_assert((std::is_same<std::enable_if_t<true, int>, int>::value), ""); +#endif +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/enable_if2.fail.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/enable_if2.fail.cpp new file mode 100644 index 00000000000..8ce894578c4 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/enable_if2.fail.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// enable_if + +#include <type_traits> + +int main() +{ +#if _LIBCPP_STD_VER > 11 + typedef std::enable_if_t<false> A; +#else + static_assert ( false, "" ); +#endif +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp new file mode 100644 index 00000000000..bf44c340ee5 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp @@ -0,0 +1,98 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// result_of<Fn(ArgTypes...)> + +#include <type_traits> +#include <memory> + +typedef bool (&PF1)(); +typedef short (*PF2)(long); + +struct S +{ + operator PF2() const; + double operator()(char, int&); + void calc(long) const; + char data_; +}; + +typedef void (S::*PMS)(long) const; +typedef char S::*PMD; + +struct wat +{ + wat& operator*() { return *this; } + void foo(); +}; + +struct F {}; + +template <class T, class U> +void test_result_of_imp() +{ + static_assert((std::is_same<typename std::result_of<T>::type, U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same<std::result_of_t<T>, U>::value), ""); +#endif +} + +int main() +{ + test_result_of_imp<S(int), short> (); + test_result_of_imp<S&(unsigned char, int&), double> (); + test_result_of_imp<PF1(), bool> (); + test_result_of_imp<PMS(std::unique_ptr<S>, int), void> (); + test_result_of_imp<PMS(S, int), void> (); + test_result_of_imp<PMS(const S&, int), void> (); +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_result_of_imp<PMD(S), char&&> (); +#endif + test_result_of_imp<PMD(const S*), const char&> (); +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_result_of_imp<int (F::* (F &)) () &, int> (); + test_result_of_imp<int (F::* (F &)) () const &, int> (); + test_result_of_imp<int (F::* (F const &)) () const &, int> (); + test_result_of_imp<int (F::* (F &&)) () &&, int> (); + test_result_of_imp<int (F::* (F &&)) () const&&, int> (); + test_result_of_imp<int (F::* (F const&&)) () const&&, int> (); +#endif +#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES + using type1 = std::result_of<decltype(&wat::foo)(wat)>::type; +#endif +#if _LIBCPP_STD_VER > 11 + using type2 = std::result_of_t<decltype(&wat::foo)(wat)>; +#endif + + + + static_assert((std::is_same<std::result_of<S(int)>::type, short>::value), "Error!"); + static_assert((std::is_same<std::result_of<S&(unsigned char, int&)>::type, double>::value), "Error!"); + static_assert((std::is_same<std::result_of<PF1()>::type, bool>::value), "Error!"); + static_assert((std::is_same<std::result_of<PMS(std::unique_ptr<S>, int)>::type, void>::value), "Error!"); + static_assert((std::is_same<std::result_of<PMS(S, int)>::type, void>::value), "Error!"); + static_assert((std::is_same<std::result_of<PMS(const S&, int)>::type, void>::value), "Error!"); +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + static_assert((std::is_same<std::result_of<PMD(S)>::type, char&&>::value), "Error!"); +#endif + static_assert((std::is_same<std::result_of<PMD(const S*)>::type, const char&>::value), "Error!"); +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + static_assert((std::is_same<std::result_of<int (F::* (F &)) () &>::type, int>::value), "Error!"); + static_assert((std::is_same<std::result_of<int (F::* (F &)) () const &>::type, int>::value), "Error!"); + static_assert((std::is_same<std::result_of<int (F::* (F const &)) () const &>::type, int>::value), "Error!"); + static_assert((std::is_same<std::result_of<int (F::* (F &&)) () &&>::type, int>::value), "Error!"); + static_assert((std::is_same<std::result_of<int (F::* (F &&)) () const&&>::type, int>::value), "Error!"); + static_assert((std::is_same<std::result_of<int (F::* (F const&&)) () const&&>::type, int>::value), "Error!"); +#endif +#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES + using type = std::result_of<decltype(&wat::foo)(wat)>::type; +#endif +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp new file mode 100644 index 00000000000..728062b7068 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// underlying_type + +#include <type_traits> +#include <climits> + +enum E { V = INT_MIN }; +enum F { W = UINT_MAX }; + +int main() +{ + static_assert((std::is_same<std::underlying_type<E>::type, int>::value), + "E has the wrong underlying type"); + static_assert((std::is_same<std::underlying_type<F>::type, unsigned>::value), + "F has the wrong underlying type"); + +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same<std::underlying_type_t<E>, int>::value), ""); + static_assert((std::is_same<std::underlying_type_t<F>, unsigned>::value), ""); +#endif + +#if __has_feature(cxx_strong_enums) + enum G : char { }; + + static_assert((std::is_same<std::underlying_type<G>::type, char>::value), + "G has the wrong underlying type"); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same<std::underlying_type_t<G>, char>::value), ""); +#endif +#endif // __has_feature(cxx_strong_enums) +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.ptr/add_pointer.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.ptr/add_pointer.pass.cpp new file mode 100644 index 00000000000..76d0f12d03f --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.ptr/add_pointer.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// add_pointer + +#include <type_traits> + +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 + static_assert((std::is_same<std::add_pointer_t<T>, U>::value), ""); +#endif +} + +int main() +{ + test_add_pointer<void, void*>(); + test_add_pointer<int, int*>(); + test_add_pointer<int[3], int(*)[3]>(); + test_add_pointer<int&, int*>(); + test_add_pointer<const int&, const int*>(); + test_add_pointer<int*, int**>(); + test_add_pointer<const int*, const int**>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.ptr/remove_pointer.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.ptr/remove_pointer.pass.cpp new file mode 100644 index 00000000000..9cecd39049f --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.ptr/remove_pointer.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// remove_pointer + +#include <type_traits> + +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 + static_assert((std::is_same<std::remove_pointer_t<T>, U>::value), ""); +#endif +} + +int main() +{ + test_remove_pointer<void, void>(); + test_remove_pointer<int, int>(); + test_remove_pointer<int[3], int[3]>(); + test_remove_pointer<int*, int>(); + test_remove_pointer<const int*, const int>(); + test_remove_pointer<int**, int*>(); + test_remove_pointer<int** const, int*>(); + test_remove_pointer<int*const * , int* const>(); + test_remove_pointer<const int** , const int*>(); + + test_remove_pointer<int&, int&>(); + test_remove_pointer<const int&, const int&>(); + test_remove_pointer<int(&)[3], int(&)[3]>(); + test_remove_pointer<int(*)[3], int[3]>(); + test_remove_pointer<int*&, int*&>(); + test_remove_pointer<const int*&, const int*&>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp new file mode 100644 index 00000000000..8150ce04e37 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// add_lvalue_reference + +#include <type_traits> + +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 + static_assert((std::is_same<std::add_lvalue_reference_t<T>, U>::value), ""); +#endif +} + +int main() +{ + test_add_lvalue_reference<void, void>(); + test_add_lvalue_reference<int, int&>(); + test_add_lvalue_reference<int[3], int(&)[3]>(); + test_add_lvalue_reference<int&, int&>(); + test_add_lvalue_reference<const int&, const int&>(); + test_add_lvalue_reference<int*, int*&>(); + test_add_lvalue_reference<const int*, const int*&>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.ref/add_rvalue_ref.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.ref/add_rvalue_ref.pass.cpp new file mode 100644 index 00000000000..e8f08fdc398 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.ref/add_rvalue_ref.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// add_rvalue_reference + +#include <type_traits> + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +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 + static_assert((std::is_same<std::add_rvalue_reference_t<T>, U>::value), ""); +#endif +} + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_add_rvalue_reference<void, void>(); + test_add_rvalue_reference<int, int&&>(); + test_add_rvalue_reference<int[3], int(&&)[3]>(); + test_add_rvalue_reference<int&, int&>(); + 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 +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.ref/remove_ref.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.ref/remove_ref.pass.cpp new file mode 100644 index 00000000000..f9ebc37a5dd --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.ref/remove_ref.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// remove_reference + +#include <type_traits> + +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 + static_assert((std::is_same<std::remove_reference_t<T>, U>::value), ""); +#endif +} + +int main() +{ + test_remove_reference<void, void>(); + test_remove_reference<int, int>(); + test_remove_reference<int[3], int[3]>(); + test_remove_reference<int*, int*>(); + test_remove_reference<const int*, const int*>(); + + test_remove_reference<int&, int>(); + test_remove_reference<const int&, const int>(); + test_remove_reference<int(&)[3], int[3]>(); + test_remove_reference<int*&, int*>(); + test_remove_reference<const int*&, const int*>(); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_remove_reference<int&&, int>(); + test_remove_reference<const int&&, const int>(); + test_remove_reference<int(&&)[3], int[3]>(); + test_remove_reference<int*&&, int*>(); + test_remove_reference<const int*&&, const int*>(); +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp new file mode 100644 index 00000000000..eb8e31c76e1 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp @@ -0,0 +1,64 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// make_signed + +#include <type_traits> + +enum Enum {zero, one_}; + +enum BigEnum +{ + bigzero, + big = 0xFFFFFFFFFFFFFFFFULL +}; + +#if !defined(_LIBCPP_HAS_NO_INT128) && !defined(_LIBCPP_HAS_NO_STRONG_ENUMS) +enum HugeEnum : __uint128_t +{ + hugezero +}; +#endif + +template <class T, class U> +void test_make_signed() +{ + static_assert((std::is_same<typename std::make_signed<T>::type, U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same<std::make_signed_t<T>, U>::value), ""); +#endif +} + +int main() +{ + test_make_signed< signed char, signed char >(); + test_make_signed< unsigned char, signed char >(); + test_make_signed< char, signed char >(); + test_make_signed< short, signed short >(); + test_make_signed< unsigned short, signed short >(); + test_make_signed< int, signed int >(); + test_make_signed< unsigned int, signed int >(); + test_make_signed< long, signed long >(); + test_make_signed< unsigned long, long >(); + test_make_signed< long long, signed long long >(); + test_make_signed< unsigned long long, signed long long >(); + test_make_signed< wchar_t, std::conditional<sizeof(wchar_t) == 4, int, short>::type >(); + test_make_signed< const wchar_t, std::conditional<sizeof(wchar_t) == 4, const int, const short>::type >(); + test_make_signed< const Enum, std::conditional<sizeof(Enum) == sizeof(int), const int, const signed char>::type >(); + test_make_signed< BigEnum, std::conditional<sizeof(long) == 4, long long, long>::type >(); +#ifndef _LIBCPP_HAS_NO_INT128 + test_make_signed< __int128_t, __int128_t >(); + test_make_signed< __uint128_t, __int128_t >(); +# ifndef _LIBCPP_HAS_NO_STRONG_ENUMS + test_make_signed< HugeEnum, __int128_t >(); +# endif +#endif +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp new file mode 100644 index 00000000000..984440193fa --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp @@ -0,0 +1,65 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// make_unsigned + +#include <type_traits> + +enum Enum {zero, one_}; + +enum BigEnum +{ + bigzero, + big = 0xFFFFFFFFFFFFFFFFULL +}; + +#if !defined(_LIBCPP_HAS_NO_INT128) && !defined(_LIBCPP_HAS_NO_STRONG_ENUMS) +enum HugeEnum : __int128_t +{ + hugezero +}; +#endif + +template <class T, class U> +void test_make_unsigned() +{ + static_assert((std::is_same<typename std::make_unsigned<T>::type, U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same<std::make_unsigned_t<T>, U>::value), ""); +#endif +} + +int main() +{ + test_make_unsigned<signed char, unsigned char> (); + test_make_unsigned<unsigned char, unsigned char> (); + test_make_unsigned<char, unsigned char> (); + test_make_unsigned<short, unsigned short> (); + test_make_unsigned<unsigned short, unsigned short> (); + test_make_unsigned<int, unsigned int> (); + test_make_unsigned<unsigned int, unsigned int> (); + test_make_unsigned<long, unsigned long> (); + test_make_unsigned<unsigned long, unsigned long> (); + test_make_unsigned<long long, unsigned long long> (); + test_make_unsigned<unsigned long long, unsigned long long> (); + test_make_unsigned<wchar_t, std::conditional<sizeof(wchar_t) == 4, unsigned int, unsigned short>::type> (); + test_make_unsigned<const wchar_t, std::conditional<sizeof(wchar_t) == 4, const unsigned int, const unsigned short>::type> (); + test_make_unsigned<const Enum, std::conditional<sizeof(Enum) == sizeof(int), const unsigned int, const unsigned char>::type >(); + test_make_unsigned<BigEnum, + std::conditional<sizeof(long) == 4, unsigned long long, unsigned long>::type> (); +#ifndef _LIBCPP_HAS_NO_INT128 + test_make_unsigned<__int128_t, __uint128_t>(); + test_make_unsigned<__uint128_t, __uint128_t>(); +# ifndef _LIBCPP_HAS_NO_STRONG_ENUMS + test_make_unsigned<HugeEnum, __uint128_t>(); +# endif +#endif +} diff --git a/libcxx/test/std/utilities/meta/meta.trans/nothing_to_do.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/std/utilities/meta/meta.type.synop/nothing_to_do.pass.cpp b/libcxx/test/std/utilities/meta/meta.type.synop/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.type.synop/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/std/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp new file mode 100644 index 00000000000..6ea1cac789e --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// alignment_of + +#include <type_traits> +#include <cstdint> + +template <class T, unsigned A> +void test_alignment_of() +{ + static_assert( std::alignment_of<T>::value == A, ""); + 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, ""); +} + +class Class +{ +public: + ~Class(); +}; + +int main() +{ + test_alignment_of<int&, 4>(); + test_alignment_of<Class, 1>(); + test_alignment_of<int*, sizeof(intptr_t)>(); + test_alignment_of<const int*, sizeof(intptr_t)>(); + test_alignment_of<char[3], 1>(); + test_alignment_of<int, 4>(); + test_alignment_of<double, 8>(); +#if (defined(__ppc__) && !defined(__ppc64__)) + test_alignment_of<bool, 4>(); // 32-bit PPC has four byte bool +#else + test_alignment_of<bool, 1>(); +#endif + test_alignment_of<unsigned, 4>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary.prop.query/extent.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary.prop.query/extent.pass.cpp new file mode 100644 index 00000000000..a99dc694852 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary.prop.query/extent.pass.cpp @@ -0,0 +1,60 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// extent + +#include <type_traits> + +template <class T, unsigned A> +void test_extent() +{ + static_assert((std::extent<T>::value == A), ""); + 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), ""); +} + +template <class T, unsigned A> +void test_extent1() +{ + static_assert((std::extent<T, 1>::value == A), ""); + 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), ""); +} + +class Class +{ +public: + ~Class(); +}; + +int main() +{ + test_extent<void, 0>(); + test_extent<int&, 0>(); + test_extent<Class, 0>(); + test_extent<int*, 0>(); + test_extent<const int*, 0>(); + test_extent<int, 0>(); + test_extent<double, 0>(); + test_extent<bool, 0>(); + test_extent<unsigned, 0>(); + + test_extent<int[2], 2>(); + test_extent<int[2][4], 2>(); + test_extent<int[][4], 0>(); + + test_extent1<int, 0>(); + test_extent1<int[2], 0>(); + test_extent1<int[2][4], 4>(); + test_extent1<int[][4], 4>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary.prop.query/rank.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary.prop.query/rank.pass.cpp new file mode 100644 index 00000000000..06f66a92c7c --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary.prop.query/rank.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// rank + +#include <type_traits> + +template <class T, unsigned A> +void test_rank() +{ + static_assert( std::rank<T>::value == A, ""); + 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, ""); +} + +class Class +{ +public: + ~Class(); +}; + +int main() +{ + test_rank<void, 0>(); + test_rank<int&, 0>(); + test_rank<Class, 0>(); + test_rank<int*, 0>(); + test_rank<const int*, 0>(); + test_rank<int, 0>(); + test_rank<double, 0>(); + test_rank<bool, 0>(); + test_rank<unsigned, 0>(); + + test_rank<char[3], 1>(); + test_rank<char[][3], 2>(); + test_rank<char[][4][3], 3>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp new file mode 100644 index 00000000000..1f99a74d9b6 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// void_t + +#include <type_traits> + +#if _LIBCPP_STD_VER <= 14 +int main () {} +#else + +template <class T> +void test1() +{ + static_assert( std::is_same<void, std::void_t<T>>::value, ""); + static_assert( std::is_same<void, std::void_t<const T>>::value, ""); + static_assert( std::is_same<void, std::void_t<volatile T>>::value, ""); + static_assert( std::is_same<void, std::void_t<const volatile T>>::value, ""); +} + +template <class T, class U> +void test2() +{ + static_assert( std::is_same<void, std::void_t<T, U>>::value, ""); + static_assert( std::is_same<void, std::void_t<const T, U>>::value, ""); + static_assert( std::is_same<void, std::void_t<volatile T, U>>::value, ""); + static_assert( std::is_same<void, std::void_t<const volatile T, U>>::value, ""); + + static_assert( std::is_same<void, std::void_t<T, const U>>::value, ""); + static_assert( std::is_same<void, std::void_t<const T, const U>>::value, ""); + static_assert( std::is_same<void, std::void_t<volatile T, const U>>::value, ""); + static_assert( std::is_same<void, std::void_t<const volatile T, const U>>::value, ""); +} + +class Class +{ +public: + ~Class(); +}; + +int main() +{ + static_assert( std::is_same<void, std::void_t<>>::value, ""); + + test1<void>(); + test1<int>(); + test1<double>(); + test1<int&>(); + test1<Class>(); + test1<Class[]>(); + test1<Class[5]>(); + + test2<void, int>(); + test2<double, int>(); + test2<int&, int>(); + test2<Class&, bool>(); + test2<void *, int&>(); + + static_assert( std::is_same<void, std::void_t<int, double const &, Class, volatile int[], void>>::value, ""); +} +#endif diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp new file mode 100644 index 00000000000..f4dd356383a --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp @@ -0,0 +1,55 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// array + +#include <type_traits> + +template <class T> +void test_array_imp() +{ + static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif + static_assert(!std::is_integral<T>::value, ""); + static_assert(!std::is_floating_point<T>::value, ""); + static_assert( std::is_array<T>::value, ""); + static_assert(!std::is_pointer<T>::value, ""); + static_assert(!std::is_lvalue_reference<T>::value, ""); + static_assert(!std::is_rvalue_reference<T>::value, ""); + static_assert(!std::is_member_object_pointer<T>::value, ""); + static_assert(!std::is_member_function_pointer<T>::value, ""); + static_assert(!std::is_enum<T>::value, ""); + static_assert(!std::is_union<T>::value, ""); + static_assert(!std::is_class<T>::value, ""); + static_assert(!std::is_function<T>::value, ""); +} + +template <class T> +void test_array() +{ + test_array_imp<T>(); + test_array_imp<const T>(); + test_array_imp<volatile T>(); + test_array_imp<const volatile T>(); +} + +typedef char array[3]; +typedef const char const_array[3]; +typedef char incomplete_array[]; + +int main() +{ + test_array<array>(); + test_array<const_array>(); + test_array<incomplete_array>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp new file mode 100644 index 00000000000..0de00485572 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp @@ -0,0 +1,55 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// class + +#include <type_traits> + +template <class T> +void test_class_imp() +{ + static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif + static_assert(!std::is_integral<T>::value, ""); + static_assert(!std::is_floating_point<T>::value, ""); + static_assert(!std::is_array<T>::value, ""); + static_assert(!std::is_pointer<T>::value, ""); + static_assert(!std::is_lvalue_reference<T>::value, ""); + static_assert(!std::is_rvalue_reference<T>::value, ""); + static_assert(!std::is_member_object_pointer<T>::value, ""); + static_assert(!std::is_member_function_pointer<T>::value, ""); + static_assert(!std::is_enum<T>::value, ""); + static_assert(!std::is_union<T>::value, ""); + static_assert( std::is_class<T>::value, ""); + static_assert(!std::is_function<T>::value, ""); +} + +template <class T> +void test_class() +{ + test_class_imp<T>(); + test_class_imp<const T>(); + test_class_imp<volatile T>(); + test_class_imp<const volatile T>(); +} + +class Class +{ + int _; + double __; +}; + +int main() +{ + test_class<Class>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp new file mode 100644 index 00000000000..7c9c78fcf2b --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// enum + +#include <type_traits> + +template <class T> +void test_enum_imp() +{ + static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif + static_assert(!std::is_integral<T>::value, ""); + static_assert(!std::is_floating_point<T>::value, ""); + static_assert(!std::is_array<T>::value, ""); + static_assert(!std::is_pointer<T>::value, ""); + static_assert(!std::is_lvalue_reference<T>::value, ""); + static_assert(!std::is_rvalue_reference<T>::value, ""); + static_assert(!std::is_member_object_pointer<T>::value, ""); + static_assert(!std::is_member_function_pointer<T>::value, ""); + static_assert( std::is_enum<T>::value, ""); + static_assert(!std::is_union<T>::value, ""); + static_assert(!std::is_class<T>::value, ""); + static_assert(!std::is_function<T>::value, ""); +} + +template <class T> +void test_enum() +{ + test_enum_imp<T>(); + test_enum_imp<const T>(); + test_enum_imp<volatile T>(); + test_enum_imp<const volatile T>(); +} + +enum Enum {zero, one}; + +int main() +{ + test_enum<Enum>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp new file mode 100644 index 00000000000..28664496031 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// floating_point + +#include <type_traits> + +template <class T> +void test_floating_point_imp() +{ + static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif + static_assert(!std::is_integral<T>::value, ""); + static_assert( std::is_floating_point<T>::value, ""); + static_assert(!std::is_array<T>::value, ""); + static_assert(!std::is_pointer<T>::value, ""); + static_assert(!std::is_lvalue_reference<T>::value, ""); + static_assert(!std::is_rvalue_reference<T>::value, ""); + static_assert(!std::is_member_object_pointer<T>::value, ""); + static_assert(!std::is_member_function_pointer<T>::value, ""); + static_assert(!std::is_enum<T>::value, ""); + static_assert(!std::is_union<T>::value, ""); + static_assert(!std::is_class<T>::value, ""); + static_assert(!std::is_function<T>::value, ""); +} + +template <class T> +void test_floating_point() +{ + test_floating_point_imp<T>(); + test_floating_point_imp<const T>(); + test_floating_point_imp<volatile T>(); + test_floating_point_imp<const volatile T>(); +} + +int main() +{ + test_floating_point<float>(); + test_floating_point<double>(); + test_floating_point<long double>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp new file mode 100644 index 00000000000..82757f5035b --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// function + +#include <type_traits> + +template <class T> +void test_function_imp() +{ + static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif + static_assert(!std::is_integral<T>::value, ""); + static_assert(!std::is_floating_point<T>::value, ""); + static_assert(!std::is_array<T>::value, ""); + static_assert(!std::is_pointer<T>::value, ""); + static_assert(!std::is_lvalue_reference<T>::value, ""); + static_assert(!std::is_rvalue_reference<T>::value, ""); + static_assert(!std::is_member_object_pointer<T>::value, ""); + static_assert(!std::is_member_function_pointer<T>::value, ""); + static_assert(!std::is_enum<T>::value, ""); + static_assert(!std::is_union<T>::value, ""); + static_assert(!std::is_class<T>::value, ""); + static_assert( std::is_function<T>::value, ""); +} + +template <class T> +void test_function() +{ + test_function_imp<T>(); + test_function_imp<const T>(); + test_function_imp<volatile T>(); + test_function_imp<const volatile T>(); +} + +int main() +{ + test_function<void ()>(); + test_function<void (int)>(); + test_function<int (double)>(); + test_function<int (double, char)>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp new file mode 100644 index 00000000000..f68ed3ef7e5 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp @@ -0,0 +1,65 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// integral + +#include <type_traits> + +template <class T> +void test_integral_imp() +{ + static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif + static_assert( std::is_integral<T>::value, ""); + static_assert(!std::is_floating_point<T>::value, ""); + static_assert(!std::is_array<T>::value, ""); + static_assert(!std::is_pointer<T>::value, ""); + static_assert(!std::is_lvalue_reference<T>::value, ""); + static_assert(!std::is_rvalue_reference<T>::value, ""); + static_assert(!std::is_member_object_pointer<T>::value, ""); + static_assert(!std::is_member_function_pointer<T>::value, ""); + static_assert(!std::is_enum<T>::value, ""); + static_assert(!std::is_union<T>::value, ""); + static_assert(!std::is_class<T>::value, ""); + static_assert(!std::is_function<T>::value, ""); +} + +template <class T> +void test_integral() +{ + test_integral_imp<T>(); + test_integral_imp<const T>(); + test_integral_imp<volatile T>(); + test_integral_imp<const volatile T>(); +} + +int main() +{ + test_integral<bool>(); + test_integral<char>(); + test_integral<signed char>(); + test_integral<unsigned char>(); + test_integral<wchar_t>(); + test_integral<short>(); + test_integral<unsigned short>(); + test_integral<int>(); + test_integral<unsigned int>(); + test_integral<long>(); + test_integral<unsigned long>(); + test_integral<long long>(); + test_integral<unsigned long long>(); +#ifndef _LIBCPP_HAS_NO_INT128 + test_integral<__int128_t>(); + test_integral<__uint128_t>(); +#endif +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp new file mode 100644 index 00000000000..3b6ccade7e7 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// lvalue_ref + +#include <type_traits> + +template <class T> +void test_lvalue_ref() +{ + static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif + static_assert(!std::is_integral<T>::value, ""); + static_assert(!std::is_floating_point<T>::value, ""); + static_assert(!std::is_array<T>::value, ""); + static_assert(!std::is_pointer<T>::value, ""); + static_assert( std::is_lvalue_reference<T>::value, ""); + static_assert(!std::is_rvalue_reference<T>::value, ""); + static_assert(!std::is_member_object_pointer<T>::value, ""); + static_assert(!std::is_member_function_pointer<T>::value, ""); + static_assert(!std::is_enum<T>::value, ""); + static_assert(!std::is_union<T>::value, ""); + static_assert(!std::is_class<T>::value, ""); + static_assert(!std::is_function<T>::value, ""); +} + +int main() +{ + test_lvalue_ref<int&>(); + test_lvalue_ref<const int&>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp new file mode 100644 index 00000000000..67ef3db2b71 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp @@ -0,0 +1,102 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// member_function_pointer + +#include <type_traits> + +template <class T> +void test_member_function_pointer_imp() +{ + static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif + static_assert(!std::is_integral<T>::value, ""); + static_assert(!std::is_floating_point<T>::value, ""); + static_assert(!std::is_array<T>::value, ""); + static_assert(!std::is_pointer<T>::value, ""); + static_assert(!std::is_lvalue_reference<T>::value, ""); + static_assert(!std::is_rvalue_reference<T>::value, ""); + static_assert(!std::is_member_object_pointer<T>::value, ""); + static_assert( std::is_member_function_pointer<T>::value, ""); + static_assert(!std::is_enum<T>::value, ""); + static_assert(!std::is_union<T>::value, ""); + static_assert(!std::is_class<T>::value, ""); + static_assert(!std::is_function<T>::value, ""); +} + +template <class T> +void test_member_function_pointer() +{ + test_member_function_pointer_imp<T>(); + test_member_function_pointer_imp<const T>(); + test_member_function_pointer_imp<volatile T>(); + test_member_function_pointer_imp<const volatile T>(); +} + +class Class +{ +}; + +int main() +{ + test_member_function_pointer<void (Class::*)()>(); + test_member_function_pointer<void (Class::*)(int)>(); + test_member_function_pointer<void (Class::*)(int, char)>(); + + test_member_function_pointer<void (Class::*)() const>(); + test_member_function_pointer<void (Class::*)(int) const>(); + test_member_function_pointer<void (Class::*)(int, char) const>(); + + test_member_function_pointer<void (Class::*)() volatile>(); + test_member_function_pointer<void (Class::*)(int) volatile>(); + test_member_function_pointer<void (Class::*)(int, char) volatile>(); + + test_member_function_pointer<void (Class::*)(...)>(); + test_member_function_pointer<void (Class::*)(int, ...)>(); + test_member_function_pointer<void (Class::*)(int, char, ...)>(); + + test_member_function_pointer<void (Class::*)(...) const>(); + test_member_function_pointer<void (Class::*)(int, ...) const>(); + test_member_function_pointer<void (Class::*)(int, char, ...) const>(); + + test_member_function_pointer<void (Class::*)(...) volatile>(); + test_member_function_pointer<void (Class::*)(int, ...) volatile>(); + test_member_function_pointer<void (Class::*)(int, char, ...) volatile>(); + +#if __cplusplus >= 201103L +// reference qualifiers on functions are a C++11 extension + test_member_function_pointer<void (Class::*)() &&>(); + test_member_function_pointer<void (Class::*)(int) &&>(); + test_member_function_pointer<void (Class::*)(int, char) &&>(); + + test_member_function_pointer<void (Class::*)() &>(); + test_member_function_pointer<void (Class::*)(int) &>(); + test_member_function_pointer<void (Class::*)(int, char) &>(); + + test_member_function_pointer<void (Class::*)() volatile &&>(); + test_member_function_pointer<void (Class::*)(int) volatile &&>(); + test_member_function_pointer<void (Class::*)(int, char) volatile &&>(); + + test_member_function_pointer<void (Class::*)(...) &&>(); + test_member_function_pointer<void (Class::*)(int,...) &&>(); + test_member_function_pointer<void (Class::*)(int, char,...) &&>(); + + test_member_function_pointer<void (Class::*)(...) &>(); + test_member_function_pointer<void (Class::*)(int,...) &>(); + test_member_function_pointer<void (Class::*)(int, char,...) &>(); + + test_member_function_pointer<void (Class::*)(...) volatile &&>(); + test_member_function_pointer<void (Class::*)(int,...) volatile &&>(); + test_member_function_pointer<void (Class::*)(int, char,...) volatile &&>(); +#endif +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer_no_variadics.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer_no_variadics.pass.cpp new file mode 100644 index 00000000000..e13e58632a3 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer_no_variadics.pass.cpp @@ -0,0 +1,76 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// member_function_pointer + +#define _LIBCPP_HAS_NO_VARIADICS +#include <type_traits> + +template <class T> +void test_member_function_pointer_imp() +{ + static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif + static_assert(!std::is_integral<T>::value, ""); + static_assert(!std::is_floating_point<T>::value, ""); + static_assert(!std::is_array<T>::value, ""); + static_assert(!std::is_pointer<T>::value, ""); + static_assert(!std::is_lvalue_reference<T>::value, ""); + static_assert(!std::is_rvalue_reference<T>::value, ""); + static_assert(!std::is_member_object_pointer<T>::value, ""); + static_assert( std::is_member_function_pointer<T>::value, ""); + static_assert(!std::is_enum<T>::value, ""); + static_assert(!std::is_union<T>::value, ""); + static_assert(!std::is_class<T>::value, ""); + static_assert(!std::is_function<T>::value, ""); +} + +template <class T> +void test_member_function_pointer() +{ + test_member_function_pointer_imp<T>(); + test_member_function_pointer_imp<const T>(); + test_member_function_pointer_imp<volatile T>(); + test_member_function_pointer_imp<const volatile T>(); +} + +class Class +{ +}; + +int main() +{ + test_member_function_pointer<void (Class::*)()>(); + test_member_function_pointer<void (Class::*)(int)>(); + test_member_function_pointer<void (Class::*)(int, char)>(); + + test_member_function_pointer<void (Class::*)() const>(); + test_member_function_pointer<void (Class::*)(int) const>(); + test_member_function_pointer<void (Class::*)(int, char) const>(); + + test_member_function_pointer<void (Class::*)() volatile>(); + test_member_function_pointer<void (Class::*)(int) volatile>(); + test_member_function_pointer<void (Class::*)(int, char) volatile>(); + + test_member_function_pointer<void (Class::*)(...)>(); + test_member_function_pointer<void (Class::*)(int, ...)>(); + test_member_function_pointer<void (Class::*)(int, char, ...)>(); + + test_member_function_pointer<void (Class::*)(...) const>(); + test_member_function_pointer<void (Class::*)(int, ...) const>(); + test_member_function_pointer<void (Class::*)(int, char, ...) const>(); + + test_member_function_pointer<void (Class::*)(...) volatile>(); + test_member_function_pointer<void (Class::*)(int, ...) volatile>(); + test_member_function_pointer<void (Class::*)(int, char, ...) volatile>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp new file mode 100644 index 00000000000..4e6699cc3e7 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// member_object_pointer + +#include <type_traits> + +template <class T> +void test_member_object_pointer_imp() +{ + static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif + static_assert(!std::is_integral<T>::value, ""); + static_assert(!std::is_floating_point<T>::value, ""); + static_assert(!std::is_array<T>::value, ""); + static_assert(!std::is_pointer<T>::value, ""); + static_assert(!std::is_lvalue_reference<T>::value, ""); + static_assert(!std::is_rvalue_reference<T>::value, ""); + static_assert( std::is_member_object_pointer<T>::value, ""); + static_assert(!std::is_member_function_pointer<T>::value, ""); + static_assert(!std::is_enum<T>::value, ""); + static_assert(!std::is_union<T>::value, ""); + static_assert(!std::is_class<T>::value, ""); + static_assert(!std::is_function<T>::value, ""); +} + +template <class T> +void test_member_object_pointer() +{ + test_member_object_pointer_imp<T>(); + test_member_object_pointer_imp<const T>(); + test_member_object_pointer_imp<volatile T>(); + test_member_object_pointer_imp<const volatile T>(); +} + +class Class +{ +}; + +int main() +{ + test_member_object_pointer<int Class::*>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp new file mode 100644 index 00000000000..691e3536167 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// nullptr_t +// is_null_pointer + +#include <type_traits> + +#if _LIBCPP_STD_VER > 11 +template <class T> +void test_nullptr_imp() +{ + static_assert(!std::is_void<T>::value, ""); + static_assert( std::is_null_pointer<T>::value, ""); + static_assert(!std::is_integral<T>::value, ""); + static_assert(!std::is_floating_point<T>::value, ""); + static_assert(!std::is_array<T>::value, ""); + static_assert(!std::is_pointer<T>::value, ""); + static_assert(!std::is_lvalue_reference<T>::value, ""); + static_assert(!std::is_rvalue_reference<T>::value, ""); + static_assert(!std::is_member_object_pointer<T>::value, ""); + static_assert(!std::is_member_function_pointer<T>::value, ""); + static_assert(!std::is_enum<T>::value, ""); + static_assert(!std::is_union<T>::value, ""); + static_assert(!std::is_class<T>::value, ""); + static_assert(!std::is_function<T>::value, ""); +} + +template <class T> +void test_nullptr() +{ + test_nullptr_imp<T>(); + test_nullptr_imp<const T>(); + test_nullptr_imp<volatile T>(); + test_nullptr_imp<const volatile T>(); +} + +int main() +{ + test_nullptr<std::nullptr_t>(); +} +#else +int main() {} +#endif diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp new file mode 100644 index 00000000000..7073c106b44 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// pointer + +#include <type_traits> + +template <class T> +void test_pointer_imp() +{ + static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif + static_assert(!std::is_integral<T>::value, ""); + static_assert(!std::is_floating_point<T>::value, ""); + static_assert(!std::is_array<T>::value, ""); + static_assert( std::is_pointer<T>::value, ""); + static_assert(!std::is_lvalue_reference<T>::value, ""); + static_assert(!std::is_rvalue_reference<T>::value, ""); + static_assert(!std::is_member_object_pointer<T>::value, ""); + static_assert(!std::is_member_function_pointer<T>::value, ""); + static_assert(!std::is_enum<T>::value, ""); + static_assert(!std::is_union<T>::value, ""); + static_assert(!std::is_class<T>::value, ""); + static_assert(!std::is_function<T>::value, ""); +} + +template <class T> +void test_pointer() +{ + test_pointer_imp<T>(); + test_pointer_imp<const T>(); + test_pointer_imp<volatile T>(); + test_pointer_imp<const volatile T>(); +} + +int main() +{ + test_pointer<void*>(); + test_pointer<int*>(); + test_pointer<const int*>(); + test_pointer<void (*)(int)>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp new file mode 100644 index 00000000000..79644240363 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// rvalue_ref + +#include <type_traits> + +template <class T> +void test_rvalue_ref() +{ + static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif + static_assert(!std::is_integral<T>::value, ""); + static_assert(!std::is_floating_point<T>::value, ""); + static_assert(!std::is_array<T>::value, ""); + static_assert(!std::is_pointer<T>::value, ""); + static_assert(!std::is_lvalue_reference<T>::value, ""); + static_assert( std::is_rvalue_reference<T>::value, ""); + static_assert(!std::is_member_object_pointer<T>::value, ""); + static_assert(!std::is_member_function_pointer<T>::value, ""); + static_assert(!std::is_enum<T>::value, ""); + static_assert(!std::is_union<T>::value, ""); + static_assert(!std::is_class<T>::value, ""); + static_assert(!std::is_function<T>::value, ""); +} + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_rvalue_ref<int&&>(); + test_rvalue_ref<const int&&>(); +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp new file mode 100644 index 00000000000..6cabb717c0c --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp @@ -0,0 +1,55 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// union + +#include <type_traits> + +template <class T> +void test_union_imp() +{ + static_assert(!std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif + static_assert(!std::is_integral<T>::value, ""); + static_assert(!std::is_floating_point<T>::value, ""); + static_assert(!std::is_array<T>::value, ""); + static_assert(!std::is_pointer<T>::value, ""); + static_assert(!std::is_lvalue_reference<T>::value, ""); + static_assert(!std::is_rvalue_reference<T>::value, ""); + static_assert(!std::is_member_object_pointer<T>::value, ""); + static_assert(!std::is_member_function_pointer<T>::value, ""); + static_assert(!std::is_enum<T>::value, ""); + static_assert( std::is_union<T>::value, ""); + static_assert(!std::is_class<T>::value, ""); + static_assert(!std::is_function<T>::value, ""); +} + +template <class T> +void test_union() +{ + test_union_imp<T>(); + test_union_imp<const T>(); + test_union_imp<volatile T>(); + test_union_imp<const volatile T>(); +} + +union Union +{ + int _; + double __; +}; + +int main() +{ + test_union<Union>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp new file mode 100644 index 00000000000..f20bcf87ea1 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp @@ -0,0 +1,49 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// void + +#include <type_traits> + +template <class T> +void test_void_imp() +{ + static_assert( std::is_void<T>::value, ""); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_null_pointer<T>::value, ""); +#endif + static_assert(!std::is_integral<T>::value, ""); + static_assert(!std::is_floating_point<T>::value, ""); + static_assert(!std::is_array<T>::value, ""); + static_assert(!std::is_pointer<T>::value, ""); + static_assert(!std::is_lvalue_reference<T>::value, ""); + static_assert(!std::is_rvalue_reference<T>::value, ""); + static_assert(!std::is_member_object_pointer<T>::value, ""); + static_assert(!std::is_member_function_pointer<T>::value, ""); + static_assert(!std::is_enum<T>::value, ""); + static_assert(!std::is_union<T>::value, ""); + static_assert(!std::is_class<T>::value, ""); + static_assert(!std::is_function<T>::value, ""); +} + +template <class T> +void test_void() +{ + test_void_imp<T>(); + test_void_imp<const T>(); + test_void_imp<volatile T>(); + test_void_imp<const volatile T>(); +} + +int main() +{ + test_void<void>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/array.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/array.pass.cpp new file mode 100644 index 00000000000..3476d5ceea2 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/array.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// array + +#include <type_traits> + +template <class T> +void test_array_imp() +{ + static_assert(!std::is_reference<T>::value, ""); + static_assert(!std::is_arithmetic<T>::value, ""); + static_assert(!std::is_fundamental<T>::value, ""); + static_assert( std::is_object<T>::value, ""); + static_assert(!std::is_scalar<T>::value, ""); + static_assert( std::is_compound<T>::value, ""); + static_assert(!std::is_member_pointer<T>::value, ""); +} + +template <class T> +void test_array() +{ + test_array_imp<T>(); + test_array_imp<const T>(); + test_array_imp<volatile T>(); + test_array_imp<const volatile T>(); +} + +typedef char array[3]; +typedef const char const_array[3]; +typedef char incomplete_array[]; + +int main() +{ + test_array<array>(); + test_array<const_array>(); + test_array<incomplete_array>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/class.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/class.pass.cpp new file mode 100644 index 00000000000..a77a10149d3 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/class.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// class + +#include <type_traits> + +template <class T> +void test_class_imp() +{ + static_assert(!std::is_reference<T>::value, ""); + static_assert(!std::is_arithmetic<T>::value, ""); + static_assert(!std::is_fundamental<T>::value, ""); + static_assert( std::is_object<T>::value, ""); + static_assert(!std::is_scalar<T>::value, ""); + static_assert( std::is_compound<T>::value, ""); + static_assert(!std::is_member_pointer<T>::value, ""); +} + +template <class T> +void test_class() +{ + test_class_imp<T>(); + test_class_imp<const T>(); + test_class_imp<volatile T>(); + test_class_imp<const volatile T>(); +} + +class Class +{ + int _; + double __; +}; + +int main() +{ + test_class<Class>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/enum.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/enum.pass.cpp new file mode 100644 index 00000000000..dc9e4874ab1 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/enum.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// enum + +#include <type_traits> + +template <class T> +void test_enum_imp() +{ + static_assert(!std::is_reference<T>::value, ""); + static_assert(!std::is_arithmetic<T>::value, ""); + static_assert(!std::is_fundamental<T>::value, ""); + static_assert( std::is_object<T>::value, ""); + static_assert( std::is_scalar<T>::value, ""); + static_assert( std::is_compound<T>::value, ""); + static_assert(!std::is_member_pointer<T>::value, ""); +} + +template <class T> +void test_enum() +{ + test_enum_imp<T>(); + test_enum_imp<const T>(); + test_enum_imp<volatile T>(); + test_enum_imp<const volatile T>(); +} + +enum Enum {zero, one}; + +int main() +{ + test_enum<Enum>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/floating_point.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/floating_point.pass.cpp new file mode 100644 index 00000000000..3560b456b00 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/floating_point.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// floating_point + +#include <type_traits> + +template <class T> +void test_floating_point_imp() +{ + static_assert(!std::is_reference<T>::value, ""); + static_assert( std::is_arithmetic<T>::value, ""); + static_assert( std::is_fundamental<T>::value, ""); + static_assert( std::is_object<T>::value, ""); + static_assert( std::is_scalar<T>::value, ""); + static_assert(!std::is_compound<T>::value, ""); + static_assert(!std::is_member_pointer<T>::value, ""); +} + +template <class T> +void test_floating_point() +{ + test_floating_point_imp<T>(); + test_floating_point_imp<const T>(); + test_floating_point_imp<volatile T>(); + test_floating_point_imp<const volatile T>(); +} + +int main() +{ + test_floating_point<float>(); + test_floating_point<double>(); + test_floating_point<long double>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/function.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/function.pass.cpp new file mode 100644 index 00000000000..fc8a1e5a8b2 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/function.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// function + +#include <type_traits> + +template <class T> +void test_function_imp() +{ + static_assert(!std::is_reference<T>::value, ""); + static_assert(!std::is_arithmetic<T>::value, ""); + static_assert(!std::is_fundamental<T>::value, ""); + static_assert(!std::is_object<T>::value, ""); + static_assert(!std::is_scalar<T>::value, ""); + static_assert( std::is_compound<T>::value, ""); + static_assert(!std::is_member_pointer<T>::value, ""); +} + +template <class T> +void test_function() +{ + test_function_imp<T>(); + test_function_imp<const T>(); + test_function_imp<volatile T>(); + test_function_imp<const volatile T>(); +} + +int main() +{ + test_function<void ()>(); + test_function<void (int)>(); + test_function<int (double)>(); + test_function<int (double, char)>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/integral.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/integral.pass.cpp new file mode 100644 index 00000000000..0bc94583ab0 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/integral.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// integral + +#include <type_traits> + +template <class T> +void test_integral_imp() +{ + static_assert(!std::is_reference<T>::value, ""); + static_assert( std::is_arithmetic<T>::value, ""); + static_assert( std::is_fundamental<T>::value, ""); + static_assert( std::is_object<T>::value, ""); + static_assert( std::is_scalar<T>::value, ""); + static_assert(!std::is_compound<T>::value, ""); + static_assert(!std::is_member_pointer<T>::value, ""); +} + +template <class T> +void test_integral() +{ + test_integral_imp<T>(); + test_integral_imp<const T>(); + test_integral_imp<volatile T>(); + test_integral_imp<const volatile T>(); +} + +int main() +{ + test_integral<bool>(); + test_integral<char>(); + test_integral<signed char>(); + test_integral<unsigned char>(); + test_integral<wchar_t>(); + test_integral<short>(); + test_integral<unsigned short>(); + test_integral<int>(); + test_integral<unsigned int>(); + test_integral<long>(); + test_integral<unsigned long>(); + test_integral<long long>(); + test_integral<unsigned long long>(); +#ifndef _LIBCPP_HAS_NO_INT128 + test_integral<__int128_t>(); + test_integral<__uint128_t>(); +#endif +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/lvalue_ref.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/lvalue_ref.pass.cpp new file mode 100644 index 00000000000..dd812832f6c --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/lvalue_ref.pass.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// lvalue_ref + +#include <type_traits> + +template <class T> +void test_lvalue_ref() +{ + static_assert( std::is_reference<T>::value, ""); + static_assert(!std::is_arithmetic<T>::value, ""); + static_assert(!std::is_fundamental<T>::value, ""); + static_assert(!std::is_object<T>::value, ""); + static_assert(!std::is_scalar<T>::value, ""); + static_assert( std::is_compound<T>::value, ""); + static_assert(!std::is_member_pointer<T>::value, ""); +} + +int main() +{ + test_lvalue_ref<int&>(); + test_lvalue_ref<const int&>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/member_function_pointer.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/member_function_pointer.pass.cpp new file mode 100644 index 00000000000..0df21173c69 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/member_function_pointer.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// member_function_pointer + +#include <type_traits> + +template <class T> +void test_member_function_pointer_imp() +{ + static_assert(!std::is_reference<T>::value, ""); + static_assert(!std::is_arithmetic<T>::value, ""); + static_assert(!std::is_fundamental<T>::value, ""); + static_assert( std::is_object<T>::value, ""); + static_assert( std::is_scalar<T>::value, ""); + static_assert( std::is_compound<T>::value, ""); + static_assert( std::is_member_pointer<T>::value, ""); +} + +template <class T> +void test_member_function_pointer() +{ + test_member_function_pointer_imp<T>(); + test_member_function_pointer_imp<const T>(); + test_member_function_pointer_imp<volatile T>(); + test_member_function_pointer_imp<const volatile T>(); +} + +class Class +{ +}; + +int main() +{ + test_member_function_pointer<void (Class::*)()>(); + test_member_function_pointer<void (Class::*)(int)>(); + test_member_function_pointer<void (Class::*)(int, char)>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/member_object_pointer.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/member_object_pointer.pass.cpp new file mode 100644 index 00000000000..a0dea4a9c44 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/member_object_pointer.pass.cpp @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// member_object_pointer + +#include <type_traits> + +template <class T> +void test_member_object_pointer_imp() +{ + static_assert(!std::is_reference<T>::value, ""); + static_assert(!std::is_arithmetic<T>::value, ""); + static_assert(!std::is_fundamental<T>::value, ""); + static_assert( std::is_object<T>::value, ""); + static_assert( std::is_scalar<T>::value, ""); + static_assert( std::is_compound<T>::value, ""); + static_assert( std::is_member_pointer<T>::value, ""); +} + +template <class T> +void test_member_object_pointer() +{ + test_member_object_pointer_imp<T>(); + test_member_object_pointer_imp<const T>(); + test_member_object_pointer_imp<volatile T>(); + test_member_object_pointer_imp<const volatile T>(); +} + +class Class +{ +}; + +int main() +{ + test_member_object_pointer<int Class::*>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/pointer.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/pointer.pass.cpp new file mode 100644 index 00000000000..de23da83637 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/pointer.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// pointer + +#include <type_traits> + +template <class T> +void test_pointer_imp() +{ + static_assert(!std::is_reference<T>::value, ""); + static_assert(!std::is_arithmetic<T>::value, ""); + static_assert(!std::is_fundamental<T>::value, ""); + static_assert( std::is_object<T>::value, ""); + static_assert( std::is_scalar<T>::value, ""); + static_assert( std::is_compound<T>::value, ""); + static_assert(!std::is_member_pointer<T>::value, ""); +} + +template <class T> +void test_pointer() +{ + test_pointer_imp<T>(); + test_pointer_imp<const T>(); + test_pointer_imp<volatile T>(); + test_pointer_imp<const volatile T>(); +} + +int main() +{ + test_pointer<void*>(); + test_pointer<int*>(); + test_pointer<const int*>(); + test_pointer<void (*)(int)>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/rvalue_ref.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/rvalue_ref.pass.cpp new file mode 100644 index 00000000000..7563c2fd585 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/rvalue_ref.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// rvalue_ref + +#include <type_traits> + +template <class T> +void test_rvalue_ref() +{ + static_assert( std::is_reference<T>::value, ""); + static_assert(!std::is_arithmetic<T>::value, ""); + static_assert(!std::is_fundamental<T>::value, ""); + static_assert(!std::is_object<T>::value, ""); + static_assert(!std::is_scalar<T>::value, ""); + static_assert( std::is_compound<T>::value, ""); + static_assert(!std::is_member_pointer<T>::value, ""); +} + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_rvalue_ref<int&&>(); + test_rvalue_ref<const int&&>(); +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/union.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/union.pass.cpp new file mode 100644 index 00000000000..05db74c8aaf --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/union.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// union + +#include <type_traits> + +template <class T> +void test_union_imp() +{ + static_assert(!std::is_reference<T>::value, ""); + static_assert(!std::is_arithmetic<T>::value, ""); + static_assert(!std::is_fundamental<T>::value, ""); + static_assert( std::is_object<T>::value, ""); + static_assert(!std::is_scalar<T>::value, ""); + static_assert( std::is_compound<T>::value, ""); + static_assert(!std::is_member_pointer<T>::value, ""); +} + +template <class T> +void test_union() +{ + test_union_imp<T>(); + test_union_imp<const T>(); + test_union_imp<volatile T>(); + test_union_imp<const volatile T>(); +} + +union Union +{ + int _; + double __; +}; + +int main() +{ + test_union<Union>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/void.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/void.pass.cpp new file mode 100644 index 00000000000..59569fe086b --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/void.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// void + +#include <type_traits> + +template <class T> +void test_void_imp() +{ + static_assert(!std::is_reference<T>::value, ""); + static_assert(!std::is_arithmetic<T>::value, ""); + static_assert( std::is_fundamental<T>::value, ""); + static_assert(!std::is_object<T>::value, ""); + static_assert(!std::is_scalar<T>::value, ""); + static_assert(!std::is_compound<T>::value, ""); + static_assert(!std::is_member_pointer<T>::value, ""); +} + +template <class T> +void test_void() +{ + test_void_imp<T>(); + test_void_imp<const T>(); + test_void_imp<volatile T>(); + test_void_imp<const volatile T>(); +} + +int main() +{ + test_void<void>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp new file mode 100644 index 00000000000..1c715e04970 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp @@ -0,0 +1,71 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// extension + +// template <typename _Tp> struct __has_operator_addressof + + +#include <type_traits> + +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + +struct A +{ +}; + +struct B +{ + constexpr B* operator&() const; +}; + +struct D; + +struct C +{ + template <class U> + D operator,(U&&); +}; + +struct E +{ + constexpr C operator&() const; +}; + +struct F {}; +constexpr F* operator&(F const &) { return nullptr; } + +struct G {}; +constexpr G* operator&(G &&) { return nullptr; } + +struct H {}; +constexpr H* operator&(H const &&) { return nullptr; } + +struct J +{ + constexpr J* operator&() const &&; +}; + +#endif // _LIBCPP_HAS_NO_CONSTEXPR + +int main() +{ +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + static_assert(std::__has_operator_addressof<int>::value == false, ""); + static_assert(std::__has_operator_addressof<A>::value == false, ""); + static_assert(std::__has_operator_addressof<B>::value == true, ""); + static_assert(std::__has_operator_addressof<E>::value == true, ""); + static_assert(std::__has_operator_addressof<F>::value == true, ""); + static_assert(std::__has_operator_addressof<G>::value == true, ""); + static_assert(std::__has_operator_addressof<H>::value == true, ""); + static_assert(std::__has_operator_addressof<J>::value == true, ""); +#endif // _LIBCPP_HAS_NO_CONSTEXPR +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp new file mode 100644 index 00000000000..685d30de692 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp @@ -0,0 +1,77 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// has_virtual_destructor + +#include <type_traits> + +template <class T> +void test_has_virtual_destructor() +{ + static_assert( std::has_virtual_destructor<T>::value, ""); + static_assert( std::has_virtual_destructor<const T>::value, ""); + static_assert( std::has_virtual_destructor<volatile T>::value, ""); + static_assert( std::has_virtual_destructor<const volatile T>::value, ""); +} + +template <class T> +void test_has_not_virtual_destructor() +{ + static_assert(!std::has_virtual_destructor<T>::value, ""); + static_assert(!std::has_virtual_destructor<const T>::value, ""); + static_assert(!std::has_virtual_destructor<volatile T>::value, ""); + static_assert(!std::has_virtual_destructor<const volatile T>::value, ""); +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +struct A +{ + ~A(); +}; + +int main() +{ + test_has_not_virtual_destructor<void>(); + test_has_not_virtual_destructor<A>(); + test_has_not_virtual_destructor<int&>(); + test_has_not_virtual_destructor<Union>(); + test_has_not_virtual_destructor<Empty>(); + test_has_not_virtual_destructor<int>(); + test_has_not_virtual_destructor<double>(); + test_has_not_virtual_destructor<int*>(); + test_has_not_virtual_destructor<const int*>(); + test_has_not_virtual_destructor<char[3]>(); + test_has_not_virtual_destructor<char[]>(); + test_has_not_virtual_destructor<bit_zero>(); + + test_has_virtual_destructor<Abstract>(); + test_has_virtual_destructor<NotEmpty>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp new file mode 100644 index 00000000000..f2a8c23246b --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp @@ -0,0 +1,71 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_abstract + +#include <type_traits> + +template <class T> +void test_is_abstract() +{ + static_assert( std::is_abstract<T>::value, ""); + static_assert( std::is_abstract<const T>::value, ""); + static_assert( std::is_abstract<volatile T>::value, ""); + static_assert( std::is_abstract<const volatile T>::value, ""); +} + +template <class T> +void test_is_not_abstract() +{ + static_assert(!std::is_abstract<T>::value, ""); + static_assert(!std::is_abstract<const T>::value, ""); + static_assert(!std::is_abstract<volatile T>::value, ""); + static_assert(!std::is_abstract<const volatile T>::value, ""); +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +int main() +{ + test_is_not_abstract<void>(); + test_is_not_abstract<int&>(); + test_is_not_abstract<int>(); + test_is_not_abstract<double>(); + test_is_not_abstract<int*>(); + test_is_not_abstract<const int*>(); + test_is_not_abstract<char[3]>(); + test_is_not_abstract<char[]>(); + test_is_not_abstract<Union>(); + test_is_not_abstract<Empty>(); + test_is_not_abstract<bit_zero>(); + test_is_not_abstract<NotEmpty>(); + + test_is_abstract<Abstract>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp new file mode 100644 index 00000000000..b46a4d6bcc6 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_assignable + +#include <type_traits> + +struct A +{ +}; + +struct B +{ + void operator=(A); +}; + +template <class T, class U> +void test_is_assignable() +{ + static_assert(( std::is_assignable<T, U>::value), ""); +} + +template <class T, class U> +void test_is_not_assignable() +{ + static_assert((!std::is_assignable<T, U>::value), ""); +} + +struct D; + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +struct C +{ + template <class U> + D operator,(U&&); +}; + +struct E +{ + C operator=(int); +}; +#endif + +int main() +{ + test_is_assignable<int&, int&> (); + test_is_assignable<int&, int> (); + test_is_assignable<int&, double> (); + test_is_assignable<B, A> (); + test_is_assignable<void*&, void*> (); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_is_assignable<E, int> (); + + test_is_not_assignable<int, int&> (); + test_is_not_assignable<int, int> (); +#endif + test_is_not_assignable<A, B> (); + test_is_not_assignable<void, const void> (); + test_is_not_assignable<const void, const void> (); + test_is_not_assignable<int(), int> (); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp new file mode 100644 index 00000000000..72f2ff45892 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_const + +#include <type_traits> + +template <class T> +void test_is_const() +{ + static_assert(!std::is_const<T>::value, ""); + static_assert( std::is_const<const T>::value, ""); + static_assert(!std::is_const<volatile T>::value, ""); + static_assert( std::is_const<const volatile T>::value, ""); +} + +int main() +{ + test_is_const<void>(); + test_is_const<int>(); + test_is_const<double>(); + test_is_const<int*>(); + test_is_const<const int*>(); + test_is_const<char[3]>(); + test_is_const<char[]>(); + + static_assert(!std::is_const<int&>::value, ""); + static_assert(!std::is_const<const int&>::value, ""); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp new file mode 100644 index 00000000000..2b8f7efec60 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp @@ -0,0 +1,86 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// template <class T, class... Args> +// struct is_constructible; + +#include <type_traits> + +struct A +{ + explicit A(int); + A(int, double); +#if __has_feature(cxx_access_control_sfinae) +private: +#endif + A(char); +}; + +class Abstract +{ + virtual void foo() = 0; +}; + +class AbstractDestructor +{ + virtual ~AbstractDestructor() = 0; +}; + +template <class T> +void test_is_constructible() +{ + static_assert( (std::is_constructible<T>::value), ""); +} + +template <class T, class A0> +void test_is_constructible() +{ + static_assert( (std::is_constructible<T, A0>::value), ""); +} + +template <class T, class A0, class A1> +void test_is_constructible() +{ + static_assert( (std::is_constructible<T, A0, A1>::value), ""); +} + +template <class T> +void test_is_not_constructible() +{ + static_assert((!std::is_constructible<T>::value), ""); +} + +template <class T, class A0> +void test_is_not_constructible() +{ + static_assert((!std::is_constructible<T, A0>::value), ""); +} + +int main() +{ + test_is_constructible<int> (); + test_is_constructible<int, const int> (); + test_is_constructible<A, int> (); + test_is_constructible<A, int, double> (); + test_is_constructible<int&, int&> (); + + test_is_not_constructible<A> (); +#if __has_feature(cxx_access_control_sfinae) + test_is_not_constructible<A, char> (); +#else + test_is_constructible<A, char> (); +#endif + test_is_not_constructible<A, void> (); + test_is_not_constructible<void> (); + test_is_not_constructible<int&> (); + test_is_not_constructible<Abstract> (); + test_is_not_constructible<AbstractDestructor> (); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp new file mode 100644 index 00000000000..c43d59479fb --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp @@ -0,0 +1,80 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_copy_assignable + +#include <type_traits> + +template <class T> +void test_is_copy_assignable() +{ + static_assert(( std::is_copy_assignable<T>::value), ""); +} + +template <class T> +void test_is_not_copy_assignable() +{ + static_assert((!std::is_copy_assignable<T>::value), ""); +} + +class Empty +{ +}; + +class NotEmpty +{ +public: + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +struct A +{ + A(); +}; + +class B +{ + B& operator=(const B&); +}; + +struct C +{ + void operator=(C&); // not const +}; + +int main() +{ + test_is_copy_assignable<int> (); + test_is_copy_assignable<int&> (); + test_is_copy_assignable<A> (); + test_is_copy_assignable<bit_zero> (); + test_is_copy_assignable<Union> (); + test_is_copy_assignable<NotEmpty> (); + test_is_copy_assignable<Empty> (); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_is_not_copy_assignable<const int> (); + test_is_not_copy_assignable<int[]> (); + test_is_not_copy_assignable<int[3]> (); +#endif +#if __has_feature(cxx_access_control_sfinae) + test_is_not_copy_assignable<B> (); +#endif + test_is_not_copy_assignable<void> (); + test_is_not_copy_assignable<C> (); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp new file mode 100644 index 00000000000..f878a50c3af --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp @@ -0,0 +1,88 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_copy_constructible + +#include <type_traits> + +template <class T> +void test_is_copy_constructible() +{ + static_assert( std::is_copy_constructible<T>::value, ""); +} + +template <class T> +void test_is_not_copy_constructible() +{ + static_assert(!std::is_copy_constructible<T>::value, ""); +} + +class Empty +{ +}; + +class NotEmpty +{ +public: + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ +public: + virtual ~Abstract() = 0; +}; + +struct A +{ + A(const A&); +}; + +class B +{ + B(const B&); +}; + +struct C +{ + C(C&); // not const + void operator=(C&); // not const +}; + +int main() +{ + test_is_copy_constructible<A>(); + test_is_copy_constructible<int&>(); + test_is_copy_constructible<Union>(); + test_is_copy_constructible<Empty>(); + test_is_copy_constructible<int>(); + test_is_copy_constructible<double>(); + test_is_copy_constructible<int*>(); + test_is_copy_constructible<const int*>(); + test_is_copy_constructible<NotEmpty>(); + test_is_copy_constructible<bit_zero>(); + + test_is_not_copy_constructible<char[3]>(); + test_is_not_copy_constructible<char[]>(); + test_is_not_copy_constructible<void>(); + test_is_not_copy_constructible<Abstract>(); + test_is_not_copy_constructible<C>(); +#if __has_feature(cxx_access_control_sfinae) + test_is_not_copy_constructible<B>(); +#endif +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp new file mode 100644 index 00000000000..e7d2e3a5503 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp @@ -0,0 +1,93 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_default_constructible + +#include <type_traits> + +template <class T> +void test_is_default_constructible() +{ + static_assert( std::is_default_constructible<T>::value, ""); + static_assert( std::is_default_constructible<const T>::value, ""); + static_assert( std::is_default_constructible<volatile T>::value, ""); + static_assert( std::is_default_constructible<const volatile T>::value, ""); +} + +template <class T> +void test_is_not_default_constructible() +{ + static_assert(!std::is_default_constructible<T>::value, ""); + static_assert(!std::is_default_constructible<const T>::value, ""); + static_assert(!std::is_default_constructible<volatile T>::value, ""); + static_assert(!std::is_default_constructible<const volatile T>::value, ""); +} + +class Empty +{ +}; + +class NoDefaultConstructor +{ + NoDefaultConstructor(int) {} +}; + +class NotEmpty +{ +public: + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ +public: + virtual ~Abstract() = 0; +}; + +struct A +{ + A(); +}; + +class B +{ + B(); +}; + +int main() +{ + test_is_default_constructible<A>(); + test_is_default_constructible<Union>(); + test_is_default_constructible<Empty>(); + test_is_default_constructible<int>(); + test_is_default_constructible<double>(); + test_is_default_constructible<int*>(); + test_is_default_constructible<const int*>(); + test_is_default_constructible<char[3]>(); + test_is_default_constructible<NotEmpty>(); + test_is_default_constructible<bit_zero>(); + + test_is_not_default_constructible<void>(); + test_is_not_default_constructible<int&>(); + test_is_not_default_constructible<char[]>(); + test_is_not_default_constructible<Abstract>(); + test_is_not_default_constructible<NoDefaultConstructor>(); +#if __has_feature(cxx_access_control_sfinae) + test_is_not_default_constructible<B>(); +#endif +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp new file mode 100644 index 00000000000..807745ef66c --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp @@ -0,0 +1,121 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_destructible + +#include <type_traits> + +template <class T> +void test_is_destructible() +{ + static_assert( std::is_destructible<T>::value, ""); + static_assert( std::is_destructible<const T>::value, ""); + static_assert( std::is_destructible<volatile T>::value, ""); + static_assert( std::is_destructible<const volatile T>::value, ""); +} + +template <class T> +void test_is_not_destructible() +{ + static_assert(!std::is_destructible<T>::value, ""); + static_assert(!std::is_destructible<const T>::value, ""); + static_assert(!std::is_destructible<volatile T>::value, ""); + static_assert(!std::is_destructible<const volatile T>::value, ""); +} + +class Empty {}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +struct A +{ + ~A(); +}; + +typedef void (Function) (); + +struct PublicAbstract { public: virtual void foo() = 0; }; +struct ProtectedAbstract { protected: virtual void foo() = 0; }; +struct PrivateAbstract { private: virtual void foo() = 0; }; + +struct PublicDestructor { public: ~PublicDestructor() {}}; +struct ProtectedDestructor { protected: ~ProtectedDestructor() {}}; +struct PrivateDestructor { private: ~PrivateDestructor() {}}; + +struct VirtualPublicDestructor { public: virtual ~VirtualPublicDestructor() {}}; +struct VirtualProtectedDestructor { protected: virtual ~VirtualProtectedDestructor() {}}; +struct VirtualPrivateDestructor { private: virtual ~VirtualPrivateDestructor() {}}; + +struct PurePublicDestructor { public: virtual ~PurePublicDestructor() = 0; }; +struct PureProtectedDestructor { protected: virtual ~PureProtectedDestructor() = 0; }; +struct PurePrivateDestructor { private: virtual ~PurePrivateDestructor() = 0; }; + +struct DeletedPublicDestructor { public: ~DeletedPublicDestructor() = delete; }; +struct DeletedProtectedDestructor { protected: ~DeletedProtectedDestructor() = delete; }; +struct DeletedPrivateDestructor { private: ~DeletedPrivateDestructor() = delete; }; + +struct DeletedVirtualPublicDestructor { public: virtual ~DeletedVirtualPublicDestructor() = delete; }; +struct DeletedVirtualProtectedDestructor { protected: virtual ~DeletedVirtualProtectedDestructor() = delete; }; +struct DeletedVirtualPrivateDestructor { private: virtual ~DeletedVirtualPrivateDestructor() = delete; }; + + +int main() +{ + test_is_destructible<A>(); + test_is_destructible<int&>(); + test_is_destructible<Union>(); + test_is_destructible<Empty>(); + test_is_destructible<int>(); + test_is_destructible<double>(); + test_is_destructible<int*>(); + test_is_destructible<const int*>(); + test_is_destructible<char[3]>(); + test_is_destructible<bit_zero>(); + test_is_destructible<int[3]>(); + test_is_destructible<ProtectedAbstract>(); + test_is_destructible<PublicAbstract>(); + test_is_destructible<PrivateAbstract>(); + test_is_destructible<PublicDestructor>(); + test_is_destructible<VirtualPublicDestructor>(); + test_is_destructible<PurePublicDestructor>(); + + test_is_not_destructible<int[]>(); + test_is_not_destructible<void>(); + + test_is_not_destructible<ProtectedDestructor>(); + test_is_not_destructible<PrivateDestructor>(); + test_is_not_destructible<VirtualProtectedDestructor>(); + test_is_not_destructible<VirtualPrivateDestructor>(); + test_is_not_destructible<PureProtectedDestructor>(); + test_is_not_destructible<PurePrivateDestructor>(); + test_is_not_destructible<DeletedPublicDestructor>(); + test_is_not_destructible<DeletedProtectedDestructor>(); + test_is_not_destructible<DeletedPrivateDestructor>(); + +// test_is_not_destructible<DeletedVirtualPublicDestructor>(); // currently fails due to clang bug #20268 + test_is_not_destructible<DeletedVirtualProtectedDestructor>(); + test_is_not_destructible<DeletedVirtualPrivateDestructor>(); + +#if __has_feature(cxx_access_control_sfinae) + test_is_not_destructible<NotEmpty>(); +#endif + test_is_not_destructible<Function>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp new file mode 100644 index 00000000000..47af3c45cde --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp @@ -0,0 +1,65 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_empty + +#include <type_traits> + +template <class T> +void test_is_empty() +{ + static_assert( std::is_empty<T>::value, ""); + static_assert( std::is_empty<const T>::value, ""); + static_assert( std::is_empty<volatile T>::value, ""); + static_assert( std::is_empty<const volatile T>::value, ""); +} + +template <class T> +void test_is_not_empty() +{ + static_assert(!std::is_empty<T>::value, ""); + static_assert(!std::is_empty<const T>::value, ""); + static_assert(!std::is_empty<volatile T>::value, ""); + static_assert(!std::is_empty<const volatile T>::value, ""); +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +int main() +{ + test_is_not_empty<void>(); + test_is_not_empty<int&>(); + test_is_not_empty<int>(); + test_is_not_empty<double>(); + test_is_not_empty<int*>(); + test_is_not_empty<const int*>(); + test_is_not_empty<char[3]>(); + test_is_not_empty<char[]>(); + test_is_not_empty<Union>(); + test_is_not_empty<NotEmpty>(); + + test_is_empty<Empty>(); + test_is_empty<bit_zero>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp new file mode 100644 index 00000000000..cf32196213e --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_final + +#include <type_traits> + +#if _LIBCPP_STD_VER > 11 + +struct P final { }; +union U1 { }; +union U2 final { }; + +template <class T> +void test_is_final() +{ + static_assert( std::is_final<T>::value, ""); + static_assert( std::is_final<const T>::value, ""); + static_assert( std::is_final<volatile T>::value, ""); + static_assert( std::is_final<const volatile T>::value, ""); +} + +template <class T> +void test_is_not_final() +{ + static_assert(!std::is_final<T>::value, ""); + static_assert(!std::is_final<const T>::value, ""); + static_assert(!std::is_final<volatile T>::value, ""); + static_assert(!std::is_final<const volatile T>::value, ""); +} + +int main () +{ + test_is_not_final<int>(); + test_is_not_final<int*>(); + test_is_final <P>(); + test_is_not_final<P*>(); + test_is_not_final<U1>(); + test_is_not_final<U1*>(); + test_is_final <U2>(); + test_is_not_final<U2*>(); +} +#else +int main () {} +#endif diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp new file mode 100644 index 00000000000..ce781cd936b --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_literal_type + +#include <type_traits> + +template <class T> +void test_is_literal_type() +{ + static_assert( std::is_literal_type<T>::value, ""); +} + +template <class T> +void test_is_not_literal_type() +{ + static_assert(!std::is_literal_type<T>::value, ""); +} + +struct A +{ +}; + +struct B +{ + B(); +}; + +int main() +{ + test_is_literal_type<int> (); + test_is_literal_type<const int> (); + test_is_literal_type<int&> (); + test_is_literal_type<volatile int&> (); + test_is_literal_type<A> (); + + test_is_not_literal_type<B> (); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp new file mode 100644 index 00000000000..a89ee7d4e49 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp @@ -0,0 +1,65 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_move_assignable + +#include <type_traits> + +template <class T> +void test_is_move_assignable() +{ + static_assert( std::is_move_assignable<T>::value, ""); +} + +template <class T> +void test_is_not_move_assignable() +{ + static_assert(!std::is_move_assignable<T>::value, ""); +} + +class Empty +{ +}; + +class NotEmpty +{ +public: + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +struct A +{ + A(); +}; + +int main() +{ + test_is_move_assignable<int> (); + test_is_move_assignable<A> (); + test_is_move_assignable<bit_zero> (); + test_is_move_assignable<Union> (); + test_is_move_assignable<NotEmpty> (); + test_is_move_assignable<Empty> (); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_is_not_move_assignable<const int> (); + test_is_not_move_assignable<int[]> (); + test_is_not_move_assignable<int[3]> (); +#endif + test_is_not_move_assignable<void> (); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_constructible.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_constructible.pass.cpp new file mode 100644 index 00000000000..7409ebaa56c --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_constructible.pass.cpp @@ -0,0 +1,81 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_move_constructible + +#include <type_traits> + +template <class T> +void test_is_move_constructible() +{ + static_assert( std::is_move_constructible<T>::value, ""); +} + +template <class T> +void test_is_not_move_constructible() +{ + static_assert(!std::is_move_constructible<T>::value, ""); +} + +class Empty +{ +}; + +class NotEmpty +{ +public: + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ +public: + virtual ~Abstract() = 0; +}; + +struct A +{ + A(const A&); +}; + +struct B +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + B(B&&); +#endif +}; + +int main() +{ + test_is_not_move_constructible<char[3]>(); + test_is_not_move_constructible<char[]>(); + test_is_not_move_constructible<void>(); + test_is_not_move_constructible<Abstract>(); + + test_is_move_constructible<A>(); + test_is_move_constructible<int&>(); + test_is_move_constructible<Union>(); + test_is_move_constructible<Empty>(); + test_is_move_constructible<int>(); + test_is_move_constructible<double>(); + test_is_move_constructible<int*>(); + test_is_move_constructible<const int*>(); + test_is_move_constructible<NotEmpty>(); + test_is_move_constructible<bit_zero>(); + test_is_move_constructible<B>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp new file mode 100644 index 00000000000..8fff5f8b3de --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp @@ -0,0 +1,55 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_nothrow_assignable + +#include <type_traits> + +template <class T, class U> +void test_is_nothrow_assignable() +{ + static_assert(( std::is_nothrow_assignable<T, U>::value), ""); +} + +template <class T, class U> +void test_is_not_nothrow_assignable() +{ + static_assert((!std::is_nothrow_assignable<T, U>::value), ""); +} + +struct A +{ +}; + +struct B +{ + void operator=(A); +}; + +struct C +{ + void operator=(C&); // not const +}; + +int main() +{ + test_is_nothrow_assignable<int&, int&> (); + test_is_nothrow_assignable<int&, int> (); +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_is_nothrow_assignable<int&, double> (); +#endif + + test_is_not_nothrow_assignable<int, int&> (); + test_is_not_nothrow_assignable<int, int> (); + test_is_not_nothrow_assignable<B, A> (); + test_is_not_nothrow_assignable<A, B> (); + test_is_not_nothrow_assignable<C, C&> (); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp new file mode 100644 index 00000000000..fe0b5673bc4 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp @@ -0,0 +1,103 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// template <class T, class... Args> +// struct is_nothrow_constructible; + +#include <type_traits> + +template <class T> +void test_is_nothrow_constructible() +{ + static_assert(( std::is_nothrow_constructible<T>::value), ""); +} + +template <class T, class A0> +void test_is_nothrow_constructible() +{ + static_assert(( std::is_nothrow_constructible<T, A0>::value), ""); +} + +template <class T> +void test_is_not_nothrow_constructible() +{ + static_assert((!std::is_nothrow_constructible<T>::value), ""); +} + +template <class T, class A0> +void test_is_not_nothrow_constructible() +{ + static_assert((!std::is_nothrow_constructible<T, A0>::value), ""); +} + +template <class T, class A0, class A1> +void test_is_not_nothrow_constructible() +{ + static_assert((!std::is_nothrow_constructible<T, A0, A1>::value), ""); +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +struct A +{ + A(const A&); +}; + +struct C +{ + C(C&); // not const + void operator=(C&); // not const +}; + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +struct Tuple { + Tuple(Empty&&) noexcept {} +}; +#endif + +int main() +{ + test_is_nothrow_constructible<int> (); + test_is_nothrow_constructible<int, const int&> (); + test_is_nothrow_constructible<Empty> (); + test_is_nothrow_constructible<Empty, const Empty&> (); +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_is_nothrow_constructible<Tuple &&, Empty> (); // See bug #19616. +#endif + + test_is_not_nothrow_constructible<A, int> (); + test_is_not_nothrow_constructible<A, int, double> (); + test_is_not_nothrow_constructible<A> (); + test_is_not_nothrow_constructible<C> (); +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + static_assert(!std::is_constructible<Tuple&, Empty>::value, ""); + test_is_not_nothrow_constructible<Tuple &, Empty> (); // See bug #19616. +#endif +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp new file mode 100644 index 00000000000..d843803cf21 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp @@ -0,0 +1,65 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_nothrow_copy_assignable + +#include <type_traits> + +template <class T> +void test_has_nothrow_assign() +{ + static_assert( std::is_nothrow_copy_assignable<T>::value, ""); +} + +template <class T> +void test_has_not_nothrow_assign() +{ + static_assert(!std::is_nothrow_copy_assignable<T>::value, ""); +} + +class Empty +{ +}; + +struct NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +struct A +{ + A& operator=(const A&); +}; + +int main() +{ + test_has_nothrow_assign<int&>(); + test_has_nothrow_assign<Union>(); + test_has_nothrow_assign<Empty>(); + test_has_nothrow_assign<int>(); + test_has_nothrow_assign<double>(); + test_has_nothrow_assign<int*>(); + test_has_nothrow_assign<const int*>(); + test_has_nothrow_assign<NotEmpty>(); + test_has_nothrow_assign<bit_zero>(); + + test_has_not_nothrow_assign<const int>(); + test_has_not_nothrow_assign<void>(); + test_has_not_nothrow_assign<A>(); + +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp new file mode 100644 index 00000000000..99fce65dcc7 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_nothrow_copy_constructible + +#include <type_traits> + +template <class T> +void test_is_nothrow_copy_constructible() +{ + static_assert( std::is_nothrow_copy_constructible<T>::value, ""); + static_assert( std::is_nothrow_copy_constructible<const T>::value, ""); +} + +template <class T> +void test_has_not_nothrow_copy_constructor() +{ + static_assert(!std::is_nothrow_copy_constructible<T>::value, ""); + static_assert(!std::is_nothrow_copy_constructible<const T>::value, ""); + static_assert(!std::is_nothrow_copy_constructible<volatile T>::value, ""); + static_assert(!std::is_nothrow_copy_constructible<const volatile T>::value, ""); +} + +class Empty +{ +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +struct A +{ + A(const A&); +}; + +int main() +{ + test_has_not_nothrow_copy_constructor<void>(); + test_has_not_nothrow_copy_constructor<A>(); + + test_is_nothrow_copy_constructible<int&>(); + test_is_nothrow_copy_constructible<Union>(); + test_is_nothrow_copy_constructible<Empty>(); + test_is_nothrow_copy_constructible<int>(); + test_is_nothrow_copy_constructible<double>(); + test_is_nothrow_copy_constructible<int*>(); + test_is_nothrow_copy_constructible<const int*>(); + test_is_nothrow_copy_constructible<bit_zero>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp new file mode 100644 index 00000000000..1550dff08bb --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp @@ -0,0 +1,64 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_nothrow_default_constructible + +#include <type_traits> + +template <class T> +void test_is_nothrow_default_constructible() +{ + static_assert( std::is_nothrow_default_constructible<T>::value, ""); + static_assert( std::is_nothrow_default_constructible<const T>::value, ""); + static_assert( std::is_nothrow_default_constructible<volatile T>::value, ""); + static_assert( std::is_nothrow_default_constructible<const volatile T>::value, ""); +} + +template <class T> +void test_has_not_nothrow_default_constructor() +{ + static_assert(!std::is_nothrow_default_constructible<T>::value, ""); + static_assert(!std::is_nothrow_default_constructible<const T>::value, ""); + static_assert(!std::is_nothrow_default_constructible<volatile T>::value, ""); + static_assert(!std::is_nothrow_default_constructible<const volatile T>::value, ""); +} + +class Empty +{ +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +struct A +{ + A(); +}; + +int main() +{ + test_has_not_nothrow_default_constructor<void>(); + test_has_not_nothrow_default_constructor<int&>(); + test_has_not_nothrow_default_constructor<A>(); + + test_is_nothrow_default_constructible<Union>(); + test_is_nothrow_default_constructible<Empty>(); + test_is_nothrow_default_constructible<int>(); + test_is_nothrow_default_constructible<double>(); + test_is_nothrow_default_constructible<int*>(); + test_is_nothrow_default_constructible<const int*>(); + test_is_nothrow_default_constructible<char[3]>(); + test_is_nothrow_default_constructible<bit_zero>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp new file mode 100644 index 00000000000..8fd5bab5a01 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp @@ -0,0 +1,91 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_nothrow_destructible + +#include <type_traits> + +template <class T> +void test_is_nothrow_destructible() +{ + static_assert( std::is_nothrow_destructible<T>::value, ""); + static_assert( std::is_nothrow_destructible<const T>::value, ""); + static_assert( std::is_nothrow_destructible<volatile T>::value, ""); + static_assert( std::is_nothrow_destructible<const volatile T>::value, ""); +} + +template <class T> +void test_is_not_nothrow_destructible() +{ + static_assert(!std::is_nothrow_destructible<T>::value, ""); + static_assert(!std::is_nothrow_destructible<const T>::value, ""); + static_assert(!std::is_nothrow_destructible<volatile T>::value, ""); + static_assert(!std::is_nothrow_destructible<const volatile T>::value, ""); +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual void foo() = 0; +}; + +class AbstractDestructor +{ + virtual ~AbstractDestructor() = 0; +}; + +struct A +{ + ~A(); +}; + +int main() +{ + test_is_not_nothrow_destructible<void>(); + test_is_not_nothrow_destructible<AbstractDestructor>(); + test_is_not_nothrow_destructible<NotEmpty>(); + test_is_not_nothrow_destructible<char[]>(); + +#if __has_feature(cxx_noexcept) + test_is_nothrow_destructible<A>(); +#endif + test_is_nothrow_destructible<int&>(); +#if __has_feature(cxx_unrestricted_unions) + test_is_nothrow_destructible<Union>(); +#endif +#if __has_feature(cxx_access_control_sfinae) + test_is_nothrow_destructible<Empty>(); +#endif + test_is_nothrow_destructible<int>(); + test_is_nothrow_destructible<double>(); + test_is_nothrow_destructible<int*>(); + test_is_nothrow_destructible<const int*>(); + test_is_nothrow_destructible<char[3]>(); + test_is_nothrow_destructible<Abstract>(); +#if __has_feature(cxx_noexcept) + test_is_nothrow_destructible<bit_zero>(); +#endif +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp new file mode 100644 index 00000000000..fe51e438864 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp @@ -0,0 +1,63 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// has_nothrow_move_assign + +#include <type_traits> + +template <class T> +void test_has_nothrow_assign() +{ + static_assert( std::is_nothrow_move_assignable<T>::value, ""); +} + +template <class T> +void test_has_not_nothrow_assign() +{ + static_assert(!std::is_nothrow_move_assignable<T>::value, ""); +} + +class Empty +{ +}; + +struct NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +struct A +{ + A& operator=(const A&); +}; + +int main() +{ + test_has_nothrow_assign<int&>(); + test_has_nothrow_assign<Union>(); + test_has_nothrow_assign<Empty>(); + test_has_nothrow_assign<int>(); + test_has_nothrow_assign<double>(); + test_has_nothrow_assign<int*>(); + test_has_nothrow_assign<const int*>(); + test_has_nothrow_assign<NotEmpty>(); + test_has_nothrow_assign<bit_zero>(); + + test_has_not_nothrow_assign<void>(); + test_has_not_nothrow_assign<A>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp new file mode 100644 index 00000000000..f5a42afe0d5 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// has_nothrow_move_constructor + +#include <type_traits> + +template <class T> +void test_is_nothrow_move_constructible() +{ + static_assert( std::is_nothrow_move_constructible<T>::value, ""); + static_assert( std::is_nothrow_move_constructible<const T>::value, ""); +} + +template <class T> +void test_has_not_nothrow_move_constructor() +{ + static_assert(!std::is_nothrow_move_constructible<T>::value, ""); + static_assert(!std::is_nothrow_move_constructible<const T>::value, ""); + static_assert(!std::is_nothrow_move_constructible<volatile T>::value, ""); + static_assert(!std::is_nothrow_move_constructible<const volatile T>::value, ""); +} + +class Empty +{ +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +struct A +{ + A(const A&); +}; + +int main() +{ + test_has_not_nothrow_move_constructor<void>(); + test_has_not_nothrow_move_constructor<A>(); + + test_is_nothrow_move_constructible<int&>(); + test_is_nothrow_move_constructible<Union>(); + test_is_nothrow_move_constructible<Empty>(); + test_is_nothrow_move_constructible<int>(); + test_is_nothrow_move_constructible<double>(); + test_is_nothrow_move_constructible<int*>(); + test_is_nothrow_move_constructible<const int*>(); + test_is_nothrow_move_constructible<bit_zero>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp new file mode 100644 index 00000000000..4ec1ae9949e --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_pod + +#include <type_traits> + +template <class T> +void test_is_pod() +{ + static_assert( std::is_pod<T>::value, ""); + static_assert( std::is_pod<const T>::value, ""); + static_assert( std::is_pod<volatile T>::value, ""); + static_assert( std::is_pod<const volatile T>::value, ""); +} + +template <class T> +void test_is_not_pod() +{ + static_assert(!std::is_pod<T>::value, ""); + static_assert(!std::is_pod<const T>::value, ""); + static_assert(!std::is_pod<volatile T>::value, ""); + static_assert(!std::is_pod<const volatile T>::value, ""); +} + +class Class +{ +public: + ~Class(); +}; + +int main() +{ + test_is_not_pod<void>(); + test_is_not_pod<int&>(); + test_is_not_pod<Class>(); + + test_is_pod<int>(); + test_is_pod<double>(); + test_is_pod<int*>(); + test_is_pod<const int*>(); + test_is_pod<char[3]>(); + test_is_pod<char[]>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp new file mode 100644 index 00000000000..6e82cddc516 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp @@ -0,0 +1,82 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_polymorphic + +#include <type_traits> + +template <class T> +void test_is_polymorphic() +{ + static_assert( std::is_polymorphic<T>::value, ""); + static_assert( std::is_polymorphic<const T>::value, ""); + static_assert( std::is_polymorphic<volatile T>::value, ""); + static_assert( std::is_polymorphic<const volatile T>::value, ""); +} + +template <class T> +void test_is_not_polymorphic() +{ + static_assert(!std::is_polymorphic<T>::value, ""); + static_assert(!std::is_polymorphic<const T>::value, ""); + static_assert(!std::is_polymorphic<volatile T>::value, ""); + static_assert(!std::is_polymorphic<const volatile T>::value, ""); +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +#if __has_feature(cxx_attributes) +class Final final { +}; +#else +class Final { +}; +#endif + +int main() +{ + test_is_not_polymorphic<void>(); + test_is_not_polymorphic<int&>(); + test_is_not_polymorphic<int>(); + test_is_not_polymorphic<double>(); + test_is_not_polymorphic<int*>(); + test_is_not_polymorphic<const int*>(); + test_is_not_polymorphic<char[3]>(); + test_is_not_polymorphic<char[]>(); + test_is_not_polymorphic<Union>(); + test_is_not_polymorphic<Empty>(); + test_is_not_polymorphic<bit_zero>(); + test_is_not_polymorphic<Final>(); + test_is_not_polymorphic<NotEmpty&>(); + test_is_not_polymorphic<Abstract&>(); + + test_is_polymorphic<NotEmpty>(); + test_is_polymorphic<Abstract>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp new file mode 100644 index 00000000000..479c2529f02 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_signed + +#include <type_traits> + +template <class T> +void test_is_signed() +{ + static_assert( std::is_signed<T>::value, ""); + static_assert( std::is_signed<const T>::value, ""); + static_assert( std::is_signed<volatile T>::value, ""); + static_assert( std::is_signed<const volatile T>::value, ""); +} + +template <class T> +void test_is_not_signed() +{ + static_assert(!std::is_signed<T>::value, ""); + static_assert(!std::is_signed<const T>::value, ""); + static_assert(!std::is_signed<volatile T>::value, ""); + static_assert(!std::is_signed<const volatile T>::value, ""); +} + +class Class +{ +public: + ~Class(); +}; + +int main() +{ + test_is_not_signed<void>(); + test_is_not_signed<int&>(); + test_is_not_signed<Class>(); + test_is_not_signed<int*>(); + test_is_not_signed<const int*>(); + test_is_not_signed<char[3]>(); + test_is_not_signed<char[]>(); + test_is_not_signed<bool>(); + test_is_not_signed<unsigned>(); + + test_is_signed<int>(); + test_is_signed<double>(); + +#ifndef _LIBCPP_HAS_NO_INT128 + test_is_signed<__int128_t>(); + test_is_not_signed<__uint128_t>(); +#endif +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp new file mode 100644 index 00000000000..668c4cdc7dd --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_standard_layout + +#include <type_traits> + +template <class T> +void test_is_standard_layout() +{ + static_assert( std::is_standard_layout<T>::value, ""); + static_assert( std::is_standard_layout<const T>::value, ""); + static_assert( std::is_standard_layout<volatile T>::value, ""); + static_assert( std::is_standard_layout<const volatile T>::value, ""); +} + +template <class T> +void test_is_not_standard_layout() +{ + static_assert(!std::is_standard_layout<T>::value, ""); + static_assert(!std::is_standard_layout<const T>::value, ""); + static_assert(!std::is_standard_layout<volatile T>::value, ""); + static_assert(!std::is_standard_layout<const volatile T>::value, ""); +} + +template <class T1, class T2> +struct pair +{ + T1 first; + T2 second; +}; + +int main() +{ + test_is_standard_layout<int> (); + test_is_standard_layout<int[3]> (); + test_is_standard_layout<pair<int, double> > (); + + test_is_not_standard_layout<int&> (); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp new file mode 100644 index 00000000000..af38699d881 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_trivial + +#include <type_traits> + +template <class T> +void test_is_trivial() +{ + static_assert( std::is_trivial<T>::value, ""); + static_assert( std::is_trivial<const T>::value, ""); + static_assert( std::is_trivial<volatile T>::value, ""); + static_assert( std::is_trivial<const volatile T>::value, ""); +} + +template <class T> +void test_is_not_trivial() +{ + static_assert(!std::is_trivial<T>::value, ""); + static_assert(!std::is_trivial<const T>::value, ""); + static_assert(!std::is_trivial<volatile T>::value, ""); + static_assert(!std::is_trivial<const volatile T>::value, ""); +} + +struct A {}; + +class B +{ +public: + B(); +}; + +int main() +{ + test_is_trivial<int> (); + test_is_trivial<A> (); + + test_is_not_trivial<int&> (); + test_is_not_trivial<volatile int&> (); + test_is_not_trivial<B> (); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp new file mode 100644 index 00000000000..735d05fa6ee --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_trivially_assignable + +#include <type_traits> + +template <class T, class U> +void test_is_trivially_assignable() +{ + static_assert(( std::is_trivially_assignable<T, U>::value), ""); +} + +template <class T, class U> +void test_is_not_trivially_assignable() +{ + static_assert((!std::is_trivially_assignable<T, U>::value), ""); +} + +struct A +{ +}; + +struct B +{ + void operator=(A); +}; + +struct C +{ + void operator=(C&); // not const +}; + +int main() +{ + test_is_trivially_assignable<int&, int&> (); + test_is_trivially_assignable<int&, int> (); + test_is_trivially_assignable<int&, double> (); + + test_is_not_trivially_assignable<int, int&> (); + test_is_not_trivially_assignable<int, int> (); + test_is_not_trivially_assignable<B, A> (); + test_is_not_trivially_assignable<A, B> (); + test_is_not_trivially_assignable<C&, C&> (); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_constructible.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_constructible.pass.cpp new file mode 100644 index 00000000000..4171d4d32f5 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_constructible.pass.cpp @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// template <class T, class... Args> +// struct is_trivially_constructible; + +#include <type_traits> + +template <class T> +void test_is_trivially_constructible() +{ + static_assert(( std::is_trivially_constructible<T>::value), ""); +} + +template <class T, class A0> +void test_is_trivially_constructible() +{ + static_assert(( std::is_trivially_constructible<T, A0>::value), ""); +} + +template <class T> +void test_is_not_trivially_constructible() +{ + static_assert((!std::is_trivially_constructible<T>::value), ""); +} + +template <class T, class A0> +void test_is_not_trivially_constructible() +{ + static_assert((!std::is_trivially_constructible<T, A0>::value), ""); +} + +template <class T, class A0, class A1> +void test_is_not_trivially_constructible() +{ + static_assert((!std::is_trivially_constructible<T, A0, A1>::value), ""); +} + +struct A +{ + explicit A(int); + A(int, double); +}; + +int main() +{ + test_is_trivially_constructible<int> (); + test_is_trivially_constructible<int, const int&> (); + + test_is_not_trivially_constructible<A, int> (); + test_is_not_trivially_constructible<A, int, double> (); + test_is_not_trivially_constructible<A> (); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp new file mode 100644 index 00000000000..7d72565e40c --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp @@ -0,0 +1,71 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_trivially_copy_assignable + +#include <type_traits> + +template <class T> +void test_has_trivially_copy_assignable() +{ + static_assert( std::is_trivially_copy_assignable<T>::value, ""); +} + +template <class T> +void test_has_not_trivially_copy_assignable() +{ + static_assert(!std::is_trivially_copy_assignable<T>::value, ""); +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +struct A +{ + A& operator=(const A&); +}; + +int main() +{ + test_has_trivially_copy_assignable<int&>(); + test_has_trivially_copy_assignable<Union>(); + test_has_trivially_copy_assignable<Empty>(); + test_has_trivially_copy_assignable<int>(); + test_has_trivially_copy_assignable<double>(); + test_has_trivially_copy_assignable<int*>(); + test_has_trivially_copy_assignable<const int*>(); + test_has_trivially_copy_assignable<bit_zero>(); + + test_has_not_trivially_copy_assignable<void>(); + test_has_not_trivially_copy_assignable<A>(); + test_has_not_trivially_copy_assignable<NotEmpty>(); + test_has_not_trivially_copy_assignable<Abstract>(); + test_has_not_trivially_copy_assignable<const Empty>(); + +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp new file mode 100644 index 00000000000..6bd78ec9e7a --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp @@ -0,0 +1,73 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_trivially_copy_constructible + +#include <type_traits> + +template <class T> +void test_is_trivially_copy_constructible() +{ + static_assert( std::is_trivially_copy_constructible<T>::value, ""); + static_assert( std::is_trivially_copy_constructible<const T>::value, ""); +} + +template <class T> +void test_has_not_trivial_copy_constructor() +{ + static_assert(!std::is_trivially_copy_constructible<T>::value, ""); + static_assert(!std::is_trivially_copy_constructible<const T>::value, ""); +} + +class Empty +{ +}; + +class NotEmpty +{ +public: + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ +public: + virtual ~Abstract() = 0; +}; + +struct A +{ + A(const A&); +}; + +int main() +{ + test_has_not_trivial_copy_constructor<void>(); + test_has_not_trivial_copy_constructor<A>(); + test_has_not_trivial_copy_constructor<Abstract>(); + test_has_not_trivial_copy_constructor<NotEmpty>(); + + test_is_trivially_copy_constructible<int&>(); + test_is_trivially_copy_constructible<Union>(); + test_is_trivially_copy_constructible<Empty>(); + test_is_trivially_copy_constructible<int>(); + test_is_trivially_copy_constructible<double>(); + test_is_trivially_copy_constructible<int*>(); + test_is_trivially_copy_constructible<const int*>(); + test_is_trivially_copy_constructible<bit_zero>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp new file mode 100644 index 00000000000..d65882378fc --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp @@ -0,0 +1,63 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_trivially_copyable + +#include <type_traits> +#include <cassert> + +template <class T> +void test_is_trivially_copyable() +{ + static_assert( std::is_trivially_copyable<T>::value, ""); + static_assert( std::is_trivially_copyable<const T>::value, ""); + static_assert(!std::is_trivially_copyable<volatile T>::value, ""); + static_assert(!std::is_trivially_copyable<const volatile T>::value, ""); +} + +template <class T> +void test_is_not_trivially_copyable() +{ + static_assert(!std::is_trivially_copyable<T>::value, ""); + static_assert(!std::is_trivially_copyable<const T>::value, ""); + static_assert(!std::is_trivially_copyable<volatile T>::value, ""); + static_assert(!std::is_trivially_copyable<const volatile T>::value, ""); +} + +struct A +{ + int i_; +}; + +struct B +{ + int i_; + ~B() {assert(i_ == 0);} +}; + +class C +{ +public: + C(); +}; + +int main() +{ + test_is_trivially_copyable<int> (); + test_is_trivially_copyable<const int> (); + test_is_trivially_copyable<A> (); + test_is_trivially_copyable<const A> (); + test_is_trivially_copyable<C> (); + + test_is_not_trivially_copyable<int&> (); + test_is_not_trivially_copyable<const A&> (); + test_is_not_trivially_copyable<B> (); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_default_constructible.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_default_constructible.pass.cpp new file mode 100644 index 00000000000..1f63401dacb --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_default_constructible.pass.cpp @@ -0,0 +1,76 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_trivially_default_constructible + +#include <type_traits> + +template <class T> +void test_is_trivially_default_constructible() +{ + static_assert( std::is_trivially_default_constructible<T>::value, ""); + static_assert( std::is_trivially_default_constructible<const T>::value, ""); + static_assert( std::is_trivially_default_constructible<volatile T>::value, ""); + static_assert( std::is_trivially_default_constructible<const volatile T>::value, ""); +} + +template <class T> +void test_has_not_trivial_default_constructor() +{ + static_assert(!std::is_trivially_default_constructible<T>::value, ""); + static_assert(!std::is_trivially_default_constructible<const T>::value, ""); + static_assert(!std::is_trivially_default_constructible<volatile T>::value, ""); + static_assert(!std::is_trivially_default_constructible<const volatile T>::value, ""); +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +struct A +{ + A(); +}; + +int main() +{ + test_has_not_trivial_default_constructor<void>(); + test_has_not_trivial_default_constructor<int&>(); + test_has_not_trivial_default_constructor<A>(); + test_has_not_trivial_default_constructor<Abstract>(); + test_has_not_trivial_default_constructor<NotEmpty>(); + + test_is_trivially_default_constructible<Union>(); + test_is_trivially_default_constructible<Empty>(); + test_is_trivially_default_constructible<int>(); + test_is_trivially_default_constructible<double>(); + test_is_trivially_default_constructible<int*>(); + test_is_trivially_default_constructible<const int*>(); + test_is_trivially_default_constructible<char[3]>(); + test_is_trivially_default_constructible<bit_zero>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp new file mode 100644 index 00000000000..b18ace44bda --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp @@ -0,0 +1,83 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_trivially_destructible + +#include <type_traits> + +template <class T> +void test_is_trivially_destructible() +{ + static_assert( std::is_trivially_destructible<T>::value, ""); + static_assert( std::is_trivially_destructible<const T>::value, ""); + static_assert( std::is_trivially_destructible<volatile T>::value, ""); + static_assert( std::is_trivially_destructible<const volatile T>::value, ""); +} + +template <class T> +void test_is_not_trivially_destructible() +{ + static_assert(!std::is_trivially_destructible<T>::value, ""); + static_assert(!std::is_trivially_destructible<const T>::value, ""); + static_assert(!std::is_trivially_destructible<volatile T>::value, ""); + static_assert(!std::is_trivially_destructible<const volatile T>::value, ""); +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual void foo() = 0; +}; + +class AbstractDestructor +{ + virtual ~AbstractDestructor() = 0; +}; + +struct A +{ + ~A(); +}; + +int main() +{ + test_is_not_trivially_destructible<void>(); + test_is_not_trivially_destructible<A>(); + test_is_not_trivially_destructible<AbstractDestructor>(); + test_is_not_trivially_destructible<NotEmpty>(); + test_is_not_trivially_destructible<char[]>(); + + test_is_trivially_destructible<Abstract>(); + test_is_trivially_destructible<int&>(); + test_is_trivially_destructible<Union>(); + test_is_trivially_destructible<Empty>(); + test_is_trivially_destructible<int>(); + test_is_trivially_destructible<double>(); + test_is_trivially_destructible<int*>(); + test_is_trivially_destructible<const int*>(); + test_is_trivially_destructible<char[3]>(); + test_is_trivially_destructible<bit_zero>(); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp new file mode 100644 index 00000000000..c3fc7ac0a3d --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp @@ -0,0 +1,71 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_trivially_move_assignable + +#include <type_traits> + +template <class T> +void test_has_trivial_assign() +{ + static_assert( std::is_trivially_move_assignable<T>::value, ""); +} + +template <class T> +void test_has_not_trivial_assign() +{ + static_assert(!std::is_trivially_move_assignable<T>::value, ""); +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +struct A +{ + A& operator=(const A&); +}; + +int main() +{ + test_has_trivial_assign<int&>(); + test_has_trivial_assign<Union>(); + test_has_trivial_assign<Empty>(); + test_has_trivial_assign<int>(); + test_has_trivial_assign<double>(); + test_has_trivial_assign<int*>(); + test_has_trivial_assign<const int*>(); + test_has_trivial_assign<bit_zero>(); + + test_has_not_trivial_assign<void>(); + test_has_not_trivial_assign<A>(); + test_has_not_trivial_assign<NotEmpty>(); + test_has_not_trivial_assign<Abstract>(); + test_has_not_trivial_assign<const Empty>(); + +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp new file mode 100644 index 00000000000..54cb5e853a8 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp @@ -0,0 +1,89 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_trivially_move_constructible + +#include <type_traits> + +template <class T> +void test_is_trivially_move_constructible() +{ + static_assert( std::is_trivially_move_constructible<T>::value, ""); +} + +template <class T> +void test_has_not_trivial_move_constructor() +{ + static_assert(!std::is_trivially_move_constructible<T>::value, ""); +} + +class Empty +{ +}; + +class NotEmpty +{ +public: + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ +public: + virtual ~Abstract() = 0; +}; + +struct A +{ + A(const A&); +}; + +#if __has_feature(cxx_defaulted_functions) + +struct MoveOnly1 +{ + MoveOnly1(MoveOnly1&&); +}; + +struct MoveOnly2 +{ + MoveOnly2(MoveOnly2&&) = default; +}; + +#endif + +int main() +{ + test_has_not_trivial_move_constructor<void>(); + test_has_not_trivial_move_constructor<A>(); + test_has_not_trivial_move_constructor<Abstract>(); + test_has_not_trivial_move_constructor<NotEmpty>(); + + test_is_trivially_move_constructible<Union>(); + test_is_trivially_move_constructible<Empty>(); + test_is_trivially_move_constructible<int>(); + test_is_trivially_move_constructible<double>(); + test_is_trivially_move_constructible<int*>(); + test_is_trivially_move_constructible<const int*>(); + test_is_trivially_move_constructible<bit_zero>(); + +#if __has_feature(cxx_defaulted_functions) + static_assert(!std::is_trivially_move_constructible<MoveOnly1>::value, ""); + static_assert( std::is_trivially_move_constructible<MoveOnly2>::value, ""); +#endif +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp new file mode 100644 index 00000000000..dfdb1554261 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_unsigned + +#include <type_traits> + +template <class T> +void test_is_unsigned() +{ + static_assert( std::is_unsigned<T>::value, ""); + static_assert( std::is_unsigned<const T>::value, ""); + static_assert( std::is_unsigned<volatile T>::value, ""); + static_assert( std::is_unsigned<const volatile T>::value, ""); +} + +template <class T> +void test_is_not_unsigned() +{ + static_assert(!std::is_unsigned<T>::value, ""); + static_assert(!std::is_unsigned<const T>::value, ""); + static_assert(!std::is_unsigned<volatile T>::value, ""); + static_assert(!std::is_unsigned<const volatile T>::value, ""); +} + +class Class +{ +public: + ~Class(); +}; + +int main() +{ + test_is_not_unsigned<void>(); + test_is_not_unsigned<int&>(); + test_is_not_unsigned<Class>(); + test_is_not_unsigned<int*>(); + test_is_not_unsigned<const int*>(); + test_is_not_unsigned<char[3]>(); + test_is_not_unsigned<char[]>(); + test_is_not_unsigned<int>(); + test_is_not_unsigned<double>(); + + test_is_unsigned<bool>(); + test_is_unsigned<unsigned>(); + +#ifndef _LIBCPP_HAS_NO_INT128 + test_is_unsigned<__uint128_t>(); + test_is_not_unsigned<__int128_t>(); +#endif +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp new file mode 100644 index 00000000000..f6805bc1c4f --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_volatile + +#include <type_traits> + +template <class T> +void test_is_volatile() +{ + static_assert(!std::is_volatile<T>::value, ""); + static_assert(!std::is_volatile<const T>::value, ""); + static_assert( std::is_volatile<volatile T>::value, ""); + static_assert( std::is_volatile<const volatile T>::value, ""); +} + +int main() +{ + test_is_volatile<void>(); + test_is_volatile<int>(); + test_is_volatile<double>(); + test_is_volatile<int*>(); + test_is_volatile<const int*>(); + test_is_volatile<char[3]>(); + test_is_volatile<char[]>(); + + static_assert(!std::is_volatile<int&>::value, ""); + static_assert(!std::is_volatile<volatile int&>::value, ""); +} diff --git a/libcxx/test/std/utilities/meta/meta.unary/nothing_to_do.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/std/utilities/meta/version.pass.cpp b/libcxx/test/std/utilities/meta/version.pass.cpp new file mode 100644 index 00000000000..3a1033bbb56 --- /dev/null +++ b/libcxx/test/std/utilities/meta/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <type_traits> + +#include <type_traits> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} |