From 5459af15f9eaab5e7f28a74a45c811fbcd4e8e60 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Fri, 19 Dec 2014 22:21:44 +0000 Subject: [PATCH] [libcxx] Add for LFTS Summary: This adds the (minus invocation traits). Mostly just the `_v` traits. Reviewers: K-ballo, mclow.lists Reviewed By: mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5742 llvm-svn: 224626 --- libcxx/include/experimental/type_traits | 423 ++++++++++++++++++ .../meta/meta.type.synop/includes.pass.cpp | 22 + .../meta/meta.type.synop/meta.rel.pass.cpp | 65 +++ .../meta/meta.type.synop/meta.unary.cat.pass.cpp | 181 ++++++++ .../meta/meta.type.synop/meta.unary.comp.pass.cpp | 102 +++++ .../meta/meta.type.synop/meta.unary.prop.pass.cpp | 489 +++++++++++++++++++++ .../meta.type.synop/meta.unary.prop.query.pass.cpp | 66 +++ .../experimental/utilities/meta/version.pass.cpp | 20 + 8 files changed, 1368 insertions(+) create mode 100644 libcxx/include/experimental/type_traits create mode 100644 libcxx/test/experimental/utilities/meta/meta.type.synop/includes.pass.cpp create mode 100644 libcxx/test/experimental/utilities/meta/meta.type.synop/meta.rel.pass.cpp create mode 100644 libcxx/test/experimental/utilities/meta/meta.type.synop/meta.unary.cat.pass.cpp create mode 100644 libcxx/test/experimental/utilities/meta/meta.type.synop/meta.unary.comp.pass.cpp create mode 100644 libcxx/test/experimental/utilities/meta/meta.type.synop/meta.unary.prop.pass.cpp create mode 100644 libcxx/test/experimental/utilities/meta/meta.type.synop/meta.unary.prop.query.pass.cpp create mode 100644 libcxx/test/experimental/utilities/meta/version.pass.cpp diff --git a/libcxx/include/experimental/type_traits b/libcxx/include/experimental/type_traits new file mode 100644 index 0000000..ab2c8cd --- /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 + +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { + + // See C++14 20.10.4.1, primary type categories + template constexpr bool is_void_v + = is_void::value; + template constexpr bool is_null_pointer_v + = is_null_pointer::value; + template constexpr bool is_integral_v + = is_integral::value; + template constexpr bool is_floating_point_v + = is_floating_point::value; + template constexpr bool is_array_v + = is_array::value; + template constexpr bool is_pointer_v + = is_pointer::value; + template constexpr bool is_lvalue_reference_v + = is_lvalue_reference::value; + template constexpr bool is_rvalue_reference_v + = is_rvalue_reference::value; + template constexpr bool is_member_object_pointer_v + = is_member_object_pointer::value; + template constexpr bool is_member_function_pointer_v + = is_member_function_pointer::value; + template constexpr bool is_enum_v + = is_enum::value; + template constexpr bool is_union_v + = is_union::value; + template constexpr bool is_class_v + = is_class::value; + template constexpr bool is_function_v + = is_function::value; + + // See C++14 20.10.4.2, composite type categories + template constexpr bool is_reference_v + = is_reference::value; + template constexpr bool is_arithmetic_v + = is_arithmetic::value; + template constexpr bool is_fundamental_v + = is_fundamental::value; + template constexpr bool is_object_v + = is_object::value; + template constexpr bool is_scalar_v + = is_scalar::value; + template constexpr bool is_compound_v + = is_compound::value; + template constexpr bool is_member_pointer_v + = is_member_pointer::value; + + // See C++14 20.10.4.3, type properties + template constexpr bool is_const_v + = is_const::value; + template constexpr bool is_volatile_v + = is_volatile::value; + template constexpr bool is_trivial_v + = is_trivial::value; + template constexpr bool is_trivially_copyable_v + = is_trivially_copyable::value; + template constexpr bool is_standard_layout_v + = is_standard_layout::value; + template constexpr bool is_pod_v + = is_pod::value; + template constexpr bool is_literal_type_v + = is_literal_type::value; + template constexpr bool is_empty_v + = is_empty::value; + template constexpr bool is_polymorphic_v + = is_polymorphic::value; + template constexpr bool is_abstract_v + = is_abstract::value; + template constexpr bool is_final_v + = is_final::value; + template constexpr bool is_signed_v + = is_signed::value; + template constexpr bool is_unsigned_v + = is_unsigned::value; + template constexpr bool is_constructible_v + = is_constructible::value; + template constexpr bool is_default_constructible_v + = is_default_constructible::value; + template constexpr bool is_copy_constructible_v + = is_copy_constructible::value; + template constexpr bool is_move_constructible_v + = is_move_constructible::value; + template constexpr bool is_assignable_v + = is_assignable::value; + template constexpr bool is_copy_assignable_v + = is_copy_assignable::value; + template constexpr bool is_move_assignable_v + = is_move_assignable::value; + template constexpr bool is_destructible_v + = is_destructible::value; + template constexpr bool is_trivially_constructible_v + = is_trivially_constructible::value; + template constexpr bool is_trivially_default_constructible_v + = is_trivially_default_constructible::value; + template constexpr bool is_trivially_copy_constructible_v + = is_trivially_copy_constructible::value; + template constexpr bool is_trivially_move_constructible_v + = is_trivially_move_constructible::value; + template constexpr bool is_trivially_assignable_v + = is_trivially_assignable::value; + template constexpr bool is_trivially_copy_assignable_v + = is_trivially_copy_assignable::value; + template constexpr bool is_trivially_move_assignable_v + = is_trivially_move_assignable::value; + template constexpr bool is_trivially_destructible_v + = is_trivially_destructible::value; + template constexpr bool is_nothrow_constructible_v + = is_nothrow_constructible::value; + template constexpr bool is_nothrow_default_constructible_v + = is_nothrow_default_constructible::value; + template constexpr bool is_nothrow_copy_constructible_v + = is_nothrow_copy_constructible::value; + template constexpr bool is_nothrow_move_constructible_v + = is_nothrow_move_constructible::value; + template constexpr bool is_nothrow_assignable_v + = is_nothrow_assignable::value; + template constexpr bool is_nothrow_copy_assignable_v + = is_nothrow_copy_assignable::value; + template constexpr bool is_nothrow_move_assignable_v + = is_nothrow_move_assignable::value; + template constexpr bool is_nothrow_destructible_v + = is_nothrow_destructible::value; + template constexpr bool has_virtual_destructor_v + = has_virtual_destructor::value; + + // See C++14 20.10.5, type property queries + template constexpr size_t alignment_of_v + = alignment_of::value; + template constexpr size_t rank_v + = rank::value; + template constexpr size_t extent_v + = extent::value; + + // See C++14 20.10.6, type relations + template constexpr bool is_same_v + = is_same::value; + template constexpr bool is_base_of_v + = is_base_of::value; + template constexpr bool is_convertible_v + = is_convertible::value; + + // 3.3.2, Other type transformations + template class invocation_type; // not defined + template class invocation_type; + template class raw_invocation_type; // not defined + template class raw_invocation_type; + + template + using invocation_type_t = typename invocation_type::type; + template + using raw_invocation_type_t = typename raw_invocation_type::type; + +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + + */ + +#include + +#if _LIBCPP_STD_VER > 11 + +#include + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +#if __has_feature(cxx_variable_templates) + +// C++14 20.10.4.1, primary type categories + +template _LIBCPP_CONSTEXPR bool is_void_v + = is_void<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_null_pointer_v + = is_null_pointer<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_integral_v + = is_integral<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_floating_point_v + = is_floating_point<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_array_v + = is_array<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_pointer_v + = is_pointer<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_lvalue_reference_v + = is_lvalue_reference<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_rvalue_reference_v + = is_rvalue_reference<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_member_object_pointer_v + = is_member_object_pointer<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_member_function_pointer_v + = is_member_function_pointer<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_enum_v + = is_enum<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_union_v + = is_union<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_class_v + = is_class<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_function_v + = is_function<_Tp>::value; + +// C++14 20.10.4.2, composite type categories + +template _LIBCPP_CONSTEXPR bool is_reference_v + = is_reference<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_arithmetic_v + = is_arithmetic<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_fundamental_v + = is_fundamental<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_object_v + = is_object<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_scalar_v + = is_scalar<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_compound_v + = is_compound<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_member_pointer_v + = is_member_pointer<_Tp>::value; + +// C++14 20.10.4.3, type properties + +template _LIBCPP_CONSTEXPR bool is_const_v + = is_const<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_volatile_v + = is_volatile<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_trivial_v + = is_trivial<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_trivially_copyable_v + = is_trivially_copyable<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_standard_layout_v + = is_standard_layout<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_pod_v + = is_pod<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_literal_type_v + = is_literal_type<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_empty_v + = is_empty<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_polymorphic_v + = is_polymorphic<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_abstract_v + = is_abstract<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_final_v + = is_final<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_signed_v + = is_signed<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_unsigned_v + = is_unsigned<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_constructible_v + = is_constructible<_Tp, _Ts...>::value; + +template _LIBCPP_CONSTEXPR bool is_default_constructible_v + = is_default_constructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_copy_constructible_v + = is_copy_constructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_move_constructible_v + = is_move_constructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_assignable_v + = is_assignable<_Tp, _Up>::value; + +template _LIBCPP_CONSTEXPR bool is_copy_assignable_v + = is_copy_assignable<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_move_assignable_v + = is_move_assignable<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_destructible_v + = is_destructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_trivially_constructible_v + = is_trivially_constructible<_Tp, _Ts...>::value; + +template _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v + = is_trivially_default_constructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v + = is_trivially_copy_constructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v + = is_trivially_move_constructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_trivially_assignable_v + = is_trivially_assignable<_Tp, _Up>::value; + +template _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v + = is_trivially_copy_assignable<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v + = is_trivially_move_assignable<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_trivially_destructible_v + = is_trivially_destructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v + = is_nothrow_constructible<_Tp, _Ts...>::value; + +template _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v + = is_nothrow_default_constructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v + = is_nothrow_copy_constructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v + = is_nothrow_move_constructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v + = is_nothrow_assignable<_Tp, _Up>::value; + +template _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v + = is_nothrow_copy_assignable<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v + = is_nothrow_move_assignable<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v + = is_nothrow_destructible<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool has_virtual_destructor_v + = has_virtual_destructor<_Tp>::value; + +// C++14 20.10.5, type properties queries + +template _LIBCPP_CONSTEXPR size_t alignment_of_v + = alignment_of<_Tp>::value; + +template _LIBCPP_CONSTEXPR size_t rank_v + = rank<_Tp>::value; + +template _LIBCPP_CONSTEXPR size_t extent_v + = extent<_Tp, _Id>::value; + +// C++14 20.10.6, type relations + +template _LIBCPP_CONSTEXPR bool is_same_v + = is_same<_Tp, _Up>::value; + +template _LIBCPP_CONSTEXPR bool is_base_of_v + = is_base_of<_Tp, _Up>::value; + +template _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 _LIBCPP_TYPE_VIS_ONLY raw_invocation_type; + +template +class _LIBCPP_TYPE_VIS_ONLY raw_invocation_type<_Fn(_Args...)>; + +template +class _LIBCPP_TYPE_VIS_ONLY invokation_type; + +template +class _LIBCPP_TYPE_VIS_ONLY invokation_type<_Fn(_Args...)>; + +template +using invokation_type_t = typename invokation_type<_Tp>::type; + +template +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 0000000..2c90dd6 --- /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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#if _LIBCPP_STD_VER > 11 +# ifndef _LIBCPP_TYPE_TRAITS +# error " must include " +# 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 0000000..96af4b6 --- /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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_same_v == std::is_same::value, ""); + } + { + typedef int T; + typedef long U; + static_assert(!ex::is_same_v, ""); + static_assert(ex::is_same_v == std::is_same::value, ""); + } + { + typedef base_type T; + typedef derived_type U; + static_assert(ex::is_base_of_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_base_of_v == std::is_base_of::value, ""); + } + { + typedef int T; + typedef int U; + static_assert(!ex::is_base_of_v, ""); + static_assert(ex::is_base_of_v == std::is_base_of::value, ""); + } + { + typedef int T; + typedef long U; + static_assert(ex::is_convertible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_convertible_v == std::is_convertible::value, ""); + } + { + typedef void T; + typedef int U; + static_assert(!ex::is_convertible_v, ""); + static_assert(ex::is_convertible_v == std::is_convertible::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 0000000..2d1e706 --- /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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_void_v == std::is_void::value, ""); + } + { + typedef int T; + static_assert(!ex::is_void_v, ""); + static_assert(ex::is_void_v == std::is_void::value, ""); + } + { + typedef decltype(nullptr) T; + static_assert(ex::is_null_pointer_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_null_pointer_v == std::is_null_pointer::value, ""); + } + { + typedef int T; + static_assert(!ex::is_null_pointer_v, ""); + static_assert(ex::is_null_pointer_v == std::is_null_pointer::value, ""); + } + { + typedef int T; + static_assert(ex::is_integral_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_integral_v == std::is_integral::value, ""); + } + { + typedef void T; + static_assert(!ex::is_integral_v, ""); + static_assert(ex::is_integral_v == std::is_integral::value, ""); + } + { + typedef float T; + static_assert(ex::is_floating_point_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_floating_point_v == std::is_floating_point::value, ""); + } + { + typedef int T; + static_assert(!ex::is_floating_point_v, ""); + static_assert(ex::is_floating_point_v == std::is_floating_point::value, ""); + } + { + typedef int(T)[42]; + static_assert(ex::is_array_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_array_v == std::is_array::value, ""); + } + { + typedef int T; + static_assert(!ex::is_array_v, ""); + static_assert(ex::is_array_v == std::is_array::value, ""); + } + { + typedef void* T; + static_assert(ex::is_pointer_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_pointer_v == std::is_pointer::value, ""); + } + { + typedef int T; + static_assert(!ex::is_pointer_v, ""); + static_assert(ex::is_pointer_v == std::is_pointer::value, ""); + } + { + typedef int & T; + static_assert(ex::is_lvalue_reference_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_lvalue_reference_v == std::is_lvalue_reference::value, ""); + } + { + typedef int T; + static_assert(!ex::is_lvalue_reference_v, ""); + static_assert(ex::is_lvalue_reference_v == std::is_lvalue_reference::value, ""); + } + { + typedef int && T; + static_assert(ex::is_rvalue_reference_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_rvalue_reference_v == std::is_rvalue_reference::value, ""); + } + { + typedef int T; + static_assert(!ex::is_rvalue_reference_v, ""); + static_assert(ex::is_rvalue_reference_v == std::is_rvalue_reference::value, ""); + } + { + typedef int class_type::*T; + static_assert(ex::is_member_object_pointer_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_member_object_pointer_v == std::is_member_object_pointer::value, ""); + } + { + typedef int T; + static_assert(!ex::is_member_object_pointer_v, ""); + static_assert(ex::is_member_object_pointer_v == std::is_member_object_pointer::value, ""); + } + { + typedef void(class_type::*T)(); + static_assert(ex::is_member_function_pointer_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_member_function_pointer_v == std::is_member_function_pointer::value, ""); + } + { + typedef int T; + static_assert(!ex::is_member_function_pointer_v, ""); + static_assert(ex::is_member_function_pointer_v == std::is_member_function_pointer::value, ""); + } + { + typedef enum_type T; + static_assert(ex::is_enum_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_enum_v == std::is_enum::value, ""); + } + { + typedef int T; + static_assert(!ex::is_enum_v, ""); + static_assert(ex::is_enum_v == std::is_enum::value, ""); + } + { + typedef union_type T; + static_assert(ex::is_union_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_union_v == std::is_union::value, ""); + } + { + typedef int T; + static_assert(!ex::is_union_v, ""); + static_assert(ex::is_union_v == std::is_union::value, ""); + } + { + typedef class_type T; + static_assert(ex::is_class_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_class_v == std::is_class::value, ""); + } + { + typedef int T; + static_assert(!ex::is_class_v, ""); + static_assert(ex::is_class_v == std::is_class::value, ""); + } + { + typedef void(T)(); + static_assert(ex::is_function_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_function_v == std::is_function::value, ""); + } + { + typedef int T; + static_assert(!ex::is_function_v, ""); + static_assert(ex::is_function_v == std::is_function::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 0000000..814f450 --- /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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#if _LIBCPP_STD_VER > 11 + +namespace ex = std::experimental; + +struct class_type {}; + +int main() +{ + { + typedef int & T; + static_assert(ex::is_reference_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_reference_v == std::is_reference::value, ""); + } + { + typedef int T; + static_assert(!ex::is_reference_v, ""); + static_assert(ex::is_reference_v == std::is_reference::value, ""); + } + { + typedef int T; + static_assert(ex::is_arithmetic_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_arithmetic_v == std::is_arithmetic::value, ""); + } + { + typedef void* T; + static_assert(!ex::is_arithmetic_v, ""); + static_assert(ex::is_arithmetic_v == std::is_arithmetic::value, ""); + } + { + typedef int T; + static_assert(ex::is_fundamental_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_fundamental_v == std::is_fundamental::value, ""); + } + { + typedef class_type T; + static_assert(!ex::is_fundamental_v, ""); + static_assert(ex::is_fundamental_v == std::is_fundamental::value, ""); + } + { + typedef class_type T; + static_assert(ex::is_object_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_object_v == std::is_object::value, ""); + } + { + typedef void T; + static_assert(!ex::is_object_v, ""); + static_assert(ex::is_object_v == std::is_object::value, ""); + } + { + typedef int T; + static_assert(ex::is_scalar_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_scalar_v == std::is_scalar::value, ""); + } + { + typedef void T; + static_assert(!ex::is_scalar_v, ""); + static_assert(ex::is_scalar_v == std::is_scalar::value, ""); + } + { + typedef void* T; + static_assert(ex::is_compound_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_compound_v == std::is_compound::value, ""); + } + { + typedef void T; + static_assert(!ex::is_compound_v, ""); + static_assert(ex::is_compound_v == std::is_compound::value, ""); + } + { + typedef int class_type::*T; + static_assert(ex::is_member_pointer_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_member_pointer_v == std::is_member_pointer::value, ""); + } + { + typedef int T; + static_assert(!ex::is_member_pointer_v, ""); + static_assert(ex::is_member_pointer_v == std::is_member_pointer::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 0000000..41cb27f --- /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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#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, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_const_v == std::is_const::value, ""); + } + { + typedef int T; + static_assert(!ex::is_const_v, ""); + static_assert(ex::is_const_v == std::is_const::value, ""); + } + { + typedef volatile int T; + static_assert(ex::is_volatile_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_volatile_v == std::is_volatile::value, ""); + } + { + typedef int T; + static_assert(!ex::is_volatile_v, ""); + static_assert(ex::is_volatile_v == std::is_volatile::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivial_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_trivial_v == std::is_trivial::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_trivial_v, ""); + static_assert(ex::is_trivial_v == std::is_trivial::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_copyable_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_trivially_copyable_v == std::is_trivially_copyable::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_trivially_copyable_v, ""); + static_assert(ex::is_trivially_copyable_v == std::is_trivially_copyable::value, ""); + } + { + typedef int T; + static_assert(ex::is_standard_layout_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_standard_layout_v == std::is_standard_layout::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_standard_layout_v, ""); + static_assert(ex::is_standard_layout_v == std::is_standard_layout::value, ""); + } + { + typedef int T; + static_assert(ex::is_pod_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_pod_v == std::is_pod::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_pod_v, ""); + static_assert(ex::is_pod_v == std::is_pod::value, ""); + } + { + typedef int T; + static_assert(ex::is_literal_type_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_literal_type_v == std::is_literal_type::value, ""); + } + { + typedef non_literal_type T; + static_assert(!ex::is_literal_type_v, ""); + static_assert(ex::is_literal_type_v == std::is_literal_type::value, ""); + } + { + typedef empty_type T; + static_assert(ex::is_empty_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_empty_v == std::is_empty::value, ""); + } + { + typedef int T; + static_assert(!ex::is_empty_v, ""); + static_assert(ex::is_empty_v == std::is_empty::value, ""); + } + { + typedef polymorphic_type T; + static_assert(ex::is_polymorphic_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_polymorphic_v == std::is_polymorphic::value, ""); + } + { + typedef int T; + static_assert(!ex::is_polymorphic_v, ""); + static_assert(ex::is_polymorphic_v == std::is_polymorphic::value, ""); + } + { + typedef abstract_type T; + static_assert(ex::is_abstract_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_abstract_v == std::is_abstract::value, ""); + } + { + typedef int T; + static_assert(!ex::is_abstract_v, ""); + static_assert(ex::is_abstract_v == std::is_abstract::value, ""); + } + { + typedef final_type T; + static_assert(ex::is_final_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_final_v == std::is_final::value, ""); + } + { + typedef int T; + static_assert(!ex::is_final_v, ""); + static_assert(ex::is_final_v == std::is_final::value, ""); + } + { + typedef int T; + static_assert(ex::is_signed_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_signed_v == std::is_signed::value, ""); + } + { + typedef unsigned T; + static_assert(!ex::is_signed_v, ""); + static_assert(ex::is_signed_v == std::is_signed::value, ""); + } + { + typedef unsigned T; + static_assert(ex::is_unsigned_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_unsigned_v == std::is_unsigned::value, ""); + } + { + typedef int T; + static_assert(!ex::is_unsigned_v, ""); + static_assert(ex::is_unsigned_v == std::is_unsigned::value, ""); + } +} + +void is_constructible_and_assignable_test() +{ + { + typedef int T; + static_assert(ex::is_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_constructible_v == std::is_constructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_constructible_v, ""); + static_assert(ex::is_constructible_v == std::is_constructible::value, ""); + } + { + typedef int T; + static_assert(ex::is_default_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_default_constructible_v == std::is_default_constructible::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_default_constructible_v, ""); + static_assert(ex::is_default_constructible_v == std::is_default_constructible::value, ""); + } + { + typedef int T; + static_assert(ex::is_copy_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_copy_constructible_v == std::is_copy_constructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_copy_constructible_v, ""); + static_assert(ex::is_copy_constructible_v == std::is_copy_constructible::value, ""); + } + { + typedef int T; + static_assert(ex::is_move_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_move_constructible_v == std::is_move_constructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_move_constructible_v, ""); + static_assert(ex::is_move_constructible_v == std::is_move_constructible::value, ""); + } + { + typedef int & T; + typedef int U; + static_assert(ex::is_assignable_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_assignable_v == std::is_assignable::value, ""); + } + { + typedef int & T; + typedef void U; + static_assert(!ex::is_assignable_v, ""); + static_assert(ex::is_assignable_v == std::is_assignable::value, ""); + } + { + typedef int T; + static_assert(ex::is_copy_assignable_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_copy_assignable_v == std::is_copy_assignable::value, ""); + } + { + typedef void T; + static_assert(!ex::is_copy_assignable_v, ""); + static_assert(ex::is_copy_assignable_v == std::is_copy_assignable::value, ""); + } + { + typedef int T; + static_assert(ex::is_move_assignable_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_move_assignable_v == std::is_move_assignable::value, ""); + } + { + typedef void T; + static_assert(!ex::is_move_assignable_v, ""); + static_assert(ex::is_move_assignable_v == std::is_move_assignable::value, ""); + } + { + typedef int T; + static_assert(ex::is_destructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_destructible_v == std::is_destructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_destructible_v, ""); + static_assert(ex::is_destructible_v == std::is_destructible::value, ""); + } +} + +void is_trivially_constructible_and_assignable_test() +{ + { + typedef int T; + static_assert(ex::is_trivially_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_trivially_constructible_v == std::is_constructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_constructible_v, ""); + static_assert(ex::is_trivially_constructible_v == std::is_constructible::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_default_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_trivially_default_constructible_v == std::is_default_constructible::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_trivially_default_constructible_v, ""); + static_assert(ex::is_trivially_default_constructible_v == std::is_default_constructible::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_copy_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_trivially_copy_constructible_v == std::is_copy_constructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_copy_constructible_v, ""); + static_assert(ex::is_trivially_copy_constructible_v == std::is_copy_constructible::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_move_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_trivially_move_constructible_v == std::is_move_constructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_move_constructible_v, ""); + static_assert(ex::is_trivially_move_constructible_v == std::is_move_constructible::value, ""); + } + { + typedef int & T; + typedef int U; + static_assert(ex::is_trivially_assignable_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_trivially_assignable_v == std::is_assignable::value, ""); + } + { + typedef int & T; + typedef void U; + static_assert(!ex::is_trivially_assignable_v, ""); + static_assert(ex::is_trivially_assignable_v == std::is_assignable::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_copy_assignable_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_trivially_copy_assignable_v == std::is_copy_assignable::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_copy_assignable_v, ""); + static_assert(ex::is_trivially_copy_assignable_v == std::is_copy_assignable::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_move_assignable_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_trivially_move_assignable_v == std::is_move_assignable::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_move_assignable_v, ""); + static_assert(ex::is_trivially_move_assignable_v == std::is_move_assignable::value, ""); + } + { + typedef int T; + static_assert(ex::is_trivially_destructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_trivially_destructible_v == std::is_destructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_trivially_destructible_v, ""); + static_assert(ex::is_trivially_destructible_v == std::is_destructible::value, ""); + } +} + + + +void is_nothrow_constructible_and_assignable_test() +{ + { + typedef int T; + static_assert(ex::is_nothrow_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_nothrow_constructible_v == std::is_constructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_constructible_v, ""); + static_assert(ex::is_nothrow_constructible_v == std::is_constructible::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_default_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_nothrow_default_constructible_v == std::is_default_constructible::value, ""); + } + { + typedef int & T; + static_assert(!ex::is_nothrow_default_constructible_v, ""); + static_assert(ex::is_nothrow_default_constructible_v == std::is_default_constructible::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_copy_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_nothrow_copy_constructible_v == std::is_copy_constructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_copy_constructible_v, ""); + static_assert(ex::is_nothrow_copy_constructible_v == std::is_copy_constructible::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_move_constructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_nothrow_move_constructible_v == std::is_move_constructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_move_constructible_v, ""); + static_assert(ex::is_nothrow_move_constructible_v == std::is_move_constructible::value, ""); + } + { + typedef int & T; + typedef int U; + static_assert(ex::is_nothrow_assignable_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_nothrow_assignable_v == std::is_assignable::value, ""); + } + { + typedef int & T; + typedef void U; + static_assert(!ex::is_nothrow_assignable_v, ""); + static_assert(ex::is_nothrow_assignable_v == std::is_assignable::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_copy_assignable_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_nothrow_copy_assignable_v == std::is_copy_assignable::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_copy_assignable_v, ""); + static_assert(ex::is_nothrow_copy_assignable_v == std::is_copy_assignable::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_move_assignable_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_nothrow_move_assignable_v == std::is_move_assignable::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_move_assignable_v, ""); + static_assert(ex::is_nothrow_move_assignable_v == std::is_move_assignable::value, ""); + } + { + typedef int T; + static_assert(ex::is_nothrow_destructible_v, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::is_nothrow_destructible_v == std::is_destructible::value, ""); + } + { + typedef void T; + static_assert(!ex::is_nothrow_destructible_v, ""); + static_assert(ex::is_nothrow_destructible_v == std::is_destructible::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, ""); + static_assert(std::is_same), const bool>::value, ""); + static_assert(ex::has_virtual_destructor_v == std::has_virtual_destructor::value, ""); + } + { + typedef int T; + static_assert(!ex::has_virtual_destructor_v, ""); + static_assert(ex::has_virtual_destructor_v == std::has_virtual_destructor::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 0000000..aedd369 --- /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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#if _LIBCPP_STD_VER > 11 + +namespace ex = std::experimental; + +int main() +{ + { + typedef char T; + static_assert(ex::alignment_of_v == 1, ""); + static_assert(std::is_same), const std::size_t>::value, ""); + static_assert(ex::alignment_of_v == std::alignment_of::value, ""); + } + { + typedef char(T)[1][1][1]; + static_assert(ex::rank_v == 3, ""); + static_assert(std::is_same), const std::size_t>::value, ""); + static_assert(ex::rank_v == std::rank::value, ""); + } + { + typedef void T; + static_assert(ex::rank_v == 0, ""); + static_assert(ex::rank_v == std::rank::value, ""); + } + { + typedef char(T)[2][3][4]; + static_assert(ex::extent_v == 2, ""); + static_assert(std::is_same), const std::size_t>::value, ""); + static_assert(ex::extent_v == std::extent::value, ""); + } + { + typedef char(T)[2][3][4]; + static_assert(ex::extent_v == 2, ""); + static_assert(ex::extent_v == std::extent::value, ""); + } + { + typedef char(T)[2][3][4]; + static_assert(ex::extent_v == 3, ""); + static_assert(ex::extent_v == std::extent::value, ""); + } + { + typedef char(T)[2][3][4]; + static_assert(ex::extent_v == 0, ""); + static_assert(ex::extent_v == std::extent::value, ""); + } + { + typedef void T; + static_assert(ex::extent_v == 0, ""); + static_assert(ex::extent_v == std::extent::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 0000000..593fb52 --- /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. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} -- 2.7.4