diff options
8 files changed, 1368 insertions, 0 deletions
diff --git a/libcxx/include/experimental/type_traits b/libcxx/include/experimental/type_traits new file mode 100644 index 00000000000..ab2c8cdf81d --- /dev/null +++ b/libcxx/include/experimental/type_traits @@ -0,0 +1,423 @@ +// -*- C++ -*- +//===-------------------------- type_traits -------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_TYPE_TRAITS +#define _LIBCPP_EXPERIMENTAL_TYPE_TRAITS + +/** + experimental/type_traits synopsis + +// C++1y +#include <type_traits> + +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { + + // See C++14 20.10.4.1, primary type categories + template <class T> constexpr bool is_void_v + = is_void<T>::value; + template <class T> constexpr bool is_null_pointer_v + = is_null_pointer<T>::value; + template <class T> constexpr bool is_integral_v + = is_integral<T>::value; + template <class T> constexpr bool is_floating_point_v + = is_floating_point<T>::value; + template <class T> constexpr bool is_array_v + = is_array<T>::value; + template <class T> constexpr bool is_pointer_v + = is_pointer<T>::value; + template <class T> constexpr bool is_lvalue_reference_v + = is_lvalue_reference<T>::value; + template <class T> constexpr bool is_rvalue_reference_v + = is_rvalue_reference<T>::value; + template <class T> constexpr bool is_member_object_pointer_v + = is_member_object_pointer<T>::value; + template <class T> constexpr bool is_member_function_pointer_v + = is_member_function_pointer<T>::value; + template <class T> constexpr bool is_enum_v + = is_enum<T>::value; + template <class T> constexpr bool is_union_v + = is_union<T>::value; + template <class T> constexpr bool is_class_v + = is_class<T>::value; + template <class T> constexpr bool is_function_v + = is_function<T>::value; + + // See C++14 20.10.4.2, composite type categories + template <class T> constexpr bool is_reference_v + = is_reference<T>::value; + template <class T> constexpr bool is_arithmetic_v + = is_arithmetic<T>::value; + template <class T> constexpr bool is_fundamental_v + = is_fundamental<T>::value; + template <class T> constexpr bool is_object_v + = is_object<T>::value; + template <class T> constexpr bool is_scalar_v + = is_scalar<T>::value; + template <class T> constexpr bool is_compound_v + = is_compound<T>::value; + template <class T> constexpr bool is_member_pointer_v + = is_member_pointer<T>::value; + + // See C++14 20.10.4.3, type properties + template <class T> constexpr bool is_const_v + = is_const<T>::value; + template <class T> constexpr bool is_volatile_v + = is_volatile<T>::value; + template <class T> constexpr bool is_trivial_v + = is_trivial<T>::value; + template <class T> constexpr bool is_trivially_copyable_v + = is_trivially_copyable<T>::value; + template <class T> constexpr bool is_standard_layout_v + = is_standard_layout<T>::value; + template <class T> constexpr bool is_pod_v + = is_pod<T>::value; + template <class T> constexpr bool is_literal_type_v + = is_literal_type<T>::value; + template <class T> constexpr bool is_empty_v + = is_empty<T>::value; + template <class T> constexpr bool is_polymorphic_v + = is_polymorphic<T>::value; + template <class T> constexpr bool is_abstract_v + = is_abstract<T>::value; + template <class T> constexpr bool is_final_v + = is_final<T>::value; + template <class T> constexpr bool is_signed_v + = is_signed<T>::value; + template <class T> constexpr bool is_unsigned_v + = is_unsigned<T>::value; + template <class T, class... Args> constexpr bool is_constructible_v + = is_constructible<T, Args...>::value; + template <class T> constexpr bool is_default_constructible_v + = is_default_constructible<T>::value; + template <class T> constexpr bool is_copy_constructible_v + = is_copy_constructible<T>::value; + template <class T> constexpr bool is_move_constructible_v + = is_move_constructible<T>::value; + template <class T, class U> constexpr bool is_assignable_v + = is_assignable<T, U>::value; + template <class T> constexpr bool is_copy_assignable_v + = is_copy_assignable<T>::value; + template <class T> constexpr bool is_move_assignable_v + = is_move_assignable<T>::value; + template <class T> constexpr bool is_destructible_v + = is_destructible<T>::value; + template <class T, class... Args> constexpr bool is_trivially_constructible_v + = is_trivially_constructible<T, Args...>::value; + template <class T> constexpr bool is_trivially_default_constructible_v + = is_trivially_default_constructible<T>::value; + template <class T> constexpr bool is_trivially_copy_constructible_v + = is_trivially_copy_constructible<T>::value; + template <class T> constexpr bool is_trivially_move_constructible_v + = is_trivially_move_constructible<T>::value; + template <class T, class U> constexpr bool is_trivially_assignable_v + = is_trivially_assignable<T, U>::value; + template <class T> constexpr bool is_trivially_copy_assignable_v + = is_trivially_copy_assignable<T>::value; + template <class T> constexpr bool is_trivially_move_assignable_v + = is_trivially_move_assignable<T>::value; + template <class T> constexpr bool is_trivially_destructible_v + = is_trivially_destructible<T>::value; + template <class T, class... Args> constexpr bool is_nothrow_constructible_v + = is_nothrow_constructible<T, Args...>::value; + template <class T> constexpr bool is_nothrow_default_constructible_v + = is_nothrow_default_constructible<T>::value; + template <class T> constexpr bool is_nothrow_copy_constructible_v + = is_nothrow_copy_constructible<T>::value; + template <class T> constexpr bool is_nothrow_move_constructible_v + = is_nothrow_move_constructible<T>::value; + template <class T, class U> constexpr bool is_nothrow_assignable_v + = is_nothrow_assignable<T, U>::value; + template <class T> constexpr bool is_nothrow_copy_assignable_v + = is_nothrow_copy_assignable<T>::value; + template <class T> constexpr bool is_nothrow_move_assignable_v + = is_nothrow_move_assignable<T>::value; + template <class T> constexpr bool is_nothrow_destructible_v + = is_nothrow_destructible<T>::value; + template <class T> constexpr bool has_virtual_destructor_v + = has_virtual_destructor<T>::value; + + // See C++14 20.10.5, type property queries + template <class T> constexpr size_t alignment_of_v + = alignment_of<T>::value; + template <class T> constexpr size_t rank_v + = rank<T>::value; + template <class T, unsigned I = 0> constexpr size_t extent_v + = extent<T, I>::value; + + // See C++14 20.10.6, type relations + template <class T, class U> constexpr bool is_same_v + = is_same<T, U>::value; + template <class Base, class Derived> constexpr bool is_base_of_v + = is_base_of<Base, Derived>::value; + template <class From, class To> constexpr bool is_convertible_v + = is_convertible<From, To>::value; + + // 3.3.2, Other type transformations + template <class> class invocation_type; // not defined + template <class F, class... ArgTypes> class invocation_type<F(ArgTypes...)>; + template <class> class raw_invocation_type; // not defined + template <class F, class... ArgTypes> class raw_invocation_type<F(ArgTypes...)>; + + template <class T> + using invocation_type_t = typename invocation_type<T>::type; + template <class T> + using raw_invocation_type_t = typename raw_invocation_type<T>::type; + +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include <experimental/__config> + +#if _LIBCPP_STD_VER > 11 + +#include <type_traits> + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +#if __has_feature(cxx_variable_templates) + +// C++14 20.10.4.1, primary type categories + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_void_v + = is_void<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_null_pointer_v + = is_null_pointer<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_integral_v + = is_integral<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_floating_point_v + = is_floating_point<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_array_v + = is_array<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_pointer_v + = is_pointer<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_lvalue_reference_v + = is_lvalue_reference<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_rvalue_reference_v + = is_rvalue_reference<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_object_pointer_v + = is_member_object_pointer<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_function_pointer_v + = is_member_function_pointer<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_enum_v + = is_enum<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_union_v + = is_union<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_class_v + = is_class<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_function_v + = is_function<_Tp>::value; + +// C++14 20.10.4.2, composite type categories + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_reference_v + = is_reference<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_arithmetic_v + = is_arithmetic<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_fundamental_v + = is_fundamental<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_object_v + = is_object<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_scalar_v + = is_scalar<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_compound_v + = is_compound<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_pointer_v + = is_member_pointer<_Tp>::value; + +// C++14 20.10.4.3, type properties + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_const_v + = is_const<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_volatile_v + = is_volatile<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivial_v + = is_trivial<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copyable_v + = is_trivially_copyable<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_standard_layout_v + = is_standard_layout<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_pod_v + = is_pod<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_literal_type_v + = is_literal_type<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_empty_v + = is_empty<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_polymorphic_v + = is_polymorphic<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_abstract_v + = is_abstract<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_final_v + = is_final<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_signed_v + = is_signed<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_unsigned_v + = is_unsigned<_Tp>::value; + +template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_constructible_v + = is_constructible<_Tp, _Ts...>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_default_constructible_v + = is_default_constructible<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_constructible_v + = is_copy_constructible<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_constructible_v + = is_move_constructible<_Tp>::value; + +template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_assignable_v + = is_assignable<_Tp, _Up>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_assignable_v + = is_copy_assignable<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_assignable_v + = is_move_assignable<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_destructible_v + = is_destructible<_Tp>::value; + +template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_trivially_constructible_v + = is_trivially_constructible<_Tp, _Ts...>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v + = is_trivially_default_constructible<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v + = is_trivially_copy_constructible<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v + = is_trivially_move_constructible<_Tp>::value; + +template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_trivially_assignable_v + = is_trivially_assignable<_Tp, _Up>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v + = is_trivially_copy_assignable<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v + = is_trivially_move_assignable<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_destructible_v + = is_trivially_destructible<_Tp>::value; + +template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v + = is_nothrow_constructible<_Tp, _Ts...>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v + = is_nothrow_default_constructible<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v + = is_nothrow_copy_constructible<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v + = is_nothrow_move_constructible<_Tp>::value; + +template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v + = is_nothrow_assignable<_Tp, _Up>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v + = is_nothrow_copy_assignable<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v + = is_nothrow_move_assignable<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v + = is_nothrow_destructible<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool has_virtual_destructor_v + = has_virtual_destructor<_Tp>::value; + +// C++14 20.10.5, type properties queries + +template <class _Tp> _LIBCPP_CONSTEXPR size_t alignment_of_v + = alignment_of<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR size_t rank_v + = rank<_Tp>::value; + +template <class _Tp, unsigned _Id = 0> _LIBCPP_CONSTEXPR size_t extent_v + = extent<_Tp, _Id>::value; + +// C++14 20.10.6, type relations + +template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_same_v + = is_same<_Tp, _Up>::value; + +template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_base_of_v + = is_base_of<_Tp, _Up>::value; + +template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_convertible_v + = is_convertible<_Tp, _Up>::value; + +#endif /* __has_feature(cxx_variable_templates) */ + +// 3.3.2, Other type transformations +/* +template <class> +class _LIBCPP_TYPE_VIS_ONLY raw_invocation_type; + +template <class _Fn, class ..._Args> +class _LIBCPP_TYPE_VIS_ONLY raw_invocation_type<_Fn(_Args...)>; + +template <class> +class _LIBCPP_TYPE_VIS_ONLY invokation_type; + +template <class _Fn, class ..._Args> +class _LIBCPP_TYPE_VIS_ONLY invokation_type<_Fn(_Args...)>; + +template <class _Tp> +using invokation_type_t = typename invokation_type<_Tp>::type; + +template <class _Tp> +using raw_invocation_type_t = typename raw_invocation_type<_Tp>::type; +*/ + +_LIBCPP_END_NAMESPACE_LFTS + +#endif /* _LIBCPP_STD_VER > 11 */ + +#endif /* _LIBCPP_EXPERIMENTAL_TYPE_TRAITS */ diff --git a/libcxx/test/experimental/utilities/meta/meta.type.synop/includes.pass.cpp b/libcxx/test/experimental/utilities/meta/meta.type.synop/includes.pass.cpp new file mode 100644 index 00000000000..2c90dd64181 --- /dev/null +++ b/libcxx/test/experimental/utilities/meta/meta.type.synop/includes.pass.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <experimental/type_traits> + +#include <experimental/type_traits> + +#if _LIBCPP_STD_VER > 11 +# ifndef _LIBCPP_TYPE_TRAITS +# error "<experimental/type_traits> must include <type_traits>" +# endif +#endif + +int main() +{ +} diff --git a/libcxx/test/experimental/utilities/meta/meta.type.synop/meta.rel.pass.cpp b/libcxx/test/experimental/utilities/meta/meta.type.synop/meta.rel.pass.cpp new file mode 100644 index 00000000000..96af4b67618 --- /dev/null +++ b/libcxx/test/experimental/utilities/meta/meta.type.synop/meta.rel.pass.cpp @@ -0,0 +1,65 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <experimental/type_traits> + +#include <experimental/type_traits> + +#if _LIBCPP_STD_VER > 11 + +namespace ex = std::experimental; + +struct base_type {}; +struct derived_type : base_type {}; + +int main() +{ + { + typedef int T; + typedef int U; + static_assert(ex::is_same_v<T, U>, ""); + static_assert(std::is_same<decltype(ex::is_same_v<T, U>), const bool>::value, ""); + static_assert(ex::is_same_v<T, U> == std::is_same<T, U>::value, ""); + } + { + typedef int T; + typedef long U; + static_assert(!ex::is_same_v<T, U>, ""); + static_assert(ex::is_same_v<T, U> == std::is_same<T, U>::value, ""); + } + { + typedef base_type T; + typedef derived_type U; + static_assert(ex::is_base_of_v<T, U>, ""); + static_assert(std::is_same<decltype(ex::is_base_of_v<T, U>), const bool>::value, ""); + static_assert(ex::is_base_of_v<T, U> == std::is_base_of<T, U>::value, ""); + } + { + typedef int T; + typedef int U; + static_assert(!ex::is_base_of_v<T, U>, ""); + static_assert(ex::is_base_of_v<T, U> == std::is_base_of<T, U>::value, ""); + } + { + typedef int T; + typedef long U; + static_assert(ex::is_convertible_v<T, U>, ""); + static_assert(std::is_same<decltype(ex::is_convertible_v<T, U>), const bool>::value, ""); + static_assert(ex::is_convertible_v<T, U> == std::is_convertible<T, U>::value, ""); + } + { + typedef void T; + typedef int U; + static_assert(!ex::is_convertible_v<T, U>, ""); + static_assert(ex::is_convertible_v<T, U> == std::is_convertible<T, U>::value, ""); + } +} +#else /* _LIBCPP_STD_VER <= 11 */ +int main() {} +#endif /* _LIBCPP_STD_VER > 11 */ diff --git a/libcxx/test/experimental/utilities/meta/meta.type.synop/meta.unary.cat.pass.cpp b/libcxx/test/experimental/utilities/meta/meta.type.synop/meta.unary.cat.pass.cpp new file mode 100644 index 00000000000..2d1e706f67d --- /dev/null +++ b/libcxx/test/experimental/utilities/meta/meta.type.synop/meta.unary.cat.pass.cpp @@ -0,0 +1,181 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <experimental/type_traits> + +#include <experimental/type_traits> + +#if _LIBCPP_STD_VER > 11 + +namespace ex = std::experimental; + +struct class_type {}; +enum enum_type {}; +union union_type {}; + +int main() +{ + { + typedef void T; + static_assert(ex::is_void_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_void_v<T>), const bool>::value, ""); + static_assert(ex::is_void_v<T> == std::is_void<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_void_v<T>, ""); + static_assert(ex::is_void_v<T> == std::is_void<T>::value, ""); + } + { + typedef decltype(nullptr) T; + static_assert(ex::is_null_pointer_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_null_pointer_v<T>), const bool>::value, ""); + static_assert(ex::is_null_pointer_v<T> == std::is_null_pointer<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_null_pointer_v<T>, ""); + static_assert(ex::is_null_pointer_v<T> == std::is_null_pointer<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_integral_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_integral_v<T>), const bool>::value, ""); + static_assert(ex::is_integral_v<T> == std::is_integral<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_integral_v<T>, ""); + static_assert(ex::is_integral_v<T> == std::is_integral<T>::value, ""); + } + { + typedef float T; + static_assert(ex::is_floating_point_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_floating_point_v<T>), const bool>::value, ""); + static_assert(ex::is_floating_point_v<T> == std::is_floating_point<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_floating_point_v<T>, ""); + static_assert(ex::is_floating_point_v<T> == std::is_floating_point<T>::value, ""); + } + { + typedef int(T)[42]; + static_assert(ex::is_array_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_array_v<T>), const bool>::value, ""); + static_assert(ex::is_array_v<T> == std::is_array<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_array_v<T>, ""); + static_assert(ex::is_array_v<T> == std::is_array<T>::value, ""); + } + { + typedef void* T; + static_assert(ex::is_pointer_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_pointer_v<T>), const bool>::value, ""); + static_assert(ex::is_pointer_v<T> == std::is_pointer<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_pointer_v<T>, ""); + static_assert(ex::is_pointer_v<T> == std::is_pointer<T>::value, ""); + } + { + typedef int & T; + static_assert(ex::is_lvalue_reference_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_lvalue_reference_v<T>), const bool>::value, ""); + static_assert(ex::is_lvalue_reference_v<T> == std::is_lvalue_reference<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_lvalue_reference_v<T>, ""); + static_assert(ex::is_lvalue_reference_v<T> == std::is_lvalue_reference<T>::value, ""); + } + { + typedef int && T; + static_assert(ex::is_rvalue_reference_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_rvalue_reference_v<T>), const bool>::value, ""); + static_assert(ex::is_rvalue_reference_v<T> == std::is_rvalue_reference<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_rvalue_reference_v<T>, ""); + static_assert(ex::is_rvalue_reference_v<T> == std::is_rvalue_reference<T>::value, ""); + } + { + typedef int class_type::*T; + static_assert(ex::is_member_object_pointer_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_member_object_pointer_v<T>), const bool>::value, ""); + static_assert(ex::is_member_object_pointer_v<T> == std::is_member_object_pointer<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_member_object_pointer_v<T>, ""); + static_assert(ex::is_member_object_pointer_v<T> == std::is_member_object_pointer<T>::value, ""); + } + { + typedef void(class_type::*T)(); + static_assert(ex::is_member_function_pointer_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_member_function_pointer_v<T>), const bool>::value, ""); + static_assert(ex::is_member_function_pointer_v<T> == std::is_member_function_pointer<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_member_function_pointer_v<T>, ""); + static_assert(ex::is_member_function_pointer_v<T> == std::is_member_function_pointer<T>::value, ""); + } + { + typedef enum_type T; + static_assert(ex::is_enum_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_enum_v<T>), const bool>::value, ""); + static_assert(ex::is_enum_v<T> == std::is_enum<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_enum_v<T>, ""); + static_assert(ex::is_enum_v<T> == std::is_enum<T>::value, ""); + } + { + typedef union_type T; + static_assert(ex::is_union_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_union_v<T>), const bool>::value, ""); + static_assert(ex::is_union_v<T> == std::is_union<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_union_v<T>, ""); + static_assert(ex::is_union_v<T> == std::is_union<T>::value, ""); + } + { + typedef class_type T; + static_assert(ex::is_class_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_class_v<T>), const bool>::value, ""); + static_assert(ex::is_class_v<T> == std::is_class<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_class_v<T>, ""); + static_assert(ex::is_class_v<T> == std::is_class<T>::value, ""); + } + { + typedef void(T)(); + static_assert(ex::is_function_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_function_v<T>), const bool>::value, ""); + static_assert(ex::is_function_v<T> == std::is_function<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_function_v<T>, ""); + static_assert(ex::is_function_v<T> == std::is_function<T>::value, ""); + } +} +#else /* _LIBCPP_STD_VER <= 11 */ +int main() {} +#endif /* _LIBCPP_STD_VER > 11 */ diff --git a/libcxx/test/experimental/utilities/meta/meta.type.synop/meta.unary.comp.pass.cpp b/libcxx/test/experimental/utilities/meta/meta.type.synop/meta.unary.comp.pass.cpp new file mode 100644 index 00000000000..814f450f4e0 --- /dev/null +++ b/libcxx/test/experimental/utilities/meta/meta.type.synop/meta.unary.comp.pass.cpp @@ -0,0 +1,102 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <experimental/type_traits> + +#include <experimental/type_traits> + +#if _LIBCPP_STD_VER > 11 + +namespace ex = std::experimental; + +struct class_type {}; + +int main() +{ + { + typedef int & T; + static_assert(ex::is_reference_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_reference_v<T>), const bool>::value, ""); + static_assert(ex::is_reference_v<T> == std::is_reference<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_reference_v<T>, ""); + static_assert(ex::is_reference_v<T> == std::is_reference<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_arithmetic_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_arithmetic_v<T>), const bool>::value, ""); + static_assert(ex::is_arithmetic_v<T> == std::is_arithmetic<T>::value, ""); + } + { + typedef void* T; + static_assert(!ex::is_arithmetic_v<T>, ""); + static_assert(ex::is_arithmetic_v<T> == std::is_arithmetic<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_fundamental_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_fundamental_v<T>), const bool>::value, ""); + static_assert(ex::is_fundamental_v<T> == std::is_fundamental<T>::value, ""); + } + { + typedef class_type T; + static_assert(!ex::is_fundamental_v<T>, ""); + static_assert(ex::is_fundamental_v<T> == std::is_fundamental<T>::value, ""); + } + { + typedef class_type T; + static_assert(ex::is_object_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_object_v<T>), const bool>::value, ""); + static_assert(ex::is_object_v<T> == std::is_object<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_object_v<T>, ""); + static_assert(ex::is_object_v<T> == std::is_object<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_scalar_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_scalar_v<T>), const bool>::value, ""); + static_assert(ex::is_scalar_v<T> == std::is_scalar<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_scalar_v<T>, ""); + static_assert(ex::is_scalar_v<T> == std::is_scalar<T>::value, ""); + } + { + typedef void* T; + static_assert(ex::is_compound_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_compound_v<T>), const bool>::value, ""); + static_assert(ex::is_compound_v<T> == std::is_compound<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_compound_v<T>, ""); + static_assert(ex::is_compound_v<T> == std::is_compound<T>::value, ""); + } + { + typedef int class_type::*T; + static_assert(ex::is_member_pointer_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_member_pointer_v<T>), const bool>::value, ""); + static_assert(ex::is_member_pointer_v<T> == std::is_member_pointer<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_member_pointer_v<T>, ""); + static_assert(ex::is_member_pointer_v<T> == std::is_member_pointer<T>::value, ""); + } +} +#else /* _LIBCPP_STD_VER <= 11 */ +int main() {} +#endif /* _LIBCPP_STD_VER > 11 */ diff --git a/libcxx/test/experimental/utilities/meta/meta.type.synop/meta.unary.prop.pass.cpp b/libcxx/test/experimental/utilities/meta/meta.type.synop/meta.unary.prop.pass.cpp new file mode 100644 index 00000000000..41cb27fced3 --- /dev/null +++ b/libcxx/test/experimental/utilities/meta/meta.type.synop/meta.unary.prop.pass.cpp @@ -0,0 +1,489 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <experimental/type_traits> + +#include <experimental/type_traits> + +#if _LIBCPP_STD_VER > 11 + +namespace ex = std::experimental; + +struct non_literal_type { non_literal_type() {} }; +struct empty_type {}; + +struct polymorphic_type +{ + virtual void foo() {} +}; + +struct abstract_type +{ + virtual void foo() = 0; +}; + +struct final_type final {}; + +struct virtual_dtor_type +{ + virtual ~virtual_dtor_type() {} +}; + +void type_properties_test() +{ + { + typedef const int T; + static_assert(ex::is_const_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_const_v<T>), const bool>::value, ""); + static_assert(ex::is_const_v<T> == std::is_const<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_const_v<T>, ""); + static_assert(ex::is_const_v<T> == std::is_const<T>::value, ""); + } + { + typedef volatile int T; + static_assert(ex::is_volatile_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_volatile_v<T>), const bool>::value, ""); + static_assert(ex::is_volatile_v<T> == std::is_volatile<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_volatile_v<T>, ""); + static_assert(ex::is_volatile_v<T> == std::is_volatile<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivial_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_trivial_v<T>), const bool>::value, ""); + static_assert(ex::is_trivial_v<T> == std::is_trivial<T>::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_trivial_v<T>, ""); + static_assert(ex::is_trivial_v<T> == std::is_trivial<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_copyable_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_trivially_copyable_v<T>), const bool>::value, ""); + static_assert(ex::is_trivially_copyable_v<T> == std::is_trivially_copyable<T>::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_trivially_copyable_v<T>, ""); + static_assert(ex::is_trivially_copyable_v<T> == std::is_trivially_copyable<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_standard_layout_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_standard_layout_v<T>), const bool>::value, ""); + static_assert(ex::is_standard_layout_v<T> == std::is_standard_layout<T>::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_standard_layout_v<T>, ""); + static_assert(ex::is_standard_layout_v<T> == std::is_standard_layout<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_pod_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_pod_v<T>), const bool>::value, ""); + static_assert(ex::is_pod_v<T> == std::is_pod<T>::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_pod_v<T>, ""); + static_assert(ex::is_pod_v<T> == std::is_pod<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_literal_type_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_literal_type_v<T>), const bool>::value, ""); + static_assert(ex::is_literal_type_v<T> == std::is_literal_type<T>::value, ""); + } + { + typedef non_literal_type T; + static_assert(!ex::is_literal_type_v<T>, ""); + static_assert(ex::is_literal_type_v<T> == std::is_literal_type<T>::value, ""); + } + { + typedef empty_type T; + static_assert(ex::is_empty_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_empty_v<T>), const bool>::value, ""); + static_assert(ex::is_empty_v<T> == std::is_empty<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_empty_v<T>, ""); + static_assert(ex::is_empty_v<T> == std::is_empty<T>::value, ""); + } + { + typedef polymorphic_type T; + static_assert(ex::is_polymorphic_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_polymorphic_v<T>), const bool>::value, ""); + static_assert(ex::is_polymorphic_v<T> == std::is_polymorphic<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_polymorphic_v<T>, ""); + static_assert(ex::is_polymorphic_v<T> == std::is_polymorphic<T>::value, ""); + } + { + typedef abstract_type T; + static_assert(ex::is_abstract_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_abstract_v<T>), const bool>::value, ""); + static_assert(ex::is_abstract_v<T> == std::is_abstract<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_abstract_v<T>, ""); + static_assert(ex::is_abstract_v<T> == std::is_abstract<T>::value, ""); + } + { + typedef final_type T; + static_assert(ex::is_final_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_final_v<T>), const bool>::value, ""); + static_assert(ex::is_final_v<T> == std::is_final<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_final_v<T>, ""); + static_assert(ex::is_final_v<T> == std::is_final<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_signed_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_signed_v<T>), const bool>::value, ""); + static_assert(ex::is_signed_v<T> == std::is_signed<T>::value, ""); + } + { + typedef unsigned T; + static_assert(!ex::is_signed_v<T>, ""); + static_assert(ex::is_signed_v<T> == std::is_signed<T>::value, ""); + } + { + typedef unsigned T; + static_assert(ex::is_unsigned_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_unsigned_v<T>), const bool>::value, ""); + static_assert(ex::is_unsigned_v<T> == std::is_unsigned<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::is_unsigned_v<T>, ""); + static_assert(ex::is_unsigned_v<T> == std::is_unsigned<T>::value, ""); + } +} + +void is_constructible_and_assignable_test() +{ + { + typedef int T; + static_assert(ex::is_constructible_v<T, int>, ""); + static_assert(std::is_same<decltype(ex::is_constructible_v<T, int>), const bool>::value, ""); + static_assert(ex::is_constructible_v<T, int> == std::is_constructible<T, int>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_constructible_v<T, int>, ""); + static_assert(ex::is_constructible_v<T, int> == std::is_constructible<T, int>::value, ""); + } + { + typedef int T; + static_assert(ex::is_default_constructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_default_constructible_v<T>), const bool>::value, ""); + static_assert(ex::is_default_constructible_v<T> == std::is_default_constructible<T>::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_default_constructible_v<T>, ""); + static_assert(ex::is_default_constructible_v<T> == std::is_default_constructible<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_copy_constructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_copy_constructible_v<T>), const bool>::value, ""); + static_assert(ex::is_copy_constructible_v<T> == std::is_copy_constructible<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_copy_constructible_v<T>, ""); + static_assert(ex::is_copy_constructible_v<T> == std::is_copy_constructible<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_move_constructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_move_constructible_v<T>), const bool>::value, ""); + static_assert(ex::is_move_constructible_v<T> == std::is_move_constructible<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_move_constructible_v<T>, ""); + static_assert(ex::is_move_constructible_v<T> == std::is_move_constructible<T>::value, ""); + } + { + typedef int & T; + typedef int U; + static_assert(ex::is_assignable_v<T, U>, ""); + static_assert(std::is_same<decltype(ex::is_assignable_v<T, U>), const bool>::value, ""); + static_assert(ex::is_assignable_v<T, U> == std::is_assignable<T, U>::value, ""); + } + { + typedef int & T; + typedef void U; + static_assert(!ex::is_assignable_v<T, U>, ""); + static_assert(ex::is_assignable_v<T, U> == std::is_assignable<T, U>::value, ""); + } + { + typedef int T; + static_assert(ex::is_copy_assignable_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_copy_assignable_v<T>), const bool>::value, ""); + static_assert(ex::is_copy_assignable_v<T> == std::is_copy_assignable<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_copy_assignable_v<T>, ""); + static_assert(ex::is_copy_assignable_v<T> == std::is_copy_assignable<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_move_assignable_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_move_assignable_v<T>), const bool>::value, ""); + static_assert(ex::is_move_assignable_v<T> == std::is_move_assignable<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_move_assignable_v<T>, ""); + static_assert(ex::is_move_assignable_v<T> == std::is_move_assignable<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_destructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_destructible_v<T>), const bool>::value, ""); + static_assert(ex::is_destructible_v<T> == std::is_destructible<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_destructible_v<T>, ""); + static_assert(ex::is_destructible_v<T> == std::is_destructible<T>::value, ""); + } +} + +void is_trivially_constructible_and_assignable_test() +{ + { + typedef int T; + static_assert(ex::is_trivially_constructible_v<T, int>, ""); + static_assert(std::is_same<decltype(ex::is_trivially_constructible_v<T, int>), const bool>::value, ""); + static_assert(ex::is_trivially_constructible_v<T, int> == std::is_constructible<T, int>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_constructible_v<T, int>, ""); + static_assert(ex::is_trivially_constructible_v<T, int> == std::is_constructible<T, int>::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_default_constructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_trivially_default_constructible_v<T>), const bool>::value, ""); + static_assert(ex::is_trivially_default_constructible_v<T> == std::is_default_constructible<T>::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_trivially_default_constructible_v<T>, ""); + static_assert(ex::is_trivially_default_constructible_v<T> == std::is_default_constructible<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_copy_constructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_trivially_copy_constructible_v<T>), const bool>::value, ""); + static_assert(ex::is_trivially_copy_constructible_v<T> == std::is_copy_constructible<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_copy_constructible_v<T>, ""); + static_assert(ex::is_trivially_copy_constructible_v<T> == std::is_copy_constructible<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_move_constructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_trivially_move_constructible_v<T>), const bool>::value, ""); + static_assert(ex::is_trivially_move_constructible_v<T> == std::is_move_constructible<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_move_constructible_v<T>, ""); + static_assert(ex::is_trivially_move_constructible_v<T> == std::is_move_constructible<T>::value, ""); + } + { + typedef int & T; + typedef int U; + static_assert(ex::is_trivially_assignable_v<T, U>, ""); + static_assert(std::is_same<decltype(ex::is_trivially_assignable_v<T, U>), const bool>::value, ""); + static_assert(ex::is_trivially_assignable_v<T, U> == std::is_assignable<T, U>::value, ""); + } + { + typedef int & T; + typedef void U; + static_assert(!ex::is_trivially_assignable_v<T, U>, ""); + static_assert(ex::is_trivially_assignable_v<T, U> == std::is_assignable<T, U>::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_copy_assignable_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_trivially_copy_assignable_v<T>), const bool>::value, ""); + static_assert(ex::is_trivially_copy_assignable_v<T> == std::is_copy_assignable<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_copy_assignable_v<T>, ""); + static_assert(ex::is_trivially_copy_assignable_v<T> == std::is_copy_assignable<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_move_assignable_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_trivially_move_assignable_v<T>), const bool>::value, ""); + static_assert(ex::is_trivially_move_assignable_v<T> == std::is_move_assignable<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_move_assignable_v<T>, ""); + static_assert(ex::is_trivially_move_assignable_v<T> == std::is_move_assignable<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_destructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_trivially_destructible_v<T>), const bool>::value, ""); + static_assert(ex::is_trivially_destructible_v<T> == std::is_destructible<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_destructible_v<T>, ""); + static_assert(ex::is_trivially_destructible_v<T> == std::is_destructible<T>::value, ""); + } +} + + + +void is_nothrow_constructible_and_assignable_test() +{ + { + typedef int T; + static_assert(ex::is_nothrow_constructible_v<T, int>, ""); + static_assert(std::is_same<decltype(ex::is_nothrow_constructible_v<T, int>), const bool>::value, ""); + static_assert(ex::is_nothrow_constructible_v<T, int> == std::is_constructible<T, int>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_constructible_v<T, int>, ""); + static_assert(ex::is_nothrow_constructible_v<T, int> == std::is_constructible<T, int>::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_default_constructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_nothrow_default_constructible_v<T>), const bool>::value, ""); + static_assert(ex::is_nothrow_default_constructible_v<T> == std::is_default_constructible<T>::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_nothrow_default_constructible_v<T>, ""); + static_assert(ex::is_nothrow_default_constructible_v<T> == std::is_default_constructible<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_copy_constructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_nothrow_copy_constructible_v<T>), const bool>::value, ""); + static_assert(ex::is_nothrow_copy_constructible_v<T> == std::is_copy_constructible<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_copy_constructible_v<T>, ""); + static_assert(ex::is_nothrow_copy_constructible_v<T> == std::is_copy_constructible<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_move_constructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_nothrow_move_constructible_v<T>), const bool>::value, ""); + static_assert(ex::is_nothrow_move_constructible_v<T> == std::is_move_constructible<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_move_constructible_v<T>, ""); + static_assert(ex::is_nothrow_move_constructible_v<T> == std::is_move_constructible<T>::value, ""); + } + { + typedef int & T; + typedef int U; + static_assert(ex::is_nothrow_assignable_v<T, U>, ""); + static_assert(std::is_same<decltype(ex::is_nothrow_assignable_v<T, U>), const bool>::value, ""); + static_assert(ex::is_nothrow_assignable_v<T, U> == std::is_assignable<T, U>::value, ""); + } + { + typedef int & T; + typedef void U; + static_assert(!ex::is_nothrow_assignable_v<T, U>, ""); + static_assert(ex::is_nothrow_assignable_v<T, U> == std::is_assignable<T, U>::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_copy_assignable_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_nothrow_copy_assignable_v<T>), const bool>::value, ""); + static_assert(ex::is_nothrow_copy_assignable_v<T> == std::is_copy_assignable<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_copy_assignable_v<T>, ""); + static_assert(ex::is_nothrow_copy_assignable_v<T> == std::is_copy_assignable<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_move_assignable_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_nothrow_move_assignable_v<T>), const bool>::value, ""); + static_assert(ex::is_nothrow_move_assignable_v<T> == std::is_move_assignable<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_move_assignable_v<T>, ""); + static_assert(ex::is_nothrow_move_assignable_v<T> == std::is_move_assignable<T>::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_destructible_v<T>, ""); + static_assert(std::is_same<decltype(ex::is_nothrow_destructible_v<T>), const bool>::value, ""); + static_assert(ex::is_nothrow_destructible_v<T> == std::is_destructible<T>::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_destructible_v<T>, ""); + static_assert(ex::is_nothrow_destructible_v<T> == std::is_destructible<T>::value, ""); + } +} + +int main() +{ + type_properties_test(); + is_constructible_and_assignable_test(); + is_trivially_constructible_and_assignable_test(); + is_nothrow_constructible_and_assignable_test(); + { + typedef virtual_dtor_type T; + static_assert(ex::has_virtual_destructor_v<T>, ""); + static_assert(std::is_same<decltype(ex::has_virtual_destructor_v<T>), const bool>::value, ""); + static_assert(ex::has_virtual_destructor_v<T> == std::has_virtual_destructor<T>::value, ""); + } + { + typedef int T; + static_assert(!ex::has_virtual_destructor_v<T>, ""); + static_assert(ex::has_virtual_destructor_v<T> == std::has_virtual_destructor<T>::value, ""); + } +} +#else /* _LIBCPP_STD_VER <= 11 */ +int main() {} +#endif /* _LIBCPP_STD_VER > 11 */ diff --git a/libcxx/test/experimental/utilities/meta/meta.type.synop/meta.unary.prop.query.pass.cpp b/libcxx/test/experimental/utilities/meta/meta.type.synop/meta.unary.prop.query.pass.cpp new file mode 100644 index 00000000000..aedd369e5ac --- /dev/null +++ b/libcxx/test/experimental/utilities/meta/meta.type.synop/meta.unary.prop.query.pass.cpp @@ -0,0 +1,66 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <experimental/type_traits> + +#include <experimental/type_traits> + +#if _LIBCPP_STD_VER > 11 + +namespace ex = std::experimental; + +int main() +{ + { + typedef char T; + static_assert(ex::alignment_of_v<T> == 1, ""); + static_assert(std::is_same<decltype(ex::alignment_of_v<T>), const std::size_t>::value, ""); + static_assert(ex::alignment_of_v<T> == std::alignment_of<T>::value, ""); + } + { + typedef char(T)[1][1][1]; + static_assert(ex::rank_v<T> == 3, ""); + static_assert(std::is_same<decltype(ex::rank_v<T>), const std::size_t>::value, ""); + static_assert(ex::rank_v<T> == std::rank<T>::value, ""); + } + { + typedef void T; + static_assert(ex::rank_v<T> == 0, ""); + static_assert(ex::rank_v<T> == std::rank<T>::value, ""); + } + { + typedef char(T)[2][3][4]; + static_assert(ex::extent_v<T> == 2, ""); + static_assert(std::is_same<decltype(ex::extent_v<T>), const std::size_t>::value, ""); + static_assert(ex::extent_v<T> == std::extent<T>::value, ""); + } + { + typedef char(T)[2][3][4]; + static_assert(ex::extent_v<T, 0> == 2, ""); + static_assert(ex::extent_v<T, 0> == std::extent<T, 0>::value, ""); + } + { + typedef char(T)[2][3][4]; + static_assert(ex::extent_v<T, 1> == 3, ""); + static_assert(ex::extent_v<T, 1> == std::extent<T, 1>::value, ""); + } + { + typedef char(T)[2][3][4]; + static_assert(ex::extent_v<T, 5> == 0, ""); + static_assert(ex::extent_v<T, 5> == std::extent<T, 5>::value, ""); + } + { + typedef void T; + static_assert(ex::extent_v<T, 0> == 0, ""); + static_assert(ex::extent_v<T, 0> == std::extent<T, 0>::value, ""); + } +} +#else /* _LIBCPP_STD_VER <= 11 */ +int main() {} +#endif /* _LIBCPP_STD_VER > 11 */ diff --git a/libcxx/test/experimental/utilities/meta/version.pass.cpp b/libcxx/test/experimental/utilities/meta/version.pass.cpp new file mode 100644 index 00000000000..593fb52a4c3 --- /dev/null +++ b/libcxx/test/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() +{ +} |

