diff options
Diffstat (limited to 'test/std/utilities/meta/meta.trans')
5 files changed, 131 insertions, 10 deletions
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.fail.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.fail.cpp new file mode 100644 index 0000000000000..efee5064cf59c --- /dev/null +++ b/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.fail.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// type_traits + +// aligned_union<size_t Len, class ...Types> + +#include <type_traits> + +class A; // Incomplete + +int main() +{ + typedef std::aligned_union<10, A>::type T1; +} diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp index 4f45a0340a916..c0aece771f0c5 100644 --- a/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp +++ b/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp @@ -34,9 +34,9 @@ int main() test_decay<const int[3], const int*>(); test_decay<void(), void (*)()>(); #if TEST_STD_VER > 11 - test_decay<int(int) const, int(int) const>(); - test_decay<int(int) volatile, int(int) volatile>(); - test_decay<int(int) &, int(int) &>(); - test_decay<int(int) &&, int(int) &&>(); + test_decay<int(int) const, int(int) const>(); + test_decay<int(int) volatile, int(int) volatile>(); + test_decay<int(int) &, int(int) &>(); + test_decay<int(int) &&, int(int) &&>(); #endif } diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/remove_cvref.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/remove_cvref.pass.cpp new file mode 100644 index 0000000000000..e06229f7e9756 --- /dev/null +++ b/test/std/utilities/meta/meta.trans/meta.trans.other/remove_cvref.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +// type_traits + +// remove_cvref + +#include <type_traits> + +#include "test_macros.h" + +template <class T, class U> +void test_remove_cvref() +{ + static_assert((std::is_same<typename std::remove_cvref<T>::type, U>::value), ""); + static_assert((std::is_same< std::remove_cvref_t<T>, U>::value), ""); +} + +int main() +{ + test_remove_cvref<void, void>(); + test_remove_cvref<int, int>(); + test_remove_cvref<const int, int>(); + test_remove_cvref<const volatile int, int>(); + test_remove_cvref<volatile int, int>(); + +// Doesn't decay + test_remove_cvref<int[3], int[3]>(); + test_remove_cvref<int const [3], int[3]>(); + test_remove_cvref<int volatile [3], int[3]>(); + test_remove_cvref<int const volatile [3], int[3]>(); + test_remove_cvref<void(), void ()>(); + + test_remove_cvref<int &, int>(); + test_remove_cvref<const int &, int>(); + test_remove_cvref<const volatile int &, int>(); + test_remove_cvref<volatile int &, int>(); + + test_remove_cvref<int*, int*>(); + test_remove_cvref<int(int) const, int(int) const>(); + test_remove_cvref<int(int) volatile, int(int) volatile>(); + test_remove_cvref<int(int) &, int(int) &>(); + test_remove_cvref<int(int) &&, int(int) &&>(); +} diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp index fc01b22c36abe..24231526b2bf8 100644 --- a/test/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp +++ b/test/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp @@ -42,16 +42,46 @@ struct HasType : std::false_type {}; template <class T> struct HasType<T, typename Voider<typename T::type>::type> : std::true_type {}; +#if TEST_STD_VER > 14 +template <typename T, typename U> +struct test_invoke_result; + +template <typename Fn, typename ...Args, typename Ret> +struct test_invoke_result<Fn(Args...), Ret> +{ + static void call() + { + static_assert(std::is_invocable<Fn, Args...>::value, ""); + static_assert(std::is_invocable_r<Ret, Fn, Args...>::value, ""); + static_assert((std::is_same<typename std::invoke_result<Fn, Args...>::type, Ret>::value), ""); + } +}; +#endif + template <class T, class U> void test_result_of() { + static_assert((std::is_same<typename std::result_of<T>::type, U>::value), ""); #if TEST_STD_VER > 14 - static_assert(std::is_callable<T>::value, ""); - static_assert(std::is_callable<T, U>::value, ""); + test_invoke_result<T, U>::call(); #endif - static_assert((std::is_same<typename std::result_of<T>::type, U>::value), ""); } +#if TEST_STD_VER > 14 +template <typename T> +struct test_invoke_no_result; + +template <typename Fn, typename ...Args> +struct test_invoke_no_result<Fn(Args...)> +{ + static void call() + { + static_assert(std::is_invocable<Fn, Args...>::value == false, ""); + static_assert((!HasType<std::invoke_result<Fn, Args...> >::value), ""); + } +}; +#endif + template <class T> void test_no_result() { @@ -59,7 +89,7 @@ void test_no_result() static_assert((!HasType<std::result_of<T> >::value), ""); #endif #if TEST_STD_VER > 14 - static_assert(std::is_callable<T>::value == false, ""); + test_invoke_no_result<T>::call(); #endif } diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp index eac4e4a089fed..2b8cd709677b5 100644 --- a/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp +++ b/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp @@ -27,6 +27,23 @@ struct wat struct F {}; struct FD : public F {}; +#if TEST_STD_VER > 14 +template <typename T, typename U> +struct test_invoke_result; + +template <typename Fn, typename ...Args, typename Ret> +struct test_invoke_result<Fn(Args...), Ret> +{ + static void call() + { + static_assert(std::is_invocable<Fn, Args...>::value, ""); + static_assert(std::is_invocable_r<Ret, Fn, Args...>::value, ""); + static_assert((std::is_same<typename std::invoke_result<Fn, Args...>::type, Ret>::value), ""); + static_assert((std::is_same<std::invoke_result_t<Fn, Args...>, Ret>::value), ""); + } +}; +#endif + template <class T, class U> void test_result_of_imp() { @@ -35,8 +52,7 @@ void test_result_of_imp() static_assert((std::is_same<std::result_of_t<T>, U>::value), ""); #endif #if TEST_STD_VER > 14 - static_assert(std::is_callable<T>::value, ""); - static_assert(std::is_callable<T, U>::value, ""); + test_invoke_result<T, U>::call(); #endif } |
