diff options
Diffstat (limited to 'libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop')
39 files changed, 2694 insertions, 0 deletions
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, ""); +} |