diff options
Diffstat (limited to 'test/std/experimental/utilities')
36 files changed, 3108 insertions, 0 deletions
diff --git a/test/std/experimental/utilities/meta/meta.type.synop/includes.pass.cpp b/test/std/experimental/utilities/meta/meta.type.synop/includes.pass.cpp new file mode 100644 index 000000000000..2c90dd641813 --- /dev/null +++ b/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/test/std/experimental/utilities/meta/meta.type.synop/meta.rel.pass.cpp b/test/std/experimental/utilities/meta/meta.type.synop/meta.rel.pass.cpp new file mode 100644 index 000000000000..96af4b676181 --- /dev/null +++ b/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/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.cat.pass.cpp b/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.cat.pass.cpp new file mode 100644 index 000000000000..2d1e706f67d2 --- /dev/null +++ b/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/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.comp.pass.cpp b/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.comp.pass.cpp new file mode 100644 index 000000000000..814f450f4e07 --- /dev/null +++ b/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/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.pass.cpp b/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.pass.cpp new file mode 100644 index 000000000000..41cb27fced37 --- /dev/null +++ b/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/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.query.pass.cpp b/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.query.pass.cpp new file mode 100644 index 000000000000..aedd369e5ac8 --- /dev/null +++ b/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/test/std/experimental/utilities/meta/version.pass.cpp b/test/std/experimental/utilities/meta/version.pass.cpp new file mode 100644 index 000000000000..593fb52a4c3b --- /dev/null +++ b/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/test/std/experimental/utilities/nothing_to_do.pass.cpp b/test/std/experimental/utilities/nothing_to_do.pass.cpp new file mode 100644 index 000000000000..9a59227abdd9 --- /dev/null +++ b/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/test/std/experimental/utilities/ratio/header.ratio.synop/includes.pass.cpp b/test/std/experimental/utilities/ratio/header.ratio.synop/includes.pass.cpp new file mode 100644 index 000000000000..f19a8211cdac --- /dev/null +++ b/test/std/experimental/utilities/ratio/header.ratio.synop/includes.pass.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <experimental/ratio> + +// Test that <ratio> is included. + +#include <experimental/ratio> + +int main() +{ + std::ratio<100> x; +} diff --git a/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_equal_v.pass.cpp b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_equal_v.pass.cpp new file mode 100644 index 000000000000..641e6ae22cc8 --- /dev/null +++ b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_equal_v.pass.cpp @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <experimental/ratio> + +// template <class R1, class R2> constexpr bool ratio_equal_v; + +#include <experimental/ratio> +#include <type_traits> + +namespace ex = std::experimental; + +int main() +{ + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert( + ex::ratio_equal_v<R1, R2>, "" + ); + static_assert( + ex::ratio_equal_v<R1, R2> == std::ratio_equal<R1, R2>::value, "" + ); + static_assert( + std::is_same<decltype(ex::ratio_equal_v<R1, R2>), const bool>::value + , "" + ); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, -1> R2; + static_assert( + !ex::ratio_equal_v<R1, R2>, "" + ); + static_assert( + ex::ratio_equal_v<R1, R2> == std::ratio_equal<R1, R2>::value, "" + ); + } +} diff --git a/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_greater_equal_v.pass.cpp b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_greater_equal_v.pass.cpp new file mode 100644 index 000000000000..3896d0ac64dc --- /dev/null +++ b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_greater_equal_v.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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <experimental/ratio> + +// template <class R1, class R2> constexpr bool ratio_greater_equal_v; + +#include <experimental/ratio> +#include <type_traits> + +namespace ex = std::experimental; + +int main() +{ + { + typedef std::ratio<1, 2> R1; + typedef std::ratio<1, 1> R2; + static_assert( + !ex::ratio_greater_equal_v<R1, R2>, "" + ); + static_assert( + ex::ratio_greater_equal_v<R1, R2> + == std::ratio_greater_equal<R1, R2>::value, "" + ); + static_assert( + std::is_same< + decltype(ex::ratio_greater_equal_v<R1, R2>), const bool>::value + , "" + ); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert( + ex::ratio_greater_equal_v<R1, R2>, "" + ); + static_assert( + ex::ratio_greater_equal_v<R1, R2> + == std::ratio_greater_equal<R1, R2>::value, "" + ); + } + { + typedef std::ratio<2, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert( + ex::ratio_greater_equal_v<R1, R2>, "" + ); + static_assert( + ex::ratio_greater_equal_v<R1, R2> + == std::ratio_greater_equal<R1, R2>::value, "" + ); + } +} diff --git a/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_greater_v.pass.cpp b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_greater_v.pass.cpp new file mode 100644 index 000000000000..bdc54515f629 --- /dev/null +++ b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_greater_v.pass.cpp @@ -0,0 +1,57 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <experimental/ratio> + +// template <class R1, class R2> constexpr bool ratio_greater_v; + +#include <experimental/ratio> +#include <type_traits> + +namespace ex = std::experimental; + +int main() +{ + { + typedef std::ratio<1, 2> R1; + typedef std::ratio<1, 1> R2; + static_assert( + !ex::ratio_greater_v<R1, R2>, "" + ); + static_assert( + ex::ratio_greater_v<R1, R2> == std::ratio_greater<R1, R2>::value, "" + ); + static_assert( + std::is_same<decltype(ex::ratio_greater_v<R1, R2>), const bool>::value + , "" + ); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert( + !ex::ratio_greater_v<R1, R2>, "" + ); + static_assert( + ex::ratio_greater_v<R1, R2> == std::ratio_greater<R1, R2>::value, "" + ); + } + { + typedef std::ratio<2, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert( + ex::ratio_greater_v<R1, R2>, "" + ); + static_assert( + ex::ratio_greater_v<R1, R2> == std::ratio_greater<R1, R2>::value, "" + ); + } +} diff --git a/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_less_equal_v.pass.cpp b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_less_equal_v.pass.cpp new file mode 100644 index 000000000000..50f213b01339 --- /dev/null +++ b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_less_equal_v.pass.cpp @@ -0,0 +1,57 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <experimental/ratio> + +// template <class R1, class R2> constexpr bool ratio_less_equal_v; + +#include <experimental/ratio> +#include <type_traits> + +namespace ex = std::experimental; + +int main() +{ + { + typedef std::ratio<1, 2> R1; + typedef std::ratio<1, 1> R2; + static_assert( + ex::ratio_less_equal_v<R1, R2>, "" + ); + static_assert( + ex::ratio_less_equal_v<R1, R2> == std::ratio_less_equal<R1, R2>::value, "" + ); + static_assert( + std::is_same<decltype(ex::ratio_less_equal_v<R1, R2>), const bool>::value + , "" + ); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert( + ex::ratio_less_equal_v<R1, R2>, "" + ); + static_assert( + ex::ratio_less_equal_v<R1, R2> == std::ratio_less_equal<R1, R2>::value, "" + ); + } + { + typedef std::ratio<2, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert( + !ex::ratio_less_equal_v<R1, R2>, "" + ); + static_assert( + ex::ratio_less_equal_v<R1, R2> == std::ratio_less_equal<R1, R2>::value, "" + ); + } +} diff --git a/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_less_v.pass.cpp b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_less_v.pass.cpp new file mode 100644 index 000000000000..7a6d7738bd9d --- /dev/null +++ b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_less_v.pass.cpp @@ -0,0 +1,57 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <experimental/ratio> + +// template <class R1, class R2> constexpr bool ratio_less_v; + +#include <experimental/ratio> +#include <type_traits> + +namespace ex = std::experimental; + +int main() +{ + { + typedef std::ratio<1, 2> R1; + typedef std::ratio<1, 1> R2; + static_assert( + ex::ratio_less_v<R1, R2>, "" + ); + static_assert( + ex::ratio_less_v<R1, R2> == std::ratio_less<R1, R2>::value, "" + ); + static_assert( + std::is_same<decltype(ex::ratio_less_v<R1, R2>), const bool>::value + , "" + ); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert( + !ex::ratio_less_v<R1, R2>, "" + ); + static_assert( + ex::ratio_less_v<R1, R2> == std::ratio_less<R1, R2>::value, "" + ); + } + { + typedef std::ratio<2, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert( + !ex::ratio_less_v<R1, R2>, "" + ); + static_assert( + ex::ratio_less_v<R1, R2> == std::ratio_less<R1, R2>::value, "" + ); + } +} diff --git a/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_not_equal_v.pass.cpp b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_not_equal_v.pass.cpp new file mode 100644 index 000000000000..b5296ff24ef1 --- /dev/null +++ b/test/std/experimental/utilities/ratio/header.ratio.synop/ratio_not_equal_v.pass.cpp @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <experimental/ratio> + +// template <class R1, class R2> constexpr bool ratio_not_equal_v; + +#include <experimental/ratio> +#include <type_traits> + +namespace ex = std::experimental; + +int main() +{ + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, -1> R2; + static_assert( + ex::ratio_not_equal_v<R1, R2>, "" + ); + static_assert( + ex::ratio_not_equal_v<R1, R2> == std::ratio_not_equal<R1, R2>::value, "" + ); + static_assert( + std::is_same<decltype(ex::ratio_not_equal_v<R1, R2>), const bool>::value + , "" + ); + } + { + typedef std::ratio<1, 1> R1; + typedef std::ratio<1, 1> R2; + static_assert( + !ex::ratio_not_equal_v<R1, R2>, "" + ); + static_assert( + ex::ratio_not_equal_v<R1, R2> == std::ratio_not_equal<R1, R2>::value, "" + ); + } +} diff --git a/test/std/experimental/utilities/ratio/nothing_to_do.pass.cpp b/test/std/experimental/utilities/ratio/nothing_to_do.pass.cpp new file mode 100644 index 000000000000..9a59227abdd9 --- /dev/null +++ b/test/std/experimental/utilities/ratio/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/test/std/experimental/utilities/syserror/header.system_error.synop/includes.pass.cpp b/test/std/experimental/utilities/syserror/header.system_error.synop/includes.pass.cpp new file mode 100644 index 000000000000..de813925f218 --- /dev/null +++ b/test/std/experimental/utilities/syserror/header.system_error.synop/includes.pass.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <experimental/system_error> + +#include <experimental/system_error> + +int main() +{ + // Check that <system_error> has been included + std::error_code ec; + ((void)ec); +} diff --git a/test/std/experimental/utilities/syserror/header.system_error.synop/is_error_code_enum_v.pass.cpp b/test/std/experimental/utilities/syserror/header.system_error.synop/is_error_code_enum_v.pass.cpp new file mode 100644 index 000000000000..f944123ebc06 --- /dev/null +++ b/test/std/experimental/utilities/syserror/header.system_error.synop/is_error_code_enum_v.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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <experimental/system_error> + +// template <class T> constexpr bool is_error_code_enum_v; + +#include <experimental/system_error> +#include <ios> /* for std::io_errc */ + +namespace ex = std::experimental; + +int main() { + { + static_assert(ex::is_error_code_enum_v<std::io_errc>, ""); + + static_assert(ex::is_error_code_enum_v<std::io_errc> == + std::is_error_code_enum <std::io_errc>::value, ""); + + static_assert(std::is_same<decltype(ex::is_error_code_enum_v<std::io_errc>), + const bool>::value, ""); + } + { + static_assert(!ex::is_error_code_enum_v<int>, ""); + + static_assert(ex::is_error_code_enum_v<int> == + std::is_error_code_enum <int>::value, ""); + } +} diff --git a/test/std/experimental/utilities/syserror/header.system_error.synop/is_error_condition_enum.pass.cpp b/test/std/experimental/utilities/syserror/header.system_error.synop/is_error_condition_enum.pass.cpp new file mode 100644 index 000000000000..ee8dc57aa9db --- /dev/null +++ b/test/std/experimental/utilities/syserror/header.system_error.synop/is_error_condition_enum.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <experimental/system_error> + +// template <class T> constexpr bool is_error_condition_enum_v; + +#include <experimental/system_error> +#include <type_traits> +namespace ex = std::experimental; + +int main() { + { + static_assert(ex::is_error_condition_enum_v<std::errc>, ""); + + static_assert(ex::is_error_condition_enum_v<std::errc> == + std::is_error_condition_enum <std::errc>::value, ""); + + static_assert( + std::is_same<decltype(ex::is_error_condition_enum_v<std::errc>), + const bool>::value, + ""); + } + { + static_assert(!ex::is_error_condition_enum_v<int>, ""); + + static_assert(ex::is_error_condition_enum_v<int> == + std::is_error_condition_enum <int>::value, ""); + } +} diff --git a/test/std/experimental/utilities/time/header.chrono.synop/includes.pass.cpp b/test/std/experimental/utilities/time/header.chrono.synop/includes.pass.cpp new file mode 100644 index 000000000000..f6ad37f9ee3e --- /dev/null +++ b/test/std/experimental/utilities/time/header.chrono.synop/includes.pass.cpp @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <experimental/chrono> + +#include <experimental/chrono> + +int main() +{ + // Check that <chrono> has been included. + std::chrono::seconds s; + ((void)s); +} diff --git a/test/std/experimental/utilities/time/header.chrono.synop/treat_as_floating_point_v.pass.cpp b/test/std/experimental/utilities/time/header.chrono.synop/treat_as_floating_point_v.pass.cpp new file mode 100644 index 000000000000..9ac9a2ed1c83 --- /dev/null +++ b/test/std/experimental/utilities/time/header.chrono.synop/treat_as_floating_point_v.pass.cpp @@ -0,0 +1,49 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <experimental/chrono> + +// template <class Rep> constexpr bool treat_as_floating_point_v; + +#include <experimental/chrono> +#include <type_traits> + +namespace ex = std::chrono::experimental; +namespace cr = std::chrono; + +template <class T, bool Expect> +void test() +{ + static_assert( + ex::treat_as_floating_point_v<T> == Expect, "" + ); + static_assert( + ex::treat_as_floating_point_v<T> == cr::treat_as_floating_point<T>::value, "" + ); +} + +int main() +{ + { + static_assert( + std::is_same< + decltype(ex::treat_as_floating_point_v<float>), const bool + >::value, "" + ); + } + test<int, false>(); + test<unsigned, false>(); + test<char, false>(); + test<bool, false>(); + test<float, true>(); + test<double, true>(); + test<long double, true>(); +} diff --git a/test/std/experimental/utilities/tuple/header.tuple.synop/includes.pass.cpp b/test/std/experimental/utilities/tuple/header.tuple.synop/includes.pass.cpp new file mode 100644 index 000000000000..d37557a7b172 --- /dev/null +++ b/test/std/experimental/utilities/tuple/header.tuple.synop/includes.pass.cpp @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <experimental/tuple> + +#include <experimental/tuple> + +int main() +{ + std::tuple<int> x(1); +} diff --git a/test/std/experimental/utilities/tuple/tuple.apply/arg_type.pass.cpp b/test/std/experimental/utilities/tuple/tuple.apply/arg_type.pass.cpp new file mode 100644 index 000000000000..56dc3c6aaa25 --- /dev/null +++ b/test/std/experimental/utilities/tuple/tuple.apply/arg_type.pass.cpp @@ -0,0 +1,182 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <experimental/tuple> + +// template <class F, class T> constexpr decltype(auto) apply(F &&, T &&) + +// Test with different ref/ptr/cv qualified argument types. + +#include <experimental/tuple> +#include <array> +#include <utility> +#include <cassert> + +namespace ex = std::experimental; + +int call_with_value(int x, int y) { return (x + y); } +int call_with_ref(int & x, int & y) { return (x + y); } +int call_with_const_ref(int const & x, int const & y) { return (x + y); } +int call_with_rvalue_ref(int && x, int && y) { return (x + y); } +int call_with_pointer(int * x, int * y) { return (*x + *y); } +int call_with_const_pointer(int const* x, int const * y) { return (*x + *y); } + + +template <class Tuple> +void test_values() +{ + { + Tuple t{1, 2}; + assert(3 == ex::apply(call_with_value, t)); + } + { + Tuple t{2, 2}; + assert(4 == ex::apply(call_with_ref, t)); + } + { + Tuple t{2, 3}; + assert(5 == ex::apply(call_with_const_ref, t)); + } + { + Tuple t{3, 3}; + assert(6 == ex::apply(call_with_rvalue_ref, static_cast<Tuple &&>(t))); + } + { + Tuple const t{4, 4}; + assert(8 == ex::apply(call_with_value, t)); + } + { + Tuple const t{4, 5}; + assert(9 == ex::apply(call_with_const_ref, t)); + } +} + +template <class Tuple> +void test_refs() +{ + int x = 0; + int y = 0; + { + x = 1; y = 2; + Tuple t{x, y}; + assert(3 == ex::apply(call_with_value, t)); + } + { + x = 2; y = 2; + Tuple t{x, y}; + assert(4 == ex::apply(call_with_ref, t)); + } + { + x = 2; y = 3; + Tuple t{x, y}; + assert(5 == ex::apply(call_with_const_ref, t)); + } + { + x = 3; y = 3; + Tuple const t{x, y}; + assert(6 == ex::apply(call_with_value, t)); + } + { + x = 3; y = 4; + Tuple const t{x, y}; + assert(7 == ex::apply(call_with_const_ref, t)); + } +} + +template <class Tuple> +void test_const_refs() +{ + int x = 0; + int y = 0; + { + x = 1; y = 2; + Tuple t{x, y}; + assert(3 == ex::apply(call_with_value, t)); + } + { + x = 2; y = 3; + Tuple t{x, y}; + assert(5 == ex::apply(call_with_const_ref, t)); + } + { + x = 3; y = 3; + Tuple const t{x, y}; + assert(6 == ex::apply(call_with_value, t)); + } + { + x = 3; y = 4; + Tuple const t{x, y}; + assert(7 == ex::apply(call_with_const_ref, t)); + } +} + + +template <class Tuple> +void test_pointer() +{ + int x = 0; + int y = 0; + { + x = 2; y = 2; + Tuple t{&x, &y}; + assert(4 == ex::apply(call_with_pointer, t)); + } + { + x = 2; y = 3; + Tuple t{&x, &y}; + assert(5 == ex::apply(call_with_const_pointer, t)); + } + { + x = 3; y = 4; + Tuple const t{&x, &y}; + assert(7 == ex::apply(call_with_const_pointer, t)); + } +} + + +template <class Tuple> +void test_const_pointer() +{ + int x = 0; + int y = 0; + { + x = 2; y = 3; + Tuple t{&x, &y}; + assert(5 == ex::apply(call_with_const_pointer, t)); + } + { + x = 3; y = 4; + Tuple const t{&x, &y}; + assert(7 == ex::apply(call_with_const_pointer, t)); + } +} + + +int main() +{ + test_values<std::tuple<int, int>>(); + test_values<std::pair<int, int>>(); + test_values<std::array<int, 2>>(); + + test_refs<std::tuple<int &, int &>>(); + test_refs<std::pair<int &, int &>>(); + + test_const_refs<std::tuple<int const &, int const &>>(); + test_const_refs<std::pair<int const &, int const &>>(); + + test_pointer<std::tuple<int *, int *>>(); + test_pointer<std::pair<int *, int *>>(); + test_pointer<std::array<int *, 2>>(); + + test_const_pointer<std::tuple<int const *, int const *>>(); + test_const_pointer<std::pair<int const *, int const *>>(); + test_const_pointer<std::array<int const *, 2>>(); +} diff --git a/test/std/experimental/utilities/tuple/tuple.apply/constexpr_types.pass.cpp b/test/std/experimental/utilities/tuple/tuple.apply/constexpr_types.pass.cpp new file mode 100644 index 000000000000..2d700486f26b --- /dev/null +++ b/test/std/experimental/utilities/tuple/tuple.apply/constexpr_types.pass.cpp @@ -0,0 +1,123 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// TODO(ericwf) +// constexpr support temporarily reverted due to bug: +// https://llvm.org/bugs/show_bug.cgi?id=23141 +// XFAIL: * + +// <experimental/tuple> + +// template <class F, class T> constexpr decltype(auto) apply(F &&, T &&) + +// Testing constexpr evaluation + +#include <experimental/tuple> +#include <utility> +#include <cassert> + +constexpr int f_int_0() { return 1; } +constexpr int f_int_1(int x) { return x; } +constexpr int f_int_2(int x, int y) { return (x + y); } + +struct A_int_0 +{ + constexpr A_int_0() {} + constexpr int operator()() const { return 1; } +}; + +struct A_int_1 +{ + constexpr A_int_1() {} + constexpr int operator()(int x) const { return x; } +}; + +struct A_int_2 +{ + constexpr A_int_2() {} + constexpr int operator()(int x, int y) const { return (x + y); } +}; + +namespace ex = std::experimental; + +template <class Tuple> +void test_0() +{ + // function + { + constexpr Tuple t{}; + static_assert(1 == ex::apply(f_int_0, t), ""); + } + // function pointer + { + constexpr Tuple t{}; + constexpr auto fp = &f_int_0; + static_assert(1 == ex::apply(fp, t), ""); + } + // functor + { + constexpr Tuple t{}; + constexpr A_int_0 a; + static_assert(1 == ex::apply(a, t), ""); + } +} + +template <class Tuple> +void test_1() +{ + // function + { + constexpr Tuple t{1}; + static_assert(1 == ex::apply(f_int_1, t), ""); + } + // function pointer + { + constexpr Tuple t{2}; + constexpr int (*fp)(int) = f_int_1; + static_assert(2 == ex::apply(fp, t), ""); + } + // functor + { + constexpr Tuple t{3}; + constexpr A_int_1 fn; + static_assert(3 == ex::apply(fn, t), ""); + } +} + +template <class Tuple> +void test_2() +{ + // function + { + constexpr Tuple t{1, 2}; + static_assert(3 == ex::apply(f_int_2, t), ""); + } + // function pointer + { + constexpr Tuple t{2, 3}; + constexpr auto fp = &f_int_2; + static_assert(5 == ex::apply(fp, t), ""); + } + // functor + { + constexpr Tuple t{3, 4}; + constexpr A_int_2 a; + static_assert(7 == ex::apply(a, t), ""); + } +} + +int main() +{ + test_0<std::tuple<>>(); + test_1<std::tuple<int>>(); + test_2<std::tuple<int, int>>(); + test_2<std::pair<int, int>>(); +} diff --git a/test/std/experimental/utilities/tuple/tuple.apply/extended_types.pass.cpp b/test/std/experimental/utilities/tuple/tuple.apply/extended_types.pass.cpp new file mode 100644 index 000000000000..322554925d3f --- /dev/null +++ b/test/std/experimental/utilities/tuple/tuple.apply/extended_types.pass.cpp @@ -0,0 +1,423 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <experimental/tuple> + +// template <class F, class T> constexpr decltype(auto) apply(F &&, T &&) + +// Testing extended function types. The extented function types are those +// named by INVOKE but that are not actual callable objects. These include +// bullets 1-4 of invoke. + +#include <experimental/tuple> +#include <array> +#include <utility> +#include <cassert> + +int count = 0; + +struct A_int_0 +{ + A_int_0() : obj1(0){} + A_int_0(int x) : obj1(x) {} + int mem1() { return ++count; } + int mem2() const { return ++count; } + int const obj1; +}; + +struct A_int_1 +{ + A_int_1() {} + A_int_1(int) {} + int mem1(int x) { return count += x; } + int mem2(int x) const { return count += x; } +}; + +struct A_int_2 +{ + A_int_2() {} + A_int_2(int) {} + int mem1(int x, int y) { return count += (x + y); } + int mem2(int x, int y) const { return count += (x + y); } +}; + +template <class A> +struct A_wrap +{ + A_wrap() {} + A_wrap(int x) : m_a(x) {} + A & operator*() { return m_a; } + A const & operator*() const { return m_a; } + A m_a; +}; + +typedef A_wrap<A_int_0> A_wrap_0; +typedef A_wrap<A_int_1> A_wrap_1; +typedef A_wrap<A_int_2> A_wrap_2; + + +template <class A> +struct A_base : public A +{ + A_base() : A() {} + A_base(int x) : A(x) {} +}; + +typedef A_base<A_int_0> A_base_0; +typedef A_base<A_int_1> A_base_1; +typedef A_base<A_int_2> A_base_2; + +namespace ex = std::experimental; + +template < + class Tuple, class ConstTuple + , class TuplePtr, class ConstTuplePtr + , class TupleWrap, class ConstTupleWrap + , class TupleBase, class ConstTupleBase + > +void test_ext_int_0() +{ + count = 0; + typedef A_int_0 T; + typedef A_wrap_0 Wrap; + typedef A_base_0 Base; + + typedef int(T::*mem1_t)(); + mem1_t mem1 = &T::mem1; + + typedef int(T::*mem2_t)() const; + mem2_t mem2 = &T::mem2; + + typedef int const T::*obj1_t; + obj1_t obj1 = &T::obj1; + + // member function w/ref + { + T a; + Tuple t{a}; + assert(1 == ex::apply(mem1, t)); + assert(count == 1); + } + count = 0; + // member function w/pointer + { + T a; + TuplePtr t{&a}; + assert(1 == ex::apply(mem1, t)); + assert(count == 1); + } + count = 0; + // member function w/base + { + Base a; + TupleBase t{a}; + assert(1 == ex::apply(mem1, t)); + assert(count == 1); + } + count = 0; + // member function w/wrap + { + Wrap a; + TupleWrap t{a}; + assert(1 == ex::apply(mem1, t)); + assert(count == 1); + } + count = 0; + // const member function w/ref + { + T const a; + ConstTuple t{a}; + assert(1 == ex::apply(mem2, t)); + assert(count == 1); + } + count = 0; + // const member function w/pointer + { + T const a; + ConstTuplePtr t{&a}; + assert(1 == ex::apply(mem2, t)); + assert(count == 1); + } + count = 0; + // const member function w/base + { + Base const a; + ConstTupleBase t{a}; + assert(1 == ex::apply(mem2, t)); + assert(count == 1); + } + count = 0; + // const member function w/wrapper + { + Wrap const a; + ConstTupleWrap t{a}; + assert(1 == ex::apply(mem2, t)); + assert(1 == count); + } + // member object w/ref + { + T a{42}; + Tuple t{a}; + assert(42 == ex::apply(obj1, t)); + } + // member object w/pointer + { + T a{42}; + TuplePtr t{&a}; + assert(42 == ex::apply(obj1, t)); + } + // member object w/base + { + Base a{42}; + TupleBase t{a}; + assert(42 == ex::apply(obj1, t)); + } + // member object w/wrapper + { + Wrap a{42}; + TupleWrap t{a}; + assert(42 == ex::apply(obj1, t)); + } +} + + +template < + class Tuple, class ConstTuple + , class TuplePtr, class ConstTuplePtr + , class TupleWrap, class ConstTupleWrap + , class TupleBase, class ConstTupleBase + > +void test_ext_int_1() +{ + count = 0; + typedef A_int_1 T; + typedef A_wrap_1 Wrap; + typedef A_base_1 Base; + + typedef int(T::*mem1_t)(int); + mem1_t mem1 = &T::mem1; + + typedef int(T::*mem2_t)(int) const; + mem2_t mem2 = &T::mem2; + + // member function w/ref + { + T a; + Tuple t{a, 2}; + assert(2 == ex::apply(mem1, t)); + assert(count == 2); + } + count = 0; + // member function w/pointer + { + T a; + TuplePtr t{&a, 3}; + assert(3 == ex::apply(mem1, t)); + assert(count == 3); + } + count = 0; + // member function w/base + { + Base a; + TupleBase t{a, 4}; + assert(4 == ex::apply(mem1, t)); + assert(count == 4); + } + count = 0; + // member function w/wrap + { + Wrap a; + TupleWrap t{a, 5}; + assert(5 == ex::apply(mem1, t)); + assert(count == 5); + } + count = 0; + // const member function w/ref + { + T const a; + ConstTuple t{a, 6}; + assert(6 == ex::apply(mem2, t)); + assert(count == 6); + } + count = 0; + // const member function w/pointer + { + T const a; + ConstTuplePtr t{&a, 7}; + assert(7 == ex::apply(mem2, t)); + assert(count == 7); + } + count = 0; + // const member function w/base + { + Base const a; + ConstTupleBase t{a, 8}; + assert(8 == ex::apply(mem2, t)); + assert(count == 8); + } + count = 0; + // const member function w/wrapper + { + Wrap const a; + ConstTupleWrap t{a, 9}; + assert(9 == ex::apply(mem2, t)); + assert(9 == count); + } +} + + +template < + class Tuple, class ConstTuple + , class TuplePtr, class ConstTuplePtr + , class TupleWrap, class ConstTupleWrap + , class TupleBase, class ConstTupleBase + > +void test_ext_int_2() +{ + count = 0; + typedef A_int_2 T; + typedef A_wrap_2 Wrap; + typedef A_base_2 Base; + + typedef int(T::*mem1_t)(int, int); + mem1_t mem1 = &T::mem1; + + typedef int(T::*mem2_t)(int, int) const; + mem2_t mem2 = &T::mem2; + + // member function w/ref + { + T a; + Tuple t{a, 1, 1}; + assert(2 == ex::apply(mem1, t)); + assert(count == 2); + } + count = 0; + // member function w/pointer + { + T a; + TuplePtr t{&a, 1, 2}; + assert(3 == ex::apply(mem1, t)); + assert(count == 3); + } + count = 0; + // member function w/base + { + Base a; + TupleBase t{a, 2, 2}; + assert(4 == ex::apply(mem1, t)); + assert(count == 4); + } + count = 0; + // member function w/wrap + { + Wrap a; + TupleWrap t{a, 2, 3}; + assert(5 == ex::apply(mem1, t)); + assert(count == 5); + } + count = 0; + // const member function w/ref + { + T const a; + ConstTuple t{a, 3, 3}; + assert(6 == ex::apply(mem2, t)); + assert(count == 6); + } + count = 0; + // const member function w/pointer + { + T const a; + ConstTuplePtr t{&a, 3, 4}; + assert(7 == ex::apply(mem2, t)); + assert(count == 7); + } + count = 0; + // const member function w/base + { + Base const a; + ConstTupleBase t{a, 4, 4}; + assert(8 == ex::apply(mem2, t)); + assert(count == 8); + } + count = 0; + // const member function w/wrapper + { + Wrap const a; + ConstTupleWrap t{a, 4, 5}; + assert(9 == ex::apply(mem2, t)); + assert(9 == count); + } +} + +int main() +{ + { + test_ext_int_0< + std::tuple<A_int_0 &>, std::tuple<A_int_0 const &> + , std::tuple<A_int_0 *>, std::tuple<A_int_0 const *> + , std::tuple<A_wrap_0 &>, std::tuple<A_wrap_0 const &> + , std::tuple<A_base_0 &>, std::tuple<A_base_0 const &> + >(); + test_ext_int_0< + std::tuple<A_int_0>, std::tuple<A_int_0 const> + , std::tuple<A_int_0 *>, std::tuple<A_int_0 const *> + , std::tuple<A_wrap_0>, std::tuple<A_wrap_0 const> + , std::tuple<A_base_0>, std::tuple<A_base_0 const> + >(); + test_ext_int_0< + std::array<A_int_0, 1>, std::array<A_int_0 const, 1> + , std::array<A_int_0*, 1>, std::array<A_int_0 const*, 1> + , std::array<A_wrap_0, 1>, std::array<A_wrap_0 const, 1> + , std::array<A_base_0, 1>, std::array<A_base_0 const, 1> + >(); + } + { + test_ext_int_1< + std::tuple<A_int_1 &, int>, std::tuple<A_int_1 const &, int> + , std::tuple<A_int_1 *, int>, std::tuple<A_int_1 const *, int> + , std::tuple<A_wrap_1 &, int>, std::tuple<A_wrap_1 const &, int> + , std::tuple<A_base_1 &, int>, std::tuple<A_base_1 const &, int> + >(); + test_ext_int_1< + std::tuple<A_int_1, int>, std::tuple<A_int_1 const, int> + , std::tuple<A_int_1 *, int>, std::tuple<A_int_1 const *, int> + , std::tuple<A_wrap_1, int>, std::tuple<A_wrap_1 const, int> + , std::tuple<A_base_1, int>, std::tuple<A_base_1 const, int> + >(); + test_ext_int_1< + std::pair<A_int_1 &, int>, std::pair<A_int_1 const &, int> + , std::pair<A_int_1 *, int>, std::pair<A_int_1 const *, int> + , std::pair<A_wrap_1 &, int>, std::pair<A_wrap_1 const &, int> + , std::pair<A_base_1 &, int>, std::pair<A_base_1 const &, int> + >(); + test_ext_int_1< + std::pair<A_int_1, int>, std::pair<A_int_1 const, int> + , std::pair<A_int_1 *, int>, std::pair<A_int_1 const *, int> + , std::pair<A_wrap_1, int>, std::pair<A_wrap_1 const, int> + , std::pair<A_base_1, int>, std::pair<A_base_1 const, int> + >(); + } + { + test_ext_int_2< + std::tuple<A_int_2 &, int, int>, std::tuple<A_int_2 const &, int, int> + , std::tuple<A_int_2 *, int, int>, std::tuple<A_int_2 const *, int, int> + , std::tuple<A_wrap_2 &, int, int>, std::tuple<A_wrap_2 const &, int, int> + , std::tuple<A_base_2 &, int, int>, std::tuple<A_base_2 const &, int, int> + >(); + test_ext_int_2< + std::tuple<A_int_2, int, int>, std::tuple<A_int_2 const, int, int> + , std::tuple<A_int_2 *, int, int>, std::tuple<A_int_2 const *, int, int> + , std::tuple<A_wrap_2, int, int>, std::tuple<A_wrap_2 const, int, int> + , std::tuple<A_base_2, int, int>, std::tuple<A_base_2 const, int, int> + >(); + } +} diff --git a/test/std/experimental/utilities/tuple/tuple.apply/large_arity.pass.cpp b/test/std/experimental/utilities/tuple/tuple.apply/large_arity.pass.cpp new file mode 100644 index 000000000000..027258ad8d1d --- /dev/null +++ b/test/std/experimental/utilities/tuple/tuple.apply/large_arity.pass.cpp @@ -0,0 +1,146 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <experimental/tuple> + +// template <class F, class T> constexpr decltype(auto) apply(F &&, T &&) + +// Stress testing large arities with tuple and array. + +#include <experimental/tuple> +#include <array> +#include <utility> +#include <cassert> + +//////////////////////////////////////////////////////////////////////////////// +template <class T, std::size_t Dummy = 0> +struct always_imp +{ + typedef T type; +}; + +template <class T, std::size_t Dummy = 0> +using always_t = typename always_imp<T, Dummy>::type; + +//////////////////////////////////////////////////////////////////////////////// +template <class Tuple, class Idx> +struct make_function; + +template <class Tp, std::size_t ...Idx> +struct make_function<Tp, std::integer_sequence<std::size_t, Idx...>> +{ + using type = bool (*)(always_t<Tp, Idx>...); +}; + +template <class Tp, std::size_t Size> +using make_function_t = typename make_function<Tp, std::make_index_sequence<Size>>::type; + +//////////////////////////////////////////////////////////////////////////////// +template <class Tp, class Idx> +struct make_tuple_imp; + +//////////////////////////////////////////////////////////////////////////////// +template <class Tp, std::size_t ...Idx> +struct make_tuple_imp<Tp, std::integer_sequence<std::size_t, Idx...>> +{ + using type = std::tuple<always_t<Tp, Idx>...>; +}; + +template <class Tp, std::size_t Size> +using make_tuple_t = typename make_tuple_imp<Tp, std::make_index_sequence<Size>>::type; + +template <class ...Types> +bool test_apply_fn(Types...) { return true; } + +namespace ex = std::experimental; + +template <std::size_t Size> +void test_all() +{ + + using A = std::array<int, Size>; + using ConstA = std::array<int const, Size>; + + using Tuple = make_tuple_t<int, Size>; + using CTuple = make_tuple_t<const int, Size>; + + using ValFn = make_function_t<int, Size>; + ValFn val_fn = &test_apply_fn; + + using RefFn = make_function_t<int &, Size>; + RefFn ref_fn = &test_apply_fn; + + using CRefFn = make_function_t<int const &, Size>; + CRefFn cref_fn = &test_apply_fn; + + using RRefFn = make_function_t<int &&, Size>; + RRefFn rref_fn = &test_apply_fn; + + { + A a{}; + assert(ex::apply(val_fn, a)); + assert(ex::apply(ref_fn, a)); + assert(ex::apply(cref_fn, a)); + assert(ex::apply(rref_fn, std::move(a))); + } + { + ConstA a{}; + assert(ex::apply(val_fn, a)); + assert(ex::apply(cref_fn, a)); + } + { + Tuple a{}; + assert(ex::apply(val_fn, a)); + assert(ex::apply(ref_fn, a)); + assert(ex::apply(cref_fn, a)); + assert(ex::apply(rref_fn, std::move(a))); + } + { + CTuple a{}; + assert(ex::apply(val_fn, a)); + assert(ex::apply(cref_fn, a)); + } + +} + + +template <std::size_t Size> +void test_one() +{ + using A = std::array<int, Size>; + using Tuple = make_tuple_t<int, Size>; + + using ValFn = make_function_t<int, Size>; + ValFn val_fn = &test_apply_fn; + + { + A a{}; + assert(ex::apply(val_fn, a)); + } + { + Tuple a{}; + assert(ex::apply(val_fn, a)); + } +} + +int main() +{ + // Instantiate with 1-5 arguments. + test_all<1>(); + test_all<2>(); + test_all<3>(); + test_all<4>(); + test_all<5>(); + + // Stress test with 128. + test_one<128>(); + //test_one<256>(); +} diff --git a/test/std/experimental/utilities/tuple/tuple.apply/ref_qualifiers.pass.cpp b/test/std/experimental/utilities/tuple/tuple.apply/ref_qualifiers.pass.cpp new file mode 100644 index 000000000000..3cf259f531c9 --- /dev/null +++ b/test/std/experimental/utilities/tuple/tuple.apply/ref_qualifiers.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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <experimental/tuple> + +// template <class F, class T> constexpr decltype(auto) apply(F &&, T &&) + +// Testing ref qualified functions + +#include <experimental/tuple> +#include <cassert> + +struct func_obj +{ + constexpr func_obj() {} + + constexpr int operator()() const & { return 1; } + constexpr int operator()() const && { return 2; } + constexpr int operator()() & { return 3; } + constexpr int operator()() && { return 4; } +}; + +namespace ex = std::experimental; + +int main() +{ +// TODO(ericwf): Re-enable constexpr support +/* + { + constexpr func_obj f; + constexpr std::tuple<> tp; + + static_assert(1 == ex::apply(static_cast<func_obj const &>(f), tp), ""); + static_assert(2 == ex::apply(static_cast<func_obj const &&>(f), tp), ""); + } +*/ + { + func_obj f; + std::tuple<> tp; + assert(1 == ex::apply(static_cast<func_obj const &>(f), tp)); + assert(2 == ex::apply(static_cast<func_obj const &&>(f), tp)); + assert(3 == ex::apply(static_cast<func_obj &>(f), tp)); + assert(4 == ex::apply(static_cast<func_obj &&>(f), tp)); + } +} diff --git a/test/std/experimental/utilities/tuple/tuple.apply/return_type.pass.cpp b/test/std/experimental/utilities/tuple/tuple.apply/return_type.pass.cpp new file mode 100644 index 000000000000..1ec38da5c043 --- /dev/null +++ b/test/std/experimental/utilities/tuple/tuple.apply/return_type.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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <experimental/tuple> + +// template <class F, class T> constexpr decltype(auto) apply(F &&, T &&) + +// Test the return type deduction. + +#include <experimental/tuple> +#include <cassert> + +static int my_int = 42; + +template <int N> struct index {}; + +void f(index<0>) {} + +int f(index<1>) { return 0; } +int const f(index<2>) { return 0; } +int volatile f(index<3>) { return 0; } +int const volatile f(index<4>) { return 0; } + +int & f(index<5>) { return static_cast<int &>(my_int); } +int const & f(index<6>) { return static_cast<int const &>(my_int); } +int volatile & f(index<7>) { return static_cast<int volatile &>(my_int); } +int const volatile & f(index<8>) { return static_cast<int const volatile &>(my_int); } + +int && f(index<9>) { return static_cast<int &&>(my_int); } +int const && f(index<10>) { return static_cast<int const &&>(my_int); } +int volatile && f(index<11>) { return static_cast<int volatile &&>(my_int); } +int const volatile && f(index<12>) { return static_cast<int const volatile &&>(my_int); } + +int * f(index<13>) { return static_cast<int *>(&my_int); } +int const * f(index<14>) { return static_cast<int const *>(&my_int); } +int volatile * f(index<15>) { return static_cast<int volatile *>(&my_int); } +int const volatile * f(index<16>) { return static_cast<int const volatile *>(&my_int); } + + +template <int Func, class Expect> +void test() +{ + using F = decltype((f(index<Func>{}))); + static_assert(std::is_same<F, Expect>::value, ""); +} + +namespace ex = std::experimental; + +int main() +{ + test<0, void>(); + test<1, int>(); + //test<2, int const>(); + //test<3, int volatile>(); + //test<4, int const volatile>(); + test<5, int &>(); + test<6, int const &>(); + test<7, int volatile &>(); + test<8, int const volatile &>(); + test<9, int &&>(); + test<10, int const &&>(); + test<11, int volatile &&>(); + test<12, int const volatile &&>(); + test<13, int *>(); + test<14, int const *>(); + test<15, int volatile *>(); + test<16, int const volatile *>(); +} diff --git a/test/std/experimental/utilities/tuple/tuple.apply/types.pass.cpp b/test/std/experimental/utilities/tuple/tuple.apply/types.pass.cpp new file mode 100644 index 000000000000..5d3d564c26fb --- /dev/null +++ b/test/std/experimental/utilities/tuple/tuple.apply/types.pass.cpp @@ -0,0 +1,427 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <experimental/tuple> + +// template <class F, class T> constexpr decltype(auto) apply(F &&, T &&) + +// Test function types. + +#include <experimental/tuple> +#include <array> +#include <utility> +#include <cassert> + +namespace ex = std::experimental; + +int count = 0; + +void f_void_0() { ++count; } +void f_void_1(int i) { count += i; } +void f_void_2(int x, int y) { count += (x + y); } +void f_void_3(int x, int y, int z) { count += (x + y + z); } + +int f_int_0() { return ++count; } +int f_int_1(int x) { return count += x; } +int f_int_2(int x, int y) { return count += (x + y); } +int f_int_3(int x, int y, int z) { return count += (x + y + z); } + +struct A_void_0 +{ + A_void_0() {} + void operator()() { ++count; } + void operator()() const { ++count; ++count; } +}; + +struct A_void_1 +{ + A_void_1() {} + void operator()(int x) { count += x; } + void operator()(int x) const { count += x + 1; } +}; + +struct A_void_2 +{ + A_void_2() {} + void operator()(int x, int y) { count += (x + y); } + void operator()(int x, int y) const { count += (x + y) + 1; } +}; + +struct A_void_3 +{ + A_void_3() {} + void operator()(int x, int y, int z) { count += (x + y + z); } + void operator()(int x, int y, int z) const { count += (x + y + z) + 1; } +}; + + +struct A_int_0 +{ + A_int_0() {} + int operator()() { return ++count; } + int operator()() const { ++count; return ++count; } +}; + +struct A_int_1 +{ + A_int_1() {} + int operator()(int x) { return count += x; } + int operator()(int x) const { return count += (x + 1); } + +}; + +struct A_int_2 +{ + A_int_2() {} + int operator()(int x, int y) { return count += (x + y); } + int operator()(int x, int y) const { return count += (x + y + 1); } +}; + +struct A_int_3 +{ + A_int_3() {} + int operator()(int x, int y, int z) { return count += (x + y + z); } + int operator()(int x, int y, int z) const { return count += (x + y + z + 1); } +}; + + +template <class Tuple> +void test_void_0() +{ + count = 0; + // function + { + Tuple t{}; + ex::apply(f_void_0, t); + assert(count == 1); + } + count = 0; + // function pointer + { + Tuple t{}; + auto fp = &f_void_0; + ex::apply(fp, t); + assert(count == 1); + } + count = 0; + // functor + { + Tuple t{}; + A_void_0 a; + ex::apply(a, t); + assert(count == 1); + } + count = 0; + // const functor + { + Tuple t{}; + A_void_0 const a; + ex::apply(a, t); + assert(count == 2); + } +} + +template <class Tuple> +void test_void_1() +{ + count = 0; + // function + { + Tuple t{1}; + ex::apply(f_void_1, t); + assert(count == 1); + } + count = 0; + // function pointer + { + Tuple t{2}; + void (*fp)(int) = f_void_1; + ex::apply(fp, t); + assert(count == 2); + } + count = 0; + // functor + { + Tuple t{3}; + A_void_1 fn; + ex::apply(fn, t); + assert(count == 3); + } + count = 0; + // const functor + { + Tuple t{4}; + A_void_1 const a; + ex::apply(a, t); + assert(count == 5); + } +} + +template <class Tuple> +void test_void_2() +{ + count = 0; + // function + { + Tuple t{1, 2}; + ex::apply(f_void_2, t); + assert(count == 3); + } + count = 0; + // function pointer + { + Tuple t{2, 3}; + auto fp = &f_void_2; + ex::apply(fp, t); + assert(count == 5); + } + count = 0; + // functor + { + Tuple t{3, 4}; + A_void_2 a; + ex::apply(a, t); + assert(count == 7); + } + count = 0; + // const functor + { + Tuple t{4, 5}; + A_void_2 const a; + ex::apply(a, t); + assert(count == 10); + } +} + +template <class Tuple> +void test_void_3() +{ + count = 0; + // function + { + Tuple t{1, 2, 3}; + ex::apply(f_void_3, t); + assert(count == 6); + } + count = 0; + // function pointer + { + Tuple t{2, 3, 4}; + auto fp = &f_void_3; + ex::apply(fp, t); + assert(count == 9); + } + count = 0; + // functor + { + Tuple t{3, 4, 5}; + A_void_3 a; + ex::apply(a, t); + assert(count == 12); + } + count = 0; + // const functor + { + Tuple t{4, 5, 6}; + A_void_3 const a; + ex::apply(a, t); + assert(count == 16); + } +} + + + +template <class Tuple> +void test_int_0() +{ + count = 0; + // function + { + Tuple t{}; + assert(1 == ex::apply(f_int_0, t)); + assert(count == 1); + } + count = 0; + // function pointer + { + Tuple t{}; + auto fp = &f_int_0; + assert(1 == ex::apply(fp, t)); + assert(count == 1); + } + count = 0; + // functor + { + Tuple t{}; + A_int_0 a; + assert(1 == ex::apply(a, t)); + assert(count == 1); + } + count = 0; + // const functor + { + Tuple t{}; + A_int_0 const a; + assert(2 == ex::apply(a, t)); + assert(count == 2); + } +} + +template <class Tuple> +void test_int_1() +{ + count = 0; + // function + { + Tuple t{1}; + assert(1 == ex::apply(f_int_1, t)); + assert(count == 1); + } + count = 0; + // function pointer + { + Tuple t{2}; + int (*fp)(int) = f_int_1; + assert(2 == ex::apply(fp, t)); + assert(count == 2); + } + count = 0; + // functor + { + Tuple t{3}; + A_int_1 fn; + assert(3 == ex::apply(fn, t)); + assert(count == 3); + } + count = 0; + // const functor + { + Tuple t{4}; + A_int_1 const a; + assert(5 == ex::apply(a, t)); + assert(count == 5); + } +} + +template <class Tuple> +void test_int_2() +{ + count = 0; + // function + { + Tuple t{1, 2}; + assert(3 == ex::apply(f_int_2, t)); + assert(count == 3); + } + count = 0; + // function pointer + { + Tuple t{2, 3}; + auto fp = &f_int_2; + assert(5 == ex::apply(fp, t)); + assert(count == 5); + } + count = 0; + // functor + { + Tuple t{3, 4}; + A_int_2 a; + assert(7 == ex::apply(a, t)); + assert(count == 7); + } + count = 0; + // const functor + { + Tuple t{4, 5}; + A_int_2 const a; + assert(10 == ex::apply(a, t)); + assert(count == 10); + } +} + +template <class Tuple> +void test_int_3() +{ + count = 0; + // function + { + Tuple t{1, 2, 3}; + assert(6 == ex::apply(f_int_3, t)); + assert(count == 6); + } + count = 0; + // function pointer + { + Tuple t{2, 3, 4}; + auto fp = &f_int_3; + assert(9 == ex::apply(fp, t)); + assert(count == 9); + } + count = 0; + // functor + { + Tuple t{3, 4, 5}; + A_int_3 a; + assert(12 == ex::apply(a, t)); + assert(count == 12); + } + count = 0; + // const functor + { + Tuple t{4, 5, 6}; + A_int_3 const a; + assert(16 == ex::apply(a, t)); + assert(count == 16); + } +} + +template <class Tuple> +void test_0() +{ + test_void_0<Tuple>(); + test_int_0<Tuple>(); +} + +template <class Tuple> +void test_1() +{ + test_void_1<Tuple>(); + test_int_1<Tuple>(); +} + +template <class Tuple> +void test_2() +{ + test_void_2<Tuple>(); + test_int_2<Tuple>(); +} + +template <class Tuple> +void test_3() +{ + test_void_3<Tuple>(); + test_int_3<Tuple>(); +} + +int main() +{ + test_0<std::tuple<>>(); + + test_1<std::tuple<int>>(); + test_1<std::array<int, 1>>(); + + test_2<std::tuple<int, int>>(); + test_2<std::pair<int, int>>(); + test_2<std::array<int, 2>>(); + + test_3<std::tuple<int, int, int>>(); + test_3<std::array<int, 3>>(); +} diff --git a/test/std/experimental/utilities/tuple/tuple_size_v.fail.cpp b/test/std/experimental/utilities/tuple/tuple_size_v.fail.cpp new file mode 100644 index 000000000000..a25b18cf5386 --- /dev/null +++ b/test/std/experimental/utilities/tuple/tuple_size_v.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <experimental/tuple> + +// template <class T> constexpr size_t tuple_size_v = tuple_size<T>::value; + +// Test with reference + +#include <experimental/tuple> + +namespace ex = std::experimental; + +int main() +{ + auto x = ex::tuple_size_v<std::tuple<> &>; +} diff --git a/test/std/experimental/utilities/tuple/tuple_size_v.pass.cpp b/test/std/experimental/utilities/tuple/tuple_size_v.pass.cpp new file mode 100644 index 000000000000..d7a5aa679fcd --- /dev/null +++ b/test/std/experimental/utilities/tuple/tuple_size_v.pass.cpp @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <experimental/tuple> + +// template <class T> constexpr size_t tuple_size_v = tuple_size<T>::value; + +#include <experimental/tuple> +#include <utility> +#include <array> + +namespace ex = std::experimental; + +template <class Tuple, int Expect> +void test() +{ + static_assert(ex::tuple_size_v<Tuple> == Expect, ""); + static_assert(ex::tuple_size_v<Tuple> == std::tuple_size<Tuple>::value, ""); + static_assert(ex::tuple_size_v<Tuple const> == std::tuple_size<Tuple>::value, ""); + static_assert(ex::tuple_size_v<Tuple volatile> == std::tuple_size<Tuple>::value, ""); + static_assert(ex::tuple_size_v<Tuple const volatile> == std::tuple_size<Tuple>::value, ""); +} + +int main() +{ + test<std::tuple<>, 0>(); + + test<std::tuple<int>, 1>(); + test<std::array<int, 1>, 1>(); + + test<std::tuple<int, int>, 2>(); + test<std::pair<int, int>, 2>(); + test<std::array<int, 2>, 2>(); + + test<std::tuple<int, int, int>, 3>(); + test<std::array<int, 3>, 3>(); +} diff --git a/test/std/experimental/utilities/tuple/tuple_size_v_2.fail.cpp b/test/std/experimental/utilities/tuple/tuple_size_v_2.fail.cpp new file mode 100644 index 000000000000..a95ac49ff452 --- /dev/null +++ b/test/std/experimental/utilities/tuple/tuple_size_v_2.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <experimental/tuple> + +// template <class T> constexpr size_t tuple_size_v = tuple_size<T>::value; + +// Test with non tuple type + +#include <experimental/tuple> + +namespace ex = std::experimental; + +int main() +{ + auto x = ex::tuple_size_v<int>; +} diff --git a/test/std/experimental/utilities/tuple/tuple_size_v_3.fail.cpp b/test/std/experimental/utilities/tuple/tuple_size_v_3.fail.cpp new file mode 100644 index 000000000000..7c2f0cc236f6 --- /dev/null +++ b/test/std/experimental/utilities/tuple/tuple_size_v_3.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <experimental/tuple> + +// template <class T> constexpr size_t tuple_size_v = tuple_size<T>::value; + +// Test with pointer + +#include <experimental/tuple> + +namespace ex = std::experimental; + +int main() +{ + auto x = ex::tuple_size_v<std::tuple<>*>; +} diff --git a/test/std/experimental/utilities/utility/utility.erased.type/erased_type.pass.cpp b/test/std/experimental/utilities/utility/utility.erased.type/erased_type.pass.cpp new file mode 100644 index 000000000000..51f9ab6bee18 --- /dev/null +++ b/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/test/std/experimental/utilities/utility/utility.synop/includes.pass.cpp b/test/std/experimental/utilities/utility/utility.synop/includes.pass.cpp new file mode 100644 index 000000000000..2583d4345406 --- /dev/null +++ b/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/test/std/experimental/utilities/utility/version.pass.cpp b/test/std/experimental/utilities/utility/version.pass.cpp new file mode 100644 index 000000000000..437712454ae5 --- /dev/null +++ b/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() +{ +} |