diff options
Diffstat (limited to 'libcxx/test/std/experimental/utilities')
11 files changed, 1015 insertions, 0 deletions
diff --git a/libcxx/test/std/experimental/utilities/meta/meta.type.synop/includes.pass.cpp b/libcxx/test/std/experimental/utilities/meta/meta.type.synop/includes.pass.cpp new file mode 100644 index 00000000000..2c90dd64181 --- /dev/null +++ b/libcxx/test/std/experimental/utilities/meta/meta.type.synop/includes.pass.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <experimental/type_traits> + +#include <experimental/type_traits> + +#if _LIBCPP_STD_VER > 11 +# ifndef _LIBCPP_TYPE_TRAITS +# error "<experimental/type_traits> must include <type_traits>" +# endif +#endif + +int main() +{ +} diff --git a/libcxx/test/std/experimental/utilities/meta/meta.type.synop/meta.rel.pass.cpp b/libcxx/test/std/experimental/utilities/meta/meta.type.synop/meta.rel.pass.cpp new file mode 100644 index 00000000000..96af4b67618 --- /dev/null +++ b/libcxx/test/std/experimental/utilities/meta/meta.type.synop/meta.rel.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. +// +//===----------------------------------------------------------------------===// + +// <experimental/type_traits> + +#include <experimental/type_traits> + +#if _LIBCPP_STD_VER > 11 + +namespace ex = std::experimental; + +struct base_type {}; +struct derived_type : base_type {}; + +int main() +{ + { + typedef int T; + typedef int U; + static_assert(ex::is_same_v<T, U>, ""); + static_assert(std::is_same<decltype(ex::is_same_v<T, U>), const bool>::value, ""); + static_assert(ex::is_same_v<T, U> == std::is_same<T, U>::value, ""); + } + { + typedef int T; + typedef long U; + static_assert(!ex::is_same_v<T, U>, ""); + static_assert(ex::is_same_v<T, U> == std::is_same<T, U>::value, ""); + } + { + typedef base_type T; + typedef derived_type U; + static_assert(ex::is_base_of_v<T, U>, ""); + static_assert(std::is_same<decltype(ex::is_base_of_v<T, U>), const bool>::value, ""); + static_assert(ex::is_base_of_v<T, U> == std::is_base_of<T, U>::value, ""); + } + { + typedef int T; + typedef int U; + static_assert(!ex::is_base_of_v<T, U>, ""); + static_assert(ex::is_base_of_v<T, U> == std::is_base_of<T, U>::value, ""); + } + { + typedef int T; + typedef long U; + static_assert(ex::is_convertible_v<T, U>, ""); + static_assert(std::is_same<decltype(ex::is_convertible_v<T, U>), const bool>::value, ""); + static_assert(ex::is_convertible_v<T, U> == std::is_convertible<T, U>::value, ""); + } + { + typedef void T; + typedef int U; + static_assert(!ex::is_convertible_v<T, U>, ""); + static_assert(ex::is_convertible_v<T, U> == std::is_convertible<T, U>::value, ""); + } +} +#else /* _LIBCPP_STD_VER <= 11 */ +int main() {} +#endif /* _LIBCPP_STD_VER > 11 */ diff --git a/libcxx/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.cat.pass.cpp b/libcxx/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.cat.pass.cpp new file mode 100644 index 00000000000..2d1e706f67d --- /dev/null +++ b/libcxx/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.cat.pass.cpp @@ -0,0 +1,181 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <experimental/type_traits> + +#include <experimental/type_traits> + +#if _LIBCPP_STD_VER > 11 + +namespace ex = std::experimental; + +struct class_type {}; +enum enum_type {}; +union union_type {}; + +int main() +{ + { + typedef void T; + static_assert(ex::is_void_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_void_v<T>), const bool>::value, ""); + static_assert(ex::is_void_v<T> == std::is_void<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_void_v<T>, ""); + static_assert(ex::is_void_v<T> == std::is_void<T>::value, ""); + } + { + typedef decltype(nullptr) T; + static_assert(ex::is_null_pointer_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_null_pointer_v<T>), const bool>::value, ""); + static_assert(ex::is_null_pointer_v<T> == std::is_null_pointer<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_null_pointer_v<T>, ""); + static_assert(ex::is_null_pointer_v<T> == std::is_null_pointer<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_integral_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_integral_v<T>), const bool>::value, ""); + static_assert(ex::is_integral_v<T> == std::is_integral<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_integral_v<T>, ""); + static_assert(ex::is_integral_v<T> == std::is_integral<T>::value, ""); + } + { + typedef float T; + static_assert(ex::is_floating_point_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_floating_point_v<T>), const bool>::value, ""); + static_assert(ex::is_floating_point_v<T> == std::is_floating_point<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_floating_point_v<T>, ""); + static_assert(ex::is_floating_point_v<T> == std::is_floating_point<T>::value, ""); + } + { + typedef int(T)[42]; + static_assert(ex::is_array_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_array_v<T>), const bool>::value, ""); + static_assert(ex::is_array_v<T> == std::is_array<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_array_v<T>, ""); + static_assert(ex::is_array_v<T> == std::is_array<T>::value, ""); + } + { + typedef void* T; + static_assert(ex::is_pointer_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_pointer_v<T>), const bool>::value, ""); + static_assert(ex::is_pointer_v<T> == std::is_pointer<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_pointer_v<T>, ""); + static_assert(ex::is_pointer_v<T> == std::is_pointer<T>::value, ""); + } + { + typedef int & T; + static_assert(ex::is_lvalue_reference_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_lvalue_reference_v<T>), const bool>::value, ""); + static_assert(ex::is_lvalue_reference_v<T> == std::is_lvalue_reference<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_lvalue_reference_v<T>, ""); + static_assert(ex::is_lvalue_reference_v<T> == std::is_lvalue_reference<T>::value, ""); + } + { + typedef int && T; + static_assert(ex::is_rvalue_reference_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_rvalue_reference_v<T>), const bool>::value, ""); + static_assert(ex::is_rvalue_reference_v<T> == std::is_rvalue_reference<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_rvalue_reference_v<T>, ""); + static_assert(ex::is_rvalue_reference_v<T> == std::is_rvalue_reference<T>::value, ""); + } + { + typedef int class_type::*T; + static_assert(ex::is_member_object_pointer_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_member_object_pointer_v<T>), const bool>::value, ""); + static_assert(ex::is_member_object_pointer_v<T> == std::is_member_object_pointer<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_member_object_pointer_v<T>, ""); + static_assert(ex::is_member_object_pointer_v<T> == std::is_member_object_pointer<T>::value, ""); + } + { + typedef void(class_type::*T)(); + static_assert(ex::is_member_function_pointer_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_member_function_pointer_v<T>), const bool>::value, ""); + static_assert(ex::is_member_function_pointer_v<T> == std::is_member_function_pointer<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_member_function_pointer_v<T>, ""); + static_assert(ex::is_member_function_pointer_v<T> == std::is_member_function_pointer<T>::value, ""); + } + { + typedef enum_type T; + static_assert(ex::is_enum_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_enum_v<T>), const bool>::value, ""); + static_assert(ex::is_enum_v<T> == std::is_enum<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_enum_v<T>, ""); + static_assert(ex::is_enum_v<T> == std::is_enum<T>::value, ""); + } + { + typedef union_type T; + static_assert(ex::is_union_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_union_v<T>), const bool>::value, ""); + static_assert(ex::is_union_v<T> == std::is_union<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_union_v<T>, ""); + static_assert(ex::is_union_v<T> == std::is_union<T>::value, ""); + } + { + typedef class_type T; + static_assert(ex::is_class_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_class_v<T>), const bool>::value, ""); + static_assert(ex::is_class_v<T> == std::is_class<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_class_v<T>, ""); + static_assert(ex::is_class_v<T> == std::is_class<T>::value, ""); + } + { + typedef void(T)(); + static_assert(ex::is_function_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_function_v<T>), const bool>::value, ""); + static_assert(ex::is_function_v<T> == std::is_function<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_function_v<T>, ""); + static_assert(ex::is_function_v<T> == std::is_function<T>::value, ""); + } +} +#else /* _LIBCPP_STD_VER <= 11 */ +int main() {} +#endif /* _LIBCPP_STD_VER > 11 */ diff --git a/libcxx/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.comp.pass.cpp b/libcxx/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.comp.pass.cpp new file mode 100644 index 00000000000..814f450f4e0 --- /dev/null +++ b/libcxx/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.comp.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. +// +//===----------------------------------------------------------------------===// + +// <experimental/type_traits> + +#include <experimental/type_traits> + +#if _LIBCPP_STD_VER > 11 + +namespace ex = std::experimental; + +struct class_type {}; + +int main() +{ + { + typedef int & T; + static_assert(ex::is_reference_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_reference_v<T>), const bool>::value, ""); + static_assert(ex::is_reference_v<T> == std::is_reference<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_reference_v<T>, ""); + static_assert(ex::is_reference_v<T> == std::is_reference<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_arithmetic_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_arithmetic_v<T>), const bool>::value, ""); + static_assert(ex::is_arithmetic_v<T> == std::is_arithmetic<T>::value, ""); + } + { + typedef void* T; + static_assert(!ex::is_arithmetic_v<T>, ""); + static_assert(ex::is_arithmetic_v<T> == std::is_arithmetic<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_fundamental_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_fundamental_v<T>), const bool>::value, ""); + static_assert(ex::is_fundamental_v<T> == std::is_fundamental<T>::value, ""); + } + { + typedef class_type T; + static_assert(!ex::is_fundamental_v<T>, ""); + static_assert(ex::is_fundamental_v<T> == std::is_fundamental<T>::value, ""); + } + { + typedef class_type T; + static_assert(ex::is_object_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_object_v<T>), const bool>::value, ""); + static_assert(ex::is_object_v<T> == std::is_object<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_object_v<T>, ""); + static_assert(ex::is_object_v<T> == std::is_object<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_scalar_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_scalar_v<T>), const bool>::value, ""); + static_assert(ex::is_scalar_v<T> == std::is_scalar<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_scalar_v<T>, ""); + static_assert(ex::is_scalar_v<T> == std::is_scalar<T>::value, ""); + } + { + typedef void* T; + static_assert(ex::is_compound_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_compound_v<T>), const bool>::value, ""); + static_assert(ex::is_compound_v<T> == std::is_compound<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_compound_v<T>, ""); + static_assert(ex::is_compound_v<T> == std::is_compound<T>::value, ""); + } + { + typedef int class_type::*T; + static_assert(ex::is_member_pointer_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_member_pointer_v<T>), const bool>::value, ""); + static_assert(ex::is_member_pointer_v<T> == std::is_member_pointer<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_member_pointer_v<T>, ""); + static_assert(ex::is_member_pointer_v<T> == std::is_member_pointer<T>::value, ""); + } +} +#else /* _LIBCPP_STD_VER <= 11 */ +int main() {} +#endif /* _LIBCPP_STD_VER > 11 */ diff --git a/libcxx/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.pass.cpp b/libcxx/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.pass.cpp new file mode 100644 index 00000000000..41cb27fced3 --- /dev/null +++ b/libcxx/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.pass.cpp @@ -0,0 +1,489 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <experimental/type_traits> + +#include <experimental/type_traits> + +#if _LIBCPP_STD_VER > 11 + +namespace ex = std::experimental; + +struct non_literal_type { non_literal_type() {} }; +struct empty_type {}; + +struct polymorphic_type +{ + virtual void foo() {} +}; + +struct abstract_type +{ + virtual void foo() = 0; +}; + +struct final_type final {}; + +struct virtual_dtor_type +{ + virtual ~virtual_dtor_type() {} +}; + +void type_properties_test() +{ + { + typedef const int T; + static_assert(ex::is_const_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_const_v<T>), const bool>::value, ""); + static_assert(ex::is_const_v<T> == std::is_const<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_const_v<T>, ""); + static_assert(ex::is_const_v<T> == std::is_const<T>::value, ""); + } + { + typedef volatile int T; + static_assert(ex::is_volatile_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_volatile_v<T>), const bool>::value, ""); + static_assert(ex::is_volatile_v<T> == std::is_volatile<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_volatile_v<T>, ""); + static_assert(ex::is_volatile_v<T> == std::is_volatile<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivial_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_trivial_v<T>), const bool>::value, ""); + static_assert(ex::is_trivial_v<T> == std::is_trivial<T>::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_trivial_v<T>, ""); + static_assert(ex::is_trivial_v<T> == std::is_trivial<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_copyable_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_trivially_copyable_v<T>), const bool>::value, ""); + static_assert(ex::is_trivially_copyable_v<T> == std::is_trivially_copyable<T>::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_trivially_copyable_v<T>, ""); + static_assert(ex::is_trivially_copyable_v<T> == std::is_trivially_copyable<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_standard_layout_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_standard_layout_v<T>), const bool>::value, ""); + static_assert(ex::is_standard_layout_v<T> == std::is_standard_layout<T>::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_standard_layout_v<T>, ""); + static_assert(ex::is_standard_layout_v<T> == std::is_standard_layout<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_pod_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_pod_v<T>), const bool>::value, ""); + static_assert(ex::is_pod_v<T> == std::is_pod<T>::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_pod_v<T>, ""); + static_assert(ex::is_pod_v<T> == std::is_pod<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_literal_type_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_literal_type_v<T>), const bool>::value, ""); + static_assert(ex::is_literal_type_v<T> == std::is_literal_type<T>::value, ""); + } + { + typedef non_literal_type T; + static_assert(!ex::is_literal_type_v<T>, ""); + static_assert(ex::is_literal_type_v<T> == std::is_literal_type<T>::value, ""); + } + { + typedef empty_type T; + static_assert(ex::is_empty_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_empty_v<T>), const bool>::value, ""); + static_assert(ex::is_empty_v<T> == std::is_empty<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_empty_v<T>, ""); + static_assert(ex::is_empty_v<T> == std::is_empty<T>::value, ""); + } + { + typedef polymorphic_type T; + static_assert(ex::is_polymorphic_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_polymorphic_v<T>), const bool>::value, ""); + static_assert(ex::is_polymorphic_v<T> == std::is_polymorphic<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_polymorphic_v<T>, ""); + static_assert(ex::is_polymorphic_v<T> == std::is_polymorphic<T>::value, ""); + } + { + typedef abstract_type T; + static_assert(ex::is_abstract_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_abstract_v<T>), const bool>::value, ""); + static_assert(ex::is_abstract_v<T> == std::is_abstract<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_abstract_v<T>, ""); + static_assert(ex::is_abstract_v<T> == std::is_abstract<T>::value, ""); + } + { + typedef final_type T; + static_assert(ex::is_final_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_final_v<T>), const bool>::value, ""); + static_assert(ex::is_final_v<T> == std::is_final<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_final_v<T>, ""); + static_assert(ex::is_final_v<T> == std::is_final<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_signed_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_signed_v<T>), const bool>::value, ""); + static_assert(ex::is_signed_v<T> == std::is_signed<T>::value, ""); + } + { + typedef unsigned T; + static_assert(!ex::is_signed_v<T>, ""); + static_assert(ex::is_signed_v<T> == std::is_signed<T>::value, ""); + } + { + typedef unsigned T; + static_assert(ex::is_unsigned_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_unsigned_v<T>), const bool>::value, ""); + static_assert(ex::is_unsigned_v<T> == std::is_unsigned<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_unsigned_v<T>, ""); + static_assert(ex::is_unsigned_v<T> == std::is_unsigned<T>::value, ""); + } +} + +void is_constructible_and_assignable_test() +{ + { + typedef int T; + static_assert(ex::is_constructible_v<T, int>, ""); + static_assert(std::is_same<decltype(ex::is_constructible_v<T, int>), const bool>::value, ""); + static_assert(ex::is_constructible_v<T, int> == std::is_constructible<T, int>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_constructible_v<T, int>, ""); + static_assert(ex::is_constructible_v<T, int> == std::is_constructible<T, int>::value, ""); + } + { + typedef int T; + static_assert(ex::is_default_constructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_default_constructible_v<T>), const bool>::value, ""); + static_assert(ex::is_default_constructible_v<T> == std::is_default_constructible<T>::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_default_constructible_v<T>, ""); + static_assert(ex::is_default_constructible_v<T> == std::is_default_constructible<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_copy_constructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_copy_constructible_v<T>), const bool>::value, ""); + static_assert(ex::is_copy_constructible_v<T> == std::is_copy_constructible<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_copy_constructible_v<T>, ""); + static_assert(ex::is_copy_constructible_v<T> == std::is_copy_constructible<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_move_constructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_move_constructible_v<T>), const bool>::value, ""); + static_assert(ex::is_move_constructible_v<T> == std::is_move_constructible<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_move_constructible_v<T>, ""); + static_assert(ex::is_move_constructible_v<T> == std::is_move_constructible<T>::value, ""); + } + { + typedef int & T; + typedef int U; + static_assert(ex::is_assignable_v<T, U>, ""); + static_assert(std::is_same<decltype(ex::is_assignable_v<T, U>), const bool>::value, ""); + static_assert(ex::is_assignable_v<T, U> == std::is_assignable<T, U>::value, ""); + } + { + typedef int & T; + typedef void U; + static_assert(!ex::is_assignable_v<T, U>, ""); + static_assert(ex::is_assignable_v<T, U> == std::is_assignable<T, U>::value, ""); + } + { + typedef int T; + static_assert(ex::is_copy_assignable_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_copy_assignable_v<T>), const bool>::value, ""); + static_assert(ex::is_copy_assignable_v<T> == std::is_copy_assignable<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_copy_assignable_v<T>, ""); + static_assert(ex::is_copy_assignable_v<T> == std::is_copy_assignable<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_move_assignable_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_move_assignable_v<T>), const bool>::value, ""); + static_assert(ex::is_move_assignable_v<T> == std::is_move_assignable<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_move_assignable_v<T>, ""); + static_assert(ex::is_move_assignable_v<T> == std::is_move_assignable<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_destructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_destructible_v<T>), const bool>::value, ""); + static_assert(ex::is_destructible_v<T> == std::is_destructible<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_destructible_v<T>, ""); + static_assert(ex::is_destructible_v<T> == std::is_destructible<T>::value, ""); + } +} + +void is_trivially_constructible_and_assignable_test() +{ + { + typedef int T; + static_assert(ex::is_trivially_constructible_v<T, int>, ""); + static_assert(std::is_same<decltype(ex::is_trivially_constructible_v<T, int>), const bool>::value, ""); + static_assert(ex::is_trivially_constructible_v<T, int> == std::is_constructible<T, int>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_constructible_v<T, int>, ""); + static_assert(ex::is_trivially_constructible_v<T, int> == std::is_constructible<T, int>::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_default_constructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_trivially_default_constructible_v<T>), const bool>::value, ""); + static_assert(ex::is_trivially_default_constructible_v<T> == std::is_default_constructible<T>::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_trivially_default_constructible_v<T>, ""); + static_assert(ex::is_trivially_default_constructible_v<T> == std::is_default_constructible<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_copy_constructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_trivially_copy_constructible_v<T>), const bool>::value, ""); + static_assert(ex::is_trivially_copy_constructible_v<T> == std::is_copy_constructible<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_copy_constructible_v<T>, ""); + static_assert(ex::is_trivially_copy_constructible_v<T> == std::is_copy_constructible<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_move_constructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_trivially_move_constructible_v<T>), const bool>::value, ""); + static_assert(ex::is_trivially_move_constructible_v<T> == std::is_move_constructible<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_move_constructible_v<T>, ""); + static_assert(ex::is_trivially_move_constructible_v<T> == std::is_move_constructible<T>::value, ""); + } + { + typedef int & T; + typedef int U; + static_assert(ex::is_trivially_assignable_v<T, U>, ""); + static_assert(std::is_same<decltype(ex::is_trivially_assignable_v<T, U>), const bool>::value, ""); + static_assert(ex::is_trivially_assignable_v<T, U> == std::is_assignable<T, U>::value, ""); + } + { + typedef int & T; + typedef void U; + static_assert(!ex::is_trivially_assignable_v<T, U>, ""); + static_assert(ex::is_trivially_assignable_v<T, U> == std::is_assignable<T, U>::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_copy_assignable_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_trivially_copy_assignable_v<T>), const bool>::value, ""); + static_assert(ex::is_trivially_copy_assignable_v<T> == std::is_copy_assignable<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_copy_assignable_v<T>, ""); + static_assert(ex::is_trivially_copy_assignable_v<T> == std::is_copy_assignable<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_move_assignable_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_trivially_move_assignable_v<T>), const bool>::value, ""); + static_assert(ex::is_trivially_move_assignable_v<T> == std::is_move_assignable<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_move_assignable_v<T>, ""); + static_assert(ex::is_trivially_move_assignable_v<T> == std::is_move_assignable<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_destructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_trivially_destructible_v<T>), const bool>::value, ""); + static_assert(ex::is_trivially_destructible_v<T> == std::is_destructible<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_destructible_v<T>, ""); + static_assert(ex::is_trivially_destructible_v<T> == std::is_destructible<T>::value, ""); + } +} + + + +void is_nothrow_constructible_and_assignable_test() +{ + { + typedef int T; + static_assert(ex::is_nothrow_constructible_v<T, int>, ""); + static_assert(std::is_same<decltype(ex::is_nothrow_constructible_v<T, int>), const bool>::value, ""); + static_assert(ex::is_nothrow_constructible_v<T, int> == std::is_constructible<T, int>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_constructible_v<T, int>, ""); + static_assert(ex::is_nothrow_constructible_v<T, int> == std::is_constructible<T, int>::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_default_constructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_nothrow_default_constructible_v<T>), const bool>::value, ""); + static_assert(ex::is_nothrow_default_constructible_v<T> == std::is_default_constructible<T>::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_nothrow_default_constructible_v<T>, ""); + static_assert(ex::is_nothrow_default_constructible_v<T> == std::is_default_constructible<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_copy_constructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_nothrow_copy_constructible_v<T>), const bool>::value, ""); + static_assert(ex::is_nothrow_copy_constructible_v<T> == std::is_copy_constructible<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_copy_constructible_v<T>, ""); + static_assert(ex::is_nothrow_copy_constructible_v<T> == std::is_copy_constructible<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_move_constructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_nothrow_move_constructible_v<T>), const bool>::value, ""); + static_assert(ex::is_nothrow_move_constructible_v<T> == std::is_move_constructible<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_move_constructible_v<T>, ""); + static_assert(ex::is_nothrow_move_constructible_v<T> == std::is_move_constructible<T>::value, ""); + } + { + typedef int & T; + typedef int U; + static_assert(ex::is_nothrow_assignable_v<T, U>, ""); + static_assert(std::is_same<decltype(ex::is_nothrow_assignable_v<T, U>), const bool>::value, ""); + static_assert(ex::is_nothrow_assignable_v<T, U> == std::is_assignable<T, U>::value, ""); + } + { + typedef int & T; + typedef void U; + static_assert(!ex::is_nothrow_assignable_v<T, U>, ""); + static_assert(ex::is_nothrow_assignable_v<T, U> == std::is_assignable<T, U>::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_copy_assignable_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_nothrow_copy_assignable_v<T>), const bool>::value, ""); + static_assert(ex::is_nothrow_copy_assignable_v<T> == std::is_copy_assignable<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_copy_assignable_v<T>, ""); + static_assert(ex::is_nothrow_copy_assignable_v<T> == std::is_copy_assignable<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_move_assignable_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_nothrow_move_assignable_v<T>), const bool>::value, ""); + static_assert(ex::is_nothrow_move_assignable_v<T> == std::is_move_assignable<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_move_assignable_v<T>, ""); + static_assert(ex::is_nothrow_move_assignable_v<T> == std::is_move_assignable<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_destructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_nothrow_destructible_v<T>), const bool>::value, ""); + static_assert(ex::is_nothrow_destructible_v<T> == std::is_destructible<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_destructible_v<T>, ""); + static_assert(ex::is_nothrow_destructible_v<T> == std::is_destructible<T>::value, ""); + } +} + +int main() +{ + type_properties_test(); + is_constructible_and_assignable_test(); + is_trivially_constructible_and_assignable_test(); + is_nothrow_constructible_and_assignable_test(); + { + typedef virtual_dtor_type T; + static_assert(ex::has_virtual_destructor_v<T>, ""); + static_assert(std::is_same<decltype(ex::has_virtual_destructor_v<T>), const bool>::value, ""); + static_assert(ex::has_virtual_destructor_v<T> == std::has_virtual_destructor<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::has_virtual_destructor_v<T>, ""); + static_assert(ex::has_virtual_destructor_v<T> == std::has_virtual_destructor<T>::value, ""); + } +} +#else /* _LIBCPP_STD_VER <= 11 */ +int main() {} +#endif /* _LIBCPP_STD_VER > 11 */ diff --git a/libcxx/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.query.pass.cpp b/libcxx/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.query.pass.cpp new file mode 100644 index 00000000000..aedd369e5ac --- /dev/null +++ b/libcxx/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.query.pass.cpp @@ -0,0 +1,66 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <experimental/type_traits> + +#include <experimental/type_traits> + +#if _LIBCPP_STD_VER > 11 + +namespace ex = std::experimental; + +int main() +{ + { + typedef char T; + static_assert(ex::alignment_of_v<T> == 1, ""); + static_assert(std::is_same<decltype(ex::alignment_of_v<T>), const std::size_t>::value, ""); + static_assert(ex::alignment_of_v<T> == std::alignment_of<T>::value, ""); + } + { + typedef char(T)[1][1][1]; + static_assert(ex::rank_v<T> == 3, ""); + static_assert(std::is_same<decltype(ex::rank_v<T>), const std::size_t>::value, ""); + static_assert(ex::rank_v<T> == std::rank<T>::value, ""); + } + { + typedef void T; + static_assert(ex::rank_v<T> == 0, ""); + static_assert(ex::rank_v<T> == std::rank<T>::value, ""); + } + { + typedef char(T)[2][3][4]; + static_assert(ex::extent_v<T> == 2, ""); + static_assert(std::is_same<decltype(ex::extent_v<T>), const std::size_t>::value, ""); + static_assert(ex::extent_v<T> == std::extent<T>::value, ""); + } + { + typedef char(T)[2][3][4]; + static_assert(ex::extent_v<T, 0> == 2, ""); + static_assert(ex::extent_v<T, 0> == std::extent<T, 0>::value, ""); + } + { + typedef char(T)[2][3][4]; + static_assert(ex::extent_v<T, 1> == 3, ""); + static_assert(ex::extent_v<T, 1> == std::extent<T, 1>::value, ""); + } + { + typedef char(T)[2][3][4]; + static_assert(ex::extent_v<T, 5> == 0, ""); + static_assert(ex::extent_v<T, 5> == std::extent<T, 5>::value, ""); + } + { + typedef void T; + static_assert(ex::extent_v<T, 0> == 0, ""); + static_assert(ex::extent_v<T, 0> == std::extent<T, 0>::value, ""); + } +} +#else /* _LIBCPP_STD_VER <= 11 */ +int main() {} +#endif /* _LIBCPP_STD_VER > 11 */ diff --git a/libcxx/test/std/experimental/utilities/meta/version.pass.cpp b/libcxx/test/std/experimental/utilities/meta/version.pass.cpp new file mode 100644 index 00000000000..593fb52a4c3 --- /dev/null +++ b/libcxx/test/std/experimental/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. +// +//===----------------------------------------------------------------------===// + +// <experimental/type_traits> + +#include <experimental/type_traits> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/libcxx/test/std/experimental/utilities/nothing_to_do.pass.cpp b/libcxx/test/std/experimental/utilities/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..9a59227abdd --- /dev/null +++ b/libcxx/test/std/experimental/utilities/nothing_to_do.pass.cpp @@ -0,0 +1,13 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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/experimental/utilities/utility/utility.erased.type/erased_type.pass.cpp b/libcxx/test/std/experimental/utilities/utility/utility.erased.type/erased_type.pass.cpp new file mode 100644 index 00000000000..3e38d5ec503 --- /dev/null +++ b/libcxx/test/std/experimental/utilities/utility/utility.erased.type/erased_type.pass.cpp @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <experimental/utility> + +#include <experimental/utility> + +int main() +{ + std::experimental::erased_type e(); +} diff --git a/libcxx/test/std/experimental/utilities/utility/utility.synop/includes.pass.cpp b/libcxx/test/std/experimental/utilities/utility/utility.synop/includes.pass.cpp new file mode 100644 index 00000000000..2583d434540 --- /dev/null +++ b/libcxx/test/std/experimental/utilities/utility/utility.synop/includes.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. +// +//===----------------------------------------------------------------------===// + +// <experimental/utility> + +#include <experimental/utility> + +#ifndef _LIBCPP_UTILITY +# error "<experimental/utility> must include <utility>" +#endif + +int main() +{ +} diff --git a/libcxx/test/std/experimental/utilities/utility/version.pass.cpp b/libcxx/test/std/experimental/utilities/utility/version.pass.cpp new file mode 100644 index 00000000000..437712454ae --- /dev/null +++ b/libcxx/test/std/experimental/utilities/utility/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. +// +//===----------------------------------------------------------------------===// + +// <experimental/utility> + +#include <experimental/utility> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} |