diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:47:26 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:47:26 +0000 |
commit | 51072bd6bf79ef2bc6a922079bff57c31c1effbc (patch) | |
tree | 91a2effbc9e6f80bdbbf9eb70e06c51ad0867ea0 /test/std/utilities/meta | |
parent | bb5e33f003797b67974a8893f7f2930fc51b8210 (diff) |
Notes
Diffstat (limited to 'test/std/utilities/meta')
86 files changed, 1227 insertions, 179 deletions
diff --git a/test/std/utilities/meta/meta.hel/bool_constant.pass.cpp b/test/std/utilities/meta/meta.help/bool_constant.pass.cpp index 71110ea3bfb09..dcacf379b9ae3 100644 --- a/test/std/utilities/meta/meta.hel/bool_constant.pass.cpp +++ b/test/std/utilities/meta/meta.help/bool_constant.pass.cpp @@ -14,9 +14,11 @@ #include <type_traits> #include <cassert> +#include "test_macros.h" + int main() { -#if __cplusplus > 201402L +#if TEST_STD_VER > 14 typedef std::bool_constant<true> _t; static_assert(_t::value, ""); static_assert((std::is_same<_t::value_type, bool>::value), ""); diff --git a/test/std/utilities/meta/meta.hel/integral_constant.pass.cpp b/test/std/utilities/meta/meta.help/integral_constant.pass.cpp index 335305a282364..335305a282364 100644 --- a/test/std/utilities/meta/meta.hel/integral_constant.pass.cpp +++ b/test/std/utilities/meta/meta.help/integral_constant.pass.cpp diff --git a/test/std/utilities/meta/meta.logical/conjunction.pass.cpp b/test/std/utilities/meta/meta.logical/conjunction.pass.cpp index dce58ec23725d..d8dd386e9347a 100644 --- a/test/std/utilities/meta/meta.logical/conjunction.pass.cpp +++ b/test/std/utilities/meta/meta.logical/conjunction.pass.cpp @@ -11,7 +11,7 @@ // type_traits // template<class... B> struct conjunction; // C++17 -// template<class... B> +// template<class... B> // constexpr bool conjunction_v = conjunction<B...>::value; // C++17 #include <type_traits> @@ -34,7 +34,7 @@ int main() static_assert (!std::conjunction<std::true_type, std::false_type>::value, "" ); static_assert (!std::conjunction<std::false_type, std::true_type >::value, "" ); static_assert (!std::conjunction<std::false_type, std::false_type>::value, "" ); - + static_assert ( std::conjunction_v<std::true_type, std::true_type >, "" ); static_assert (!std::conjunction_v<std::true_type, std::false_type>, "" ); static_assert (!std::conjunction_v<std::false_type, std::true_type >, "" ); diff --git a/test/std/utilities/meta/meta.logical/disjunction.pass.cpp b/test/std/utilities/meta/meta.logical/disjunction.pass.cpp index 13cd9341b99f1..f5ba178d6483d 100644 --- a/test/std/utilities/meta/meta.logical/disjunction.pass.cpp +++ b/test/std/utilities/meta/meta.logical/disjunction.pass.cpp @@ -11,7 +11,7 @@ // type_traits // template<class... B> struct disjunction; // C++17 -// template<class... B> +// template<class... B> // constexpr bool disjunction_v = disjunction<B...>::value; // C++17 #include <type_traits> @@ -34,7 +34,7 @@ int main() static_assert ( std::disjunction<std::true_type, std::false_type>::value, "" ); static_assert ( std::disjunction<std::false_type, std::true_type >::value, "" ); static_assert (!std::disjunction<std::false_type, std::false_type>::value, "" ); - + static_assert ( std::disjunction_v<std::true_type, std::true_type >, "" ); static_assert ( std::disjunction_v<std::true_type, std::false_type>, "" ); static_assert ( std::disjunction_v<std::false_type, std::true_type >, "" ); diff --git a/test/std/utilities/meta/meta.logical/negation.pass.cpp b/test/std/utilities/meta/meta.logical/negation.pass.cpp index 76ff6c5b24db8..7b4eb27a75e1a 100644 --- a/test/std/utilities/meta/meta.logical/negation.pass.cpp +++ b/test/std/utilities/meta/meta.logical/negation.pass.cpp @@ -11,7 +11,7 @@ // type_traits // template<class B> struct negation; // C++17 -// template<class B> +// template<class B> // constexpr bool negation_v = negation<B>::value; // C++17 #include <type_traits> diff --git a/test/std/utilities/meta/meta.rel/is_callable.pass.cpp b/test/std/utilities/meta/meta.rel/is_callable.pass.cpp new file mode 100644 index 0000000000000..4c85f440b0bf9 --- /dev/null +++ b/test/std/utilities/meta/meta.rel/is_callable.pass.cpp @@ -0,0 +1,160 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// type_traits + +// is_callable + +// Most testing of is_callable is done within the [meta.trans.other] result_of +// tests. + +#include <type_traits> +#include <functional> +#include <memory> + +#include "test_macros.h" + +struct Tag {}; +struct DerFromTag : Tag {}; + +struct Implicit { + Implicit(int) {} +}; + +struct Explicit { + explicit Explicit(int) {} +}; + +struct NotCallableWithInt { + int operator()(int) = delete; + int operator()(Tag) { return 42; } +}; + +int main() +{ + { + using Fn = int(Tag::*)(int); + using RFn = int(Tag::*)(int) &&; + // INVOKE bullet 1, 2 and 3 + { + // Bullet 1 + static_assert(std::is_callable<Fn(Tag&, int)>::value, ""); + static_assert(std::is_callable<Fn(DerFromTag&, int)>::value, ""); + static_assert(std::is_callable<RFn(Tag&&, int)>::value, ""); + static_assert(!std::is_callable<RFn(Tag&, int)>::value, ""); + static_assert(!std::is_callable<Fn(Tag&)>::value, ""); + static_assert(!std::is_callable<Fn(Tag const&, int)>::value, ""); + } + { + // Bullet 2 + using T = std::reference_wrapper<Tag>; + using DT = std::reference_wrapper<DerFromTag>; + using CT = std::reference_wrapper<const Tag>; + static_assert(std::is_callable<Fn(T&, int)>::value, ""); + static_assert(std::is_callable<Fn(DT&, int)>::value, ""); + static_assert(std::is_callable<Fn(const T&, int)>::value, ""); + static_assert(std::is_callable<Fn(T&&, int)>::value, ""); + static_assert(!std::is_callable<Fn(CT&, int)>::value, ""); + static_assert(!std::is_callable<RFn(T, int)>::value, ""); + } + { + // Bullet 3 + using T = Tag*; + using DT = DerFromTag*; + using CT = const Tag*; + using ST = std::unique_ptr<Tag>; + static_assert(std::is_callable<Fn(T&, int)>::value, ""); + static_assert(std::is_callable<Fn(DT&, int)>::value, ""); + static_assert(std::is_callable<Fn(const T&, int)>::value, ""); + static_assert(std::is_callable<Fn(T&&, int)>::value, ""); + static_assert(std::is_callable<Fn(ST, int)>::value, ""); + static_assert(!std::is_callable<Fn(CT&, int)>::value, ""); + static_assert(!std::is_callable<RFn(T, int)>::value, ""); + } + } + { + // Bullets 4, 5 and 6 + using Fn = int (Tag::*); + static_assert(!std::is_callable<Fn()>::value, ""); + { + // Bullet 4 + static_assert(std::is_callable<Fn(Tag&)>::value, ""); + static_assert(std::is_callable<Fn(DerFromTag&)>::value, ""); + static_assert(std::is_callable<Fn(Tag&&)>::value, ""); + static_assert(std::is_callable<Fn(Tag const&)>::value, ""); + } + { + // Bullet 5 + using T = std::reference_wrapper<Tag>; + using DT = std::reference_wrapper<DerFromTag>; + using CT = std::reference_wrapper<const Tag>; + static_assert(std::is_callable<Fn(T&)>::value, ""); + static_assert(std::is_callable<Fn(DT&)>::value, ""); + static_assert(std::is_callable<Fn(const T&)>::value, ""); + static_assert(std::is_callable<Fn(T&&)>::value, ""); + static_assert(std::is_callable<Fn(CT&)>::value, ""); + } + { + // Bullet 6 + using T = Tag*; + using DT = DerFromTag*; + using CT = const Tag*; + using ST = std::unique_ptr<Tag>; + static_assert(std::is_callable<Fn(T&)>::value, ""); + static_assert(std::is_callable<Fn(DT&)>::value, ""); + static_assert(std::is_callable<Fn(const T&)>::value, ""); + static_assert(std::is_callable<Fn(T&&)>::value, ""); + static_assert(std::is_callable<Fn(ST)>::value, ""); + static_assert(std::is_callable<Fn(CT&)>::value, ""); + } + } + { + // INVOKE bullet 7 + { + // Function pointer + using Fp = void(*)(Tag&, int); + static_assert(std::is_callable<Fp(Tag&, int)>::value, ""); + static_assert(std::is_callable<Fp(DerFromTag&, int)>::value, ""); + static_assert(!std::is_callable<Fp(const Tag&, int)>::value, ""); + static_assert(!std::is_callable<Fp()>::value, ""); + static_assert(!std::is_callable<Fp(Tag&)>::value, ""); + } + { + // Function reference + using Fp = void(&)(Tag&, int); + static_assert(std::is_callable<Fp(Tag&, int)>::value, ""); + static_assert(std::is_callable<Fp(DerFromTag&, int)>::value, ""); + static_assert(!std::is_callable<Fp(const Tag&, int)>::value, ""); + static_assert(!std::is_callable<Fp()>::value, ""); + static_assert(!std::is_callable<Fp(Tag&)>::value, ""); + } + { + // Function object + using Fn = NotCallableWithInt; + static_assert(std::is_callable<Fn(Tag)>::value, ""); + static_assert(!std::is_callable<Fn(int)>::value, ""); + } + } + { + // Check that the conversion to the return type is properly checked + using Fn = int(*)(); + static_assert(std::is_callable<Fn(), Implicit>::value, ""); + static_assert(std::is_callable<Fn(), double>::value, ""); + static_assert(std::is_callable<Fn(), const volatile void>::value, ""); + static_assert(!std::is_callable<Fn(), Explicit>::value, ""); + } + { + // Check for is_callable_v + using Fn = void(*)(); + static_assert(std::is_callable_v<Fn()>, ""); + static_assert(!std::is_callable_v<Fn(int)>, ""); + } +} diff --git a/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp b/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp index 1681c39972d28..552c16075da7a 100644 --- a/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp +++ b/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp @@ -12,7 +12,6 @@ // is_convertible #include <type_traits> - #include "test_macros.h" template <class T, class U> @@ -46,12 +45,22 @@ void test_is_not_convertible() } typedef void Function(); +typedef void ConstFunction() const; typedef char Array[1]; +struct StringType { + StringType(const char*) {} +}; + class NonCopyable { NonCopyable(NonCopyable&); }; +template <typename T> +class CannotInstantiate { + enum { X = T::ThisExpressionWillBlowUp }; +}; + int main() { // void @@ -64,12 +73,19 @@ int main() test_is_not_convertible<void,char> (); test_is_not_convertible<void,char&> (); test_is_not_convertible<void,char*> (); + test_is_not_convertible<char, void>(); // Function test_is_not_convertible<Function, void> (); test_is_not_convertible<Function, Function> (); test_is_convertible<Function, Function&> (); test_is_convertible<Function, Function*> (); + test_is_convertible<Function, Function*const> (); + +#if TEST_STD_VER >= 11 + static_assert(( std::is_convertible<Function, Function&&>::value), ""); +#endif + test_is_not_convertible<Function, Array> (); test_is_not_convertible<Function, Array&> (); test_is_not_convertible<Function, char> (); @@ -100,6 +116,16 @@ int main() test_is_not_convertible<Function*, char&> (); test_is_not_convertible<Function*, char*> (); + // Non-referencable function type + static_assert((!std::is_convertible<ConstFunction, Function>::value), ""); + static_assert((!std::is_convertible<ConstFunction, Function*>::value), ""); + static_assert((!std::is_convertible<ConstFunction, Function&>::value), ""); + static_assert((!std::is_convertible<ConstFunction, Function>::value), ""); + static_assert((!std::is_convertible<Function*, ConstFunction>::value), ""); + static_assert((!std::is_convertible<Function&, ConstFunction>::value), ""); + static_assert((!std::is_convertible<ConstFunction, ConstFunction>::value), ""); + static_assert((!std::is_convertible<ConstFunction, void>::value), ""); + // Array test_is_not_convertible<Array, void> (); test_is_not_convertible<Array, Function> (); @@ -109,17 +135,37 @@ int main() static_assert((!std::is_convertible<Array, Array&>::value), ""); static_assert(( std::is_convertible<Array, const Array&>::value), ""); + static_assert((!std::is_convertible<Array, const volatile Array&>::value), ""); + static_assert((!std::is_convertible<const Array, Array&>::value), ""); static_assert(( std::is_convertible<const Array, const Array&>::value), ""); + static_assert((!std::is_convertible<Array, volatile Array&>::value), ""); + static_assert((!std::is_convertible<Array, const volatile Array&>::value), ""); + +#if TEST_STD_VER >= 11 + static_assert(( std::is_convertible<Array, Array&&>::value), ""); + static_assert(( std::is_convertible<Array, const Array&&>::value), ""); + static_assert(( std::is_convertible<Array, volatile Array&&>::value), ""); + static_assert(( std::is_convertible<Array, const volatile Array&&>::value), ""); + static_assert(( std::is_convertible<const Array, const Array&&>::value), ""); + static_assert((!std::is_convertible<Array&, Array&&>::value), ""); + static_assert((!std::is_convertible<Array&&, Array&>::value), ""); +#endif test_is_not_convertible<Array, char> (); test_is_not_convertible<Array, char&> (); static_assert(( std::is_convertible<Array, char*>::value), ""); static_assert(( std::is_convertible<Array, const char*>::value), ""); + static_assert(( std::is_convertible<Array, char* const>::value), ""); + static_assert(( std::is_convertible<Array, char* const volatile>::value), ""); + static_assert((!std::is_convertible<const Array, char*>::value), ""); static_assert(( std::is_convertible<const Array, const char*>::value), ""); + static_assert((!std::is_convertible<char[42][42], char*>::value), ""); + static_assert((!std::is_convertible<char[][1], char*>::value), ""); + // Array& test_is_not_convertible<Array&, void> (); test_is_not_convertible<Array&, Function> (); @@ -140,6 +186,9 @@ int main() static_assert((!std::is_convertible<const Array&, char*>::value), ""); static_assert(( std::is_convertible<const Array&, const char*>::value), ""); + static_assert((std::is_convertible<Array, StringType>::value), ""); + static_assert((std::is_convertible<char(&)[], StringType>::value), ""); + // char test_is_not_convertible<char, void> (); test_is_not_convertible<char, Function> (); @@ -149,7 +198,7 @@ int main() test_is_not_convertible<char, Array&> (); test_is_convertible<char, char> (); - + static_assert((!std::is_convertible<char, char&>::value), ""); static_assert(( std::is_convertible<char, const char&>::value), ""); static_assert((!std::is_convertible<const char, char&>::value), ""); @@ -166,7 +215,7 @@ int main() test_is_not_convertible<char&, Array&> (); test_is_convertible<char&, char> (); - + static_assert(( std::is_convertible<char&, char&>::value), ""); static_assert(( std::is_convertible<char&, const char&>::value), ""); static_assert((!std::is_convertible<const char&, char&>::value), ""); @@ -184,7 +233,7 @@ int main() test_is_not_convertible<char*, char> (); test_is_not_convertible<char*, char&> (); - + static_assert(( std::is_convertible<char*, char*>::value), ""); static_assert(( std::is_convertible<char*, const char*>::value), ""); static_assert((!std::is_convertible<const char*, char*>::value), ""); @@ -202,8 +251,11 @@ int main() static_assert((!std::is_convertible<const NonCopyable&, NonCopyable&>::value), ""); // This test requires Access control SFINAE which we only have in C++11 or when // we are using the compiler builtin for is_convertible. -#if __cplusplus >= 201103L || !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK) +#if TEST_STD_VER >= 11 || !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK) test_is_not_convertible<NonCopyable&, NonCopyable>(); #endif + // Ensure that CannotInstantiate is not instantiated by is_convertible when it is not needed. + // For example CannotInstantiate is instatiated as a part of ADL lookup for arguments of type CannotInstantiate*. + static_assert((std::is_convertible<CannotInstantiate<int>*, CannotInstantiate<int>*>::value), ""); } diff --git a/test/std/utilities/meta/meta.rel/is_nothrow_callable.pass.cpp b/test/std/utilities/meta/meta.rel/is_nothrow_callable.pass.cpp new file mode 100644 index 0000000000000..eefa6d1f22b18 --- /dev/null +++ b/test/std/utilities/meta/meta.rel/is_nothrow_callable.pass.cpp @@ -0,0 +1,115 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// type_traits + +// is_nothrow_callable + +#include <type_traits> +#include <functional> + +#include "test_macros.h" + +struct Tag {}; + +struct Implicit { + Implicit(int) noexcept {} +}; + +struct ThrowsImplicit { + ThrowsImplicit(int) {} +}; + +struct Explicit { + explicit Explicit(int) noexcept {} +}; + +template <bool IsNoexcept, class Ret, class ...Args> +struct CallObject { + Ret operator()(Args&&...) const noexcept(IsNoexcept); +}; + +template <class Fn> +constexpr bool throws_callable() { + return std::is_callable<Fn>::value && + !std::is_nothrow_callable<Fn>::value; +} + +template <class Fn, class Ret> +constexpr bool throws_callable() { + return std::is_callable<Fn, Ret>::value && + !std::is_nothrow_callable<Fn, Ret>::value; +} + +// FIXME(EricWF) Don't test the where noexcept is *not* part of the type system +// once implementations have caught up. +void test_noexcept_function_pointers() +{ + struct Dummy { void foo() noexcept {} static void bar() noexcept {} }; +#if !defined(__cpp_noexcept_function_type) + { + // Check that PMF's and function pointers *work*. is_nothrow_callable will always + // return false because 'noexcept' is not part of the function type. + static_assert(throws_callable<decltype(&Dummy::foo)(Dummy&)>(), ""); + static_assert(throws_callable<decltype(&Dummy::bar)()>(), ""); + } +#else + { + // Check that PMF's and function pointers actually work and that + // is_nothrow_callable returns true for noexcept PMF's and function + // pointers. + static_assert(std::is_nothrow_callable<decltype(&Dummy::foo)(Dummy&)>::value, ""); + static_assert(std::is_nothrow_callable<decltype(&Dummy::bar)()>::value, ""); + } +#endif +} + +int main() +{ + { + // Check that the conversion to the return type is properly checked + using Fn = CallObject<true, int>; + static_assert(std::is_nothrow_callable<Fn(), Implicit>::value, ""); + static_assert(std::is_nothrow_callable<Fn(), double>::value, ""); + static_assert(std::is_nothrow_callable<Fn(), const volatile void>::value, ""); + static_assert(throws_callable<Fn(), ThrowsImplicit>(), ""); + static_assert(!std::is_nothrow_callable<Fn(), Explicit>(), ""); + } + { + // Check that the conversion to the parameters is properly checked + using Fn = CallObject<true, void, const Implicit&, const ThrowsImplicit&>; + static_assert(std::is_nothrow_callable<Fn(Implicit&, ThrowsImplicit&)>::value, ""); + static_assert(std::is_nothrow_callable<Fn(int, ThrowsImplicit&)>::value, ""); + static_assert(throws_callable<Fn(int, int)>(), ""); + static_assert(!std::is_nothrow_callable<Fn()>::value, ""); + } + { + // Check that the noexcept-ness of function objects is checked. + using Fn = CallObject<true, void>; + using Fn2 = CallObject<false, void>; + static_assert(std::is_nothrow_callable<Fn()>::value, ""); + static_assert(throws_callable<Fn2()>(), ""); + } + { + // Check that PMD derefs are noexcept + using Fn = int (Tag::*); + static_assert(std::is_nothrow_callable<Fn(Tag&)>::value, ""); + static_assert(std::is_nothrow_callable<Fn(Tag&), Implicit>::value, ""); + static_assert(throws_callable<Fn(Tag&), ThrowsImplicit>(), ""); + } + { + // Check for is_nothrow_callable_v + using Fn = CallObject<true, int>; + static_assert(std::is_nothrow_callable_v<Fn()>, ""); + static_assert(!std::is_nothrow_callable_v<Fn(int)>, ""); + } + test_noexcept_function_pointers(); +} diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp index a53bed984c5e2..079661d0c1749 100644 --- a/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp +++ b/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp @@ -164,7 +164,7 @@ int main() // Use alignof(std::max_align_t) below to find the max alignment instead of // hardcoding it, because it's different on different platforms. // (For example 8 on arm and 16 on x86.) -#if __cplusplus < 201103L +#if TEST_STD_VER < 11 #define alignof __alignof__ #endif { diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/enable_if2.fail.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/enable_if2.fail.cpp index 8ce894578c4fd..8c9b42d60f30e 100644 --- a/test/std/utilities/meta/meta.trans/meta.trans.other/enable_if2.fail.cpp +++ b/test/std/utilities/meta/meta.trans/meta.trans.other/enable_if2.fail.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11 // type_traits // enable_if @@ -15,9 +16,5 @@ int main() { -#if _LIBCPP_STD_VER > 11 typedef std::enable_if_t<false> A; -#else - static_assert ( false, "" ); -#endif } 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 5a925bb34b260..fc01b22c36abe 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 @@ -13,6 +13,7 @@ #include <type_traits> #include <memory> +#include <cassert> #include "test_macros.h" struct S @@ -25,6 +26,11 @@ struct S double const volatile& operator()(char, int&) const volatile; }; + +struct SD : public S { }; + +struct NotDerived {}; + template <class Tp> struct Voider { typedef void type; @@ -39,6 +45,10 @@ struct HasType<T, typename Voider<typename T::type>::type> : std::true_type {}; template <class T, class U> void test_result_of() { +#if TEST_STD_VER > 14 + static_assert(std::is_callable<T>::value, ""); + static_assert(std::is_callable<T, U>::value, ""); +#endif static_assert((std::is_same<typename std::result_of<T>::type, U>::value), ""); } @@ -48,10 +58,14 @@ void test_no_result() #if TEST_STD_VER >= 11 static_assert((!HasType<std::result_of<T> >::value), ""); #endif +#if TEST_STD_VER > 14 + static_assert(std::is_callable<T>::value == false, ""); +#endif } int main() { + typedef NotDerived ND; { // functor object test_result_of<S(int), short> (); test_result_of<S&(unsigned char, int&), double> (); @@ -90,32 +104,64 @@ int main() typedef int (S::*PMS0)(); typedef int* (S::*PMS1)(long); typedef int& (S::*PMS2)(long, int); - test_result_of<PMS0( S), int> (); - test_result_of<PMS0( S&), int> (); - test_result_of<PMS0( S*), int> (); - test_result_of<PMS0( S*&), int> (); - test_result_of<PMS0(std::unique_ptr<S>), int> (); + test_result_of<PMS0( S), int> (); + test_result_of<PMS0( S&), int> (); + test_result_of<PMS0( S*), int> (); + test_result_of<PMS0( S*&), int> (); + test_result_of<PMS0( std::reference_wrapper<S>), int> (); + test_result_of<PMS0(const std::reference_wrapper<S>&), int> (); + test_result_of<PMS0( std::reference_wrapper<SD>), int> (); + test_result_of<PMS0(const std::reference_wrapper<SD>&), int> (); + test_result_of<PMS0(std::unique_ptr<S>), int> (); + test_result_of<PMS0(std::unique_ptr<SD>), int> (); test_no_result<PMS0(const S&)>(); test_no_result<PMS0(volatile S&)>(); test_no_result<PMS0(const volatile S&)>(); + test_no_result<PMS0(ND & )>(); + test_no_result<PMS0(const ND& )>(); + test_no_result<PMS0(std::unique_ptr<S const> )>(); + test_no_result<PMS0(std::reference_wrapper<S const>)>(); + test_no_result<PMS0(std::reference_wrapper<ND> )>(); + test_no_result<PMS0(std::unique_ptr<ND> )>(); - test_result_of<PMS1( S, int), int*> (); - test_result_of<PMS1( S&, int), int*> (); - test_result_of<PMS1( S*, int), int*> (); - test_result_of<PMS1( S*&, int), int*> (); - test_result_of<PMS1(std::unique_ptr<S>, int), int*> (); + test_result_of<PMS1( S, int), int*> (); + test_result_of<PMS1( S&, int), int*> (); + test_result_of<PMS1( S*, int), int*> (); + test_result_of<PMS1( S*&, int), int*> (); + test_result_of<PMS1(std::unique_ptr<S>, int), int*> (); + test_result_of<PMS1(std::unique_ptr<SD>, int), int*> (); + test_result_of<PMS1(std::reference_wrapper<S>, int), int*> (); + test_result_of<PMS1(const std::reference_wrapper<S>&, int), int*> (); + test_result_of<PMS1(std::reference_wrapper<SD>, int), int*> (); + test_result_of<PMS1(const std::reference_wrapper<SD>&, int), int*> (); test_no_result<PMS1(const S&, int)>(); test_no_result<PMS1(volatile S&, int)>(); test_no_result<PMS1(const volatile S&, int)>(); + test_no_result<PMS1(ND &, int)>(); + test_no_result<PMS1(const ND&, int)>(); + test_no_result<PMS1(std::unique_ptr<S const>, int)>(); + test_no_result<PMS1(std::reference_wrapper<S const>, int)>(); + test_no_result<PMS1(std::reference_wrapper<ND>, int)>(); + test_no_result<PMS1(std::unique_ptr<ND>, int)>(); test_result_of<PMS2( S, int, int), int&> (); test_result_of<PMS2( S&, int, int), int&> (); test_result_of<PMS2( S*, int, int), int&> (); test_result_of<PMS2( S*&, int, int), int&> (); test_result_of<PMS2(std::unique_ptr<S>, int, int), int&> (); + test_result_of<PMS2(std::unique_ptr<SD>, int, int), int&> (); + test_result_of<PMS2(std::reference_wrapper<S>, int, int), int&> (); + test_result_of<PMS2(const std::reference_wrapper<S>&, int, int), int&> (); + test_result_of<PMS2(std::reference_wrapper<SD>, int, int), int&> (); + test_result_of<PMS2(const std::reference_wrapper<SD>&, int, int), int&> (); test_no_result<PMS2(const S&, int, int)>(); test_no_result<PMS2(volatile S&, int, int)>(); test_no_result<PMS2(const volatile S&, int, int)>(); + test_no_result<PMS2(std::unique_ptr<S const>, int, int)>(); + test_no_result<PMS2(std::reference_wrapper<S const>, int, int)>(); + test_no_result<PMS2(const ND&, int, int)>(); + test_no_result<PMS2(std::reference_wrapper<ND>, int, int)>(); + test_no_result<PMS2(std::unique_ptr<ND>, int, int)>(); typedef int (S::*PMS0C)() const; typedef int* (S::*PMS1C)(long) const; @@ -128,6 +174,15 @@ int main() test_result_of<PMS0C( S*&), int> (); test_result_of<PMS0C(const S*&), int> (); test_result_of<PMS0C(std::unique_ptr<S>), int> (); + test_result_of<PMS0C(std::unique_ptr<SD>), int> (); + test_result_of<PMS0C(std::reference_wrapper<S> ), int> (); + test_result_of<PMS0C(std::reference_wrapper<const S> ), int> (); + test_result_of<PMS0C(const std::reference_wrapper<S> & ), int> (); + test_result_of<PMS0C(const std::reference_wrapper<const S> &), int> (); + test_result_of<PMS0C(std::reference_wrapper<SD> ), int> (); + test_result_of<PMS0C(std::reference_wrapper<const SD> ), int> (); + test_result_of<PMS0C(const std::reference_wrapper<SD> & ), int> (); + test_result_of<PMS0C(const std::reference_wrapper<const SD> &), int> (); test_no_result<PMS0C(volatile S&)>(); test_no_result<PMS0C(const volatile S&)>(); @@ -248,5 +303,16 @@ int main() test_result_of<PMD(volatile S*), volatile char&> (); test_result_of<PMD(const volatile S&), const volatile char&> (); test_result_of<PMD(const volatile S*), const volatile char&> (); + test_result_of<PMD(SD&), char &>(); + test_result_of<PMD(SD const&), const char&>(); + test_result_of<PMD(SD*), char&>(); + test_result_of<PMD(const SD*), const char&>(); + test_result_of<PMD(std::unique_ptr<S>), char &>(); + test_result_of<PMD(std::unique_ptr<S const>), const char&>(); +#if TEST_STD_VER >= 11 + test_result_of<PMD(std::reference_wrapper<S>), char&>(); + test_result_of<PMD(std::reference_wrapper<S const>), const char&>(); +#endif + test_no_result<PMD(ND&)>(); } } 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 6996cddc08b90..8cb5853bbc6d7 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 @@ -14,6 +14,8 @@ // result_of<Fn(ArgTypes...)> #include <type_traits> +#include <memory> +#include <utility> #include "test_macros.h" struct wat @@ -23,6 +25,8 @@ struct wat }; struct F {}; +struct FD : public F {}; +struct NotDerived {}; template <class T, class U> void test_result_of_imp() @@ -31,10 +35,15 @@ void test_result_of_imp() #if TEST_STD_VER > 11 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, ""); +#endif } int main() { + typedef NotDerived ND; { typedef char F::*PMD; test_result_of_imp<PMD(F &), char &>(); @@ -51,6 +60,31 @@ int main() test_result_of_imp<PMD(F const ), char &&>(); test_result_of_imp<PMD(F volatile ), char &&>(); test_result_of_imp<PMD(F const volatile ), char &&>(); + + test_result_of_imp<PMD(FD &), char &>(); + test_result_of_imp<PMD(FD const &), char const &>(); + test_result_of_imp<PMD(FD volatile &), char volatile &>(); + test_result_of_imp<PMD(FD const volatile &), char const volatile &>(); + + test_result_of_imp<PMD(FD &&), char &&>(); + test_result_of_imp<PMD(FD const &&), char const &&>(); + test_result_of_imp<PMD(FD volatile &&), char volatile &&>(); + test_result_of_imp<PMD(FD const volatile &&), char const volatile &&>(); + + test_result_of_imp<PMD(FD ), char &&>(); + test_result_of_imp<PMD(FD const ), char &&>(); + test_result_of_imp<PMD(FD volatile ), char &&>(); + test_result_of_imp<PMD(FD const volatile ), char &&>(); + + test_result_of_imp<PMD(std::unique_ptr<F>), char &>(); + test_result_of_imp<PMD(std::unique_ptr<F const>), const char &>(); + test_result_of_imp<PMD(std::unique_ptr<FD>), char &>(); + test_result_of_imp<PMD(std::unique_ptr<FD const>), const char &>(); + + test_result_of_imp<PMD(std::reference_wrapper<F>), char &>(); + test_result_of_imp<PMD(std::reference_wrapper<F const>), const char &>(); + test_result_of_imp<PMD(std::reference_wrapper<FD>), char &>(); + test_result_of_imp<PMD(std::reference_wrapper<FD const>), const char &>(); } { test_result_of_imp<int (F::* (F &)) () &, int> (); @@ -83,6 +117,42 @@ int main() test_result_of_imp<int (F::* (F volatile )) () const volatile &&, int> (); test_result_of_imp<int (F::* (F const volatile )) () const volatile &&, int> (); } + { + test_result_of_imp<int (F::* (FD &)) () &, int> (); + test_result_of_imp<int (F::* (FD &)) () const &, int> (); + test_result_of_imp<int (F::* (FD &)) () volatile &, int> (); + test_result_of_imp<int (F::* (FD &)) () const volatile &, int> (); + test_result_of_imp<int (F::* (FD const &)) () const &, int> (); + test_result_of_imp<int (F::* (FD const &)) () const volatile &, int> (); + test_result_of_imp<int (F::* (FD volatile &)) () volatile &, int> (); + test_result_of_imp<int (F::* (FD volatile &)) () const volatile &, int> (); + test_result_of_imp<int (F::* (FD const volatile &)) () const volatile &, int> (); + + test_result_of_imp<int (F::* (FD &&)) () &&, int> (); + test_result_of_imp<int (F::* (FD &&)) () const &&, int> (); + test_result_of_imp<int (F::* (FD &&)) () volatile &&, int> (); + test_result_of_imp<int (F::* (FD &&)) () const volatile &&, int> (); + test_result_of_imp<int (F::* (FD const &&)) () const &&, int> (); + test_result_of_imp<int (F::* (FD const &&)) () const volatile &&, int> (); + test_result_of_imp<int (F::* (FD volatile &&)) () volatile &&, int> (); + test_result_of_imp<int (F::* (FD volatile &&)) () const volatile &&, int> (); + test_result_of_imp<int (F::* (FD const volatile &&)) () const volatile &&, int> (); + test_result_of_imp<int (F::* (FD )) () &&, int> (); + test_result_of_imp<int (F::* (FD )) () const &&, int> (); + test_result_of_imp<int (F::* (FD )) () volatile &&, int> (); + test_result_of_imp<int (F::* (FD )) () const volatile &&, int> (); + test_result_of_imp<int (F::* (FD const )) () const &&, int> (); + test_result_of_imp<int (F::* (FD const )) () const volatile &&, int> (); + test_result_of_imp<int (F::* (FD volatile )) () volatile &&, int> (); + test_result_of_imp<int (F::* (FD volatile )) () const volatile &&, int> (); + test_result_of_imp<int (F::* (FD const volatile )) () const volatile &&, int> (); + } + { + test_result_of_imp<int (F::* (std::reference_wrapper<F>)) (), int>(); + test_result_of_imp<int (F::* (std::reference_wrapper<const F>)) () const, int>(); + test_result_of_imp<int (F::* (std::unique_ptr<F> )) (), int>(); + test_result_of_imp<int (F::* (std::unique_ptr<const F> )) () const, int>(); + } test_result_of_imp<decltype(&wat::foo)(wat), void>(); } diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp index 728062b70684a..1d7b23c192225 100644 --- a/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp +++ b/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp @@ -14,6 +14,8 @@ #include <type_traits> #include <climits> +#include "test_macros.h" + enum E { V = INT_MIN }; enum F { W = UINT_MAX }; @@ -29,7 +31,7 @@ int main() static_assert((std::is_same<std::underlying_type_t<F>, unsigned>::value), ""); #endif -#if __has_feature(cxx_strong_enums) +#if TEST_STD_VER >= 11 enum G : char { }; static_assert((std::is_same<std::underlying_type<G>::type, char>::value), @@ -37,5 +39,5 @@ int main() #if _LIBCPP_STD_VER > 11 static_assert((std::is_same<std::underlying_type_t<G>, char>::value), ""); #endif -#endif // __has_feature(cxx_strong_enums) +#endif // TEST_STD_VER >= 11 } diff --git a/test/std/utilities/meta/meta.trans/meta.trans.ptr/add_pointer.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.ptr/add_pointer.pass.cpp index 76d0f12d03fb5..51b3e5d736882 100644 --- a/test/std/utilities/meta/meta.trans/meta.trans.ptr/add_pointer.pass.cpp +++ b/test/std/utilities/meta/meta.trans/meta.trans.ptr/add_pointer.pass.cpp @@ -10,18 +10,42 @@ // type_traits // add_pointer +// If T names a referenceable type or a (possibly cv-qualified) void type then +// the member typedef type shall name the same type as remove_reference_t<T>*; +// otherwise, type shall name T. #include <type_traits> +#include "test_macros.h" template <class T, class U> void test_add_pointer() { static_assert((std::is_same<typename std::add_pointer<T>::type, U>::value), ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert((std::is_same<std::add_pointer_t<T>, U>::value), ""); #endif } +template <class F> +void test_function0() +{ + static_assert((std::is_same<typename std::add_pointer<F>::type, F*>::value), ""); +#if TEST_STD_VER > 11 + static_assert((std::is_same<std::add_pointer_t<F>, F*>::value), ""); +#endif +} + +template <class F> +void test_function1() +{ + static_assert((std::is_same<typename std::add_pointer<F>::type, F>::value), ""); +#if TEST_STD_VER > 11 + static_assert((std::is_same<std::add_pointer_t<F>, F>::value), ""); +#endif +} + +struct Foo {}; + int main() { test_add_pointer<void, void*>(); @@ -31,4 +55,26 @@ int main() test_add_pointer<const int&, const int*>(); test_add_pointer<int*, int**>(); test_add_pointer<const int*, const int**>(); + test_add_pointer<Foo, Foo*>(); + +// LWG 2101 specifically talks about add_pointer and functions. +// The term of art is "a referenceable type", which a cv- or ref-qualified function is not. + test_function0<void()>(); +#if TEST_STD_VER >= 11 + test_function1<void() const>(); + test_function1<void() &>(); + test_function1<void() &&>(); + test_function1<void() const &>(); + test_function1<void() const &&>(); +#endif + +// But a cv- or ref-qualified member function *is* "a referenceable type" + test_function0<void (Foo::*)()>(); +#if TEST_STD_VER >= 11 + test_function0<void (Foo::*)() const>(); + test_function0<void (Foo::*)() &>(); + test_function0<void (Foo::*)() &&>(); + test_function0<void (Foo::*)() const &>(); + test_function0<void (Foo::*)() const &&>(); +#endif } diff --git a/test/std/utilities/meta/meta.trans/meta.trans.ptr/remove_pointer.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.ptr/remove_pointer.pass.cpp index 9cecd39049fc4..cccbb6011edf1 100644 --- a/test/std/utilities/meta/meta.trans/meta.trans.ptr/remove_pointer.pass.cpp +++ b/test/std/utilities/meta/meta.trans/meta.trans.ptr/remove_pointer.pass.cpp @@ -12,12 +12,13 @@ // remove_pointer #include <type_traits> +#include "test_macros.h" template <class T, class U> void test_remove_pointer() { static_assert((std::is_same<typename std::remove_pointer<T>::type, U>::value), ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert((std::is_same<std::remove_pointer_t<T>, U>::value), ""); #endif } diff --git a/test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp index fb53312cbe677..c82c282995355 100644 --- a/test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp +++ b/test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp @@ -10,14 +10,17 @@ // type_traits // add_lvalue_reference +// If T names a referenceable type then the member typedef type +// shall name T&; otherwise, type shall name T. #include <type_traits> +#include "test_macros.h" template <class T, class U> void test_add_lvalue_reference() { static_assert((std::is_same<typename std::add_lvalue_reference<T>::type, U>::value), ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert((std::is_same<std::add_lvalue_reference_t<T>, U>::value), ""); #endif } @@ -26,7 +29,7 @@ template <class F> void test_function0() { static_assert((std::is_same<typename std::add_lvalue_reference<F>::type, F&>::value), ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert((std::is_same<std::add_lvalue_reference_t<F>, F&>::value), ""); #endif } @@ -35,7 +38,7 @@ template <class F> void test_function1() { static_assert((std::is_same<typename std::add_lvalue_reference<F>::type, F>::value), ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert((std::is_same<std::add_lvalue_reference_t<F>, F>::value), ""); #endif } @@ -51,20 +54,26 @@ int main() test_add_lvalue_reference<const int&, const int&>(); test_add_lvalue_reference<int*, int*&>(); test_add_lvalue_reference<const int*, const int*&>(); + test_add_lvalue_reference<Foo, Foo&>(); // LWG 2101 specifically talks about add_lvalue_reference and functions. // The term of art is "a referenceable type", which a cv- or ref-qualified function is not. test_function0<void()>(); -// test_function1<void() const>(); -// test_function1<void() &>(); -// test_function1<void() &&>(); -// test_function1<void() const &>(); -// test_function1<void() const &&>(); +#if TEST_STD_VER >= 11 + test_function1<void() const>(); + test_function1<void() &>(); + test_function1<void() &&>(); + test_function1<void() const &>(); + test_function1<void() const &&>(); +#endif +// But a cv- or ref-qualified member function *is* "a referenceable type" test_function0<void (Foo::*)()>(); +#if TEST_STD_VER >= 11 test_function0<void (Foo::*)() const>(); test_function0<void (Foo::*)() &>(); test_function0<void (Foo::*)() &&>(); test_function0<void (Foo::*)() const &>(); test_function0<void (Foo::*)() const &&>(); +#endif } diff --git a/test/std/utilities/meta/meta.trans/meta.trans.ref/add_rvalue_ref.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.ref/add_rvalue_ref.pass.cpp index e8f08fdc398ad..fc147c37b1acc 100644 --- a/test/std/utilities/meta/meta.trans/meta.trans.ref/add_rvalue_ref.pass.cpp +++ b/test/std/utilities/meta/meta.trans/meta.trans.ref/add_rvalue_ref.pass.cpp @@ -10,8 +10,11 @@ // type_traits // add_rvalue_reference +// If T names a referenceable type then the member typedef type +// shall name T&&; otherwise, type shall name T. #include <type_traits> +#include "test_macros.h" #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -19,13 +22,32 @@ template <class T, class U> void test_add_rvalue_reference() { static_assert((std::is_same<typename std::add_rvalue_reference<T>::type, U>::value), ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert((std::is_same<std::add_rvalue_reference_t<T>, U>::value), ""); #endif } +template <class F> +void test_function0() +{ + static_assert((std::is_same<typename std::add_rvalue_reference<F>::type, F&&>::value), ""); +#if TEST_STD_VER > 11 + static_assert((std::is_same<std::add_rvalue_reference_t<F>, F&&>::value), ""); +#endif +} + +template <class F> +void test_function1() +{ + static_assert((std::is_same<typename std::add_rvalue_reference<F>::type, F>::value), ""); +#if TEST_STD_VER > 11 + static_assert((std::is_same<std::add_rvalue_reference_t<F>, F>::value), ""); +#endif +} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +struct Foo {}; + int main() { #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -36,5 +58,27 @@ int main() test_add_rvalue_reference<const int&, const int&>(); test_add_rvalue_reference<int*, int*&&>(); test_add_rvalue_reference<const int*, const int*&&>(); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + test_add_rvalue_reference<Foo, Foo&&>(); + +// LWG 2101 specifically talks about add_rvalue_reference and functions. +// The term of art is "a referenceable type", which a cv- or ref-qualified function is not. + test_function0<void()>(); +#if TEST_STD_VER >= 11 + test_function1<void() const>(); + test_function1<void() &>(); + test_function1<void() &&>(); + test_function1<void() const &>(); + test_function1<void() const &&>(); +#endif + +// But a cv- or ref-qualified member function *is* "a referenceable type" + test_function0<void (Foo::*)()>(); +#if TEST_STD_VER >= 11 + test_function0<void (Foo::*)() const>(); + test_function0<void (Foo::*)() &>(); + test_function0<void (Foo::*)() &&>(); + test_function0<void (Foo::*)() const &>(); + test_function0<void (Foo::*)() const &&>(); +#endif +#endif } diff --git a/test/std/utilities/meta/meta.trans/meta.trans.ref/remove_ref.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.ref/remove_ref.pass.cpp index f9ebc37a5dd28..e335bd19ef2d3 100644 --- a/test/std/utilities/meta/meta.trans/meta.trans.ref/remove_ref.pass.cpp +++ b/test/std/utilities/meta/meta.trans/meta.trans.ref/remove_ref.pass.cpp @@ -12,12 +12,13 @@ // remove_reference #include <type_traits> +#include "test_macros.h" template <class T, class U> void test_remove_reference() { static_assert((std::is_same<typename std::remove_reference<T>::type, U>::value), ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert((std::is_same<std::remove_reference_t<T>, U>::value), ""); #endif } diff --git a/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp b/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp index ccec65fec3992..05ef99d0ebf4d 100644 --- a/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp +++ b/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp @@ -57,7 +57,7 @@ int main() test1<Class>(); test1<Class[]>(); test1<Class[5]>(); - + test2<void, int>(); test2<double, int>(); test2<int&, int>(); diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp index f4dd356383af1..ef1fc4040dc75 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp @@ -12,12 +12,13 @@ // array #include <type_traits> +#include "test_macros.h" template <class T> void test_array_imp() { static_assert(!std::is_void<T>::value, ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(!std::is_null_pointer<T>::value, ""); #endif static_assert(!std::is_integral<T>::value, ""); @@ -46,10 +47,15 @@ void test_array() typedef char array[3]; typedef const char const_array[3]; typedef char incomplete_array[]; +struct Incomplete; int main() { test_array<array>(); test_array<const_array>(); test_array<incomplete_array>(); + test_array<Incomplete[]>(); + +// LWG#2582 + static_assert(!std::is_array<Incomplete>::value, ""); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp index ac5d6e5923117..8c8510882bf6d 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp @@ -12,12 +12,13 @@ // class #include <type_traits> +#include "test_macros.h" template <class T> void test_class_imp() { static_assert(!std::is_void<T>::value, ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(!std::is_null_pointer<T>::value, ""); #endif static_assert(!std::is_integral<T>::value, ""); @@ -47,7 +48,13 @@ class Class { }; +struct incomplete_type; + int main() { test_class<Class>(); + test_class<incomplete_type>(); + +// LWG#2582 + static_assert( std::is_class<incomplete_type>::value, ""); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp index 7c9c78fcf2b9d..40dea443cd41f 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp @@ -12,12 +12,13 @@ // enum #include <type_traits> +#include "test_macros.h" template <class T> void test_enum_imp() { static_assert(!std::is_void<T>::value, ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(!std::is_null_pointer<T>::value, ""); #endif static_assert(!std::is_integral<T>::value, ""); @@ -44,8 +45,12 @@ void test_enum() } enum Enum {zero, one}; +struct incomplete_type; int main() { test_enum<Enum>(); + +// LWG#2582 + static_assert(!std::is_enum<incomplete_type>::value, ""); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp index 286644960315f..217bc7e25659d 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp @@ -12,12 +12,13 @@ // floating_point #include <type_traits> +#include "test_macros.h" template <class T> void test_floating_point_imp() { static_assert(!std::is_void<T>::value, ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(!std::is_null_pointer<T>::value, ""); #endif static_assert(!std::is_integral<T>::value, ""); @@ -43,9 +44,14 @@ void test_floating_point() test_floating_point_imp<const volatile T>(); } +struct incomplete_type; + int main() { test_floating_point<float>(); test_floating_point<double>(); test_floating_point<long double>(); + +// LWG#2582 + static_assert(!std::is_floating_point<incomplete_type>::value, ""); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp index b1df4f2d3f4cc..3f21b9a7dbcfe 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp @@ -12,13 +12,14 @@ // function #include <type_traits> +#include "test_macros.h" using namespace std; class Class {}; enum Enum1 {}; -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 enum class Enum2 : int {}; #else enum Enum2 {}; @@ -28,7 +29,7 @@ template <class T> void test() { static_assert(!std::is_void<T>::value, ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(!std::is_null_pointer<T>::value, ""); #endif static_assert(!std::is_integral<T>::value, ""); @@ -64,6 +65,7 @@ void test() test<__VA_ARGS__ volatile &&>(); \ test<__VA_ARGS__ const volatile &&>() +struct incomplete_type; int main() { @@ -75,7 +77,7 @@ int main() TEST_REGULAR( void (int, ...) ); TEST_REGULAR( int (double, ...) ); TEST_REGULAR( int (double, char, ...) ); -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 TEST_REF_QUALIFIED( void () ); TEST_REF_QUALIFIED( void (int) ); TEST_REF_QUALIFIED( int (double) ); @@ -85,4 +87,7 @@ int main() TEST_REF_QUALIFIED( int (double, ...) ); TEST_REF_QUALIFIED( int (double, char, ...) ); #endif + +// LWG#2582 + static_assert(!std::is_function<incomplete_type>::value, ""); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp index f68ed3ef7e57e..a50beeb3e3106 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp @@ -12,12 +12,13 @@ // integral #include <type_traits> +#include "test_macros.h" template <class T> void test_integral_imp() { static_assert(!std::is_void<T>::value, ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(!std::is_null_pointer<T>::value, ""); #endif static_assert( std::is_integral<T>::value, ""); @@ -43,6 +44,8 @@ void test_integral() test_integral_imp<const volatile T>(); } +struct incomplete_type; + int main() { test_integral<bool>(); @@ -62,4 +65,7 @@ int main() test_integral<__int128_t>(); test_integral<__uint128_t>(); #endif + +// LWG#2582 + static_assert(!std::is_integral<incomplete_type>::value, ""); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_array.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_array.pass.cpp index 72955defa3990..dfd09ac52bfa4 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_array.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_array.pass.cpp @@ -12,7 +12,7 @@ // is_array #include <type_traits> -#include <cstddef> // for std::nullptr_t +#include <cstddef> // for std::nullptr_t #include "test_macros.h" template <class T> @@ -67,6 +67,7 @@ class Abstract }; enum Enum {zero, one}; +struct incomplete_type; typedef void (*FunctionPtr)(); @@ -89,5 +90,5 @@ int main() test_is_not_array<Empty>(); test_is_not_array<bit_zero>(); test_is_not_array<NotEmpty>(); - test_is_not_array<Abstract>(); + test_is_not_array<incomplete_type>(); // LWG#2582 } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_class.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_class.pass.cpp index 97671e7b62e00..3c1a2181d2614 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_class.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_class.pass.cpp @@ -67,6 +67,7 @@ class Abstract }; enum Enum {zero, one}; +struct incomplete_type; typedef void (*FunctionPtr)(); @@ -76,6 +77,7 @@ int main() test_is_class<bit_zero>(); test_is_class<NotEmpty>(); test_is_class<Abstract>(); + test_is_class<incomplete_type>(); #if TEST_STD_VER >= 11 // In C++03 we have an emulation of std::nullptr_t diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_enum.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_enum.pass.cpp index 481260ea6e524..2603bdff26d2d 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_enum.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_enum.pass.cpp @@ -67,6 +67,7 @@ class Abstract }; enum Enum {zero, one}; +struct incomplete_type; typedef void (*FunctionPtr)(); @@ -90,4 +91,5 @@ int main() test_is_not_enum<NotEmpty>(); test_is_not_enum<Abstract>(); test_is_not_enum<FunctionPtr>(); + test_is_not_enum<incomplete_type>(); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_floating_point.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_floating_point.pass.cpp index de9c146bcb4e2..7e19c0629672c 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_floating_point.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_floating_point.pass.cpp @@ -67,6 +67,7 @@ class Abstract }; enum Enum {zero, one}; +struct incomplete_type; typedef void (*FunctionPtr)(); @@ -98,4 +99,5 @@ int main() test_is_not_floating_point<Abstract>(); test_is_not_floating_point<Enum>(); test_is_not_floating_point<FunctionPtr>(); + test_is_not_floating_point<incomplete_type>(); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp index 9a1d821b0746c..32e4f06beb04e 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp @@ -67,6 +67,7 @@ class Abstract }; enum Enum {zero, one}; +struct incomplete_type; typedef void (*FunctionPtr)(); @@ -77,7 +78,7 @@ int main() test_is_function<int(int, double)>(); test_is_function<int(Abstract *)>(); test_is_function<void(...)>(); - + test_is_not_function<std::nullptr_t>(); test_is_not_function<void>(); test_is_not_function<int>(); @@ -95,4 +96,5 @@ int main() test_is_not_function<NotEmpty>(); test_is_not_function<Abstract>(); test_is_not_function<Abstract*>(); + test_is_not_function<incomplete_type>(); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_integral.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_integral.pass.cpp index 86b63c53da54d..09997626ea06d 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_integral.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_integral.pass.cpp @@ -67,6 +67,7 @@ class Abstract }; enum Enum {zero, one}; +struct incomplete_type; typedef void (*FunctionPtr)(); @@ -101,4 +102,5 @@ int main() test_is_not_integral<bit_zero>(); test_is_not_integral<NotEmpty>(); test_is_not_integral<Abstract>(); + test_is_not_integral<incomplete_type>(); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_lvalue_reference.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_lvalue_reference.pass.cpp index 0e59f7153f506..41b8d44b93158 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_lvalue_reference.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_lvalue_reference.pass.cpp @@ -69,6 +69,7 @@ class Abstract }; enum Enum {zero, one}; +struct incomplete_type; typedef void (*FunctionPtr)(); @@ -92,4 +93,5 @@ int main() test_is_not_lvalue_reference<bit_zero>(); test_is_not_lvalue_reference<NotEmpty>(); test_is_not_lvalue_reference<Abstract>(); + test_is_not_lvalue_reference<incomplete_type>(); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_object_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_object_pointer.pass.cpp index 8da411d2eeed6..9498edc652abf 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_object_pointer.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_object_pointer.pass.cpp @@ -67,6 +67,7 @@ class Abstract }; enum Enum {zero, one}; +struct incomplete_type; typedef void (*FunctionPtr)(); @@ -94,4 +95,5 @@ int main() test_is_not_member_object_pointer<bit_zero>(); test_is_not_member_object_pointer<NotEmpty>(); test_is_not_member_object_pointer<Abstract>(); + test_is_not_member_object_pointer<incomplete_type>(); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp index 19a74b01d0fdc..d4043f48f98ed 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp @@ -67,6 +67,7 @@ class Abstract }; enum Enum {zero, one}; +struct incomplete_type; typedef void (*FunctionPtr)(); @@ -95,4 +96,5 @@ int main() test_is_not_member_pointer<bit_zero>(); test_is_not_member_pointer<NotEmpty>(); test_is_not_member_pointer<Abstract>(); + test_is_not_member_pointer<incomplete_type>(); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_null_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_null_pointer.pass.cpp index 80f563e8969e3..f575763300a70 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_null_pointer.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_null_pointer.pass.cpp @@ -69,6 +69,7 @@ class Abstract }; enum Enum {zero, one}; +struct incomplete_type; typedef void (*FunctionPtr)(); @@ -92,4 +93,5 @@ int main() test_is_not_null_pointer<bit_zero>(); test_is_not_null_pointer<NotEmpty>(); test_is_not_null_pointer<Abstract>(); + test_is_not_null_pointer<incomplete_type>(); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_pointer.pass.cpp index a901aed1143e2..257719eb940ee 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_pointer.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_pointer.pass.cpp @@ -67,6 +67,7 @@ class Abstract }; enum Enum {zero, one}; +struct incomplete_type; typedef void (*FunctionPtr)(); @@ -91,4 +92,5 @@ int main() test_is_not_pointer<bit_zero>(); test_is_not_pointer<NotEmpty>(); test_is_not_pointer<Abstract>(); + test_is_not_pointer<incomplete_type>(); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_rvalue_reference.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_rvalue_reference.pass.cpp index b7b52687018a0..89639377ce81a 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_rvalue_reference.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_rvalue_reference.pass.cpp @@ -69,6 +69,7 @@ class Abstract }; enum Enum {zero, one}; +struct incomplete_type; typedef void (*FunctionPtr)(); @@ -92,4 +93,5 @@ int main() test_is_not_rvalue_reference<bit_zero>(); test_is_not_rvalue_reference<NotEmpty>(); test_is_not_rvalue_reference<Abstract>(); + test_is_not_rvalue_reference<incomplete_type>(); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_union.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_union.pass.cpp index 307fedb32b269..415d9a7813dd2 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_union.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_union.pass.cpp @@ -67,6 +67,7 @@ class Abstract }; enum Enum {zero, one}; +struct incomplete_type; typedef void (*FunctionPtr)(); @@ -90,4 +91,5 @@ int main() test_is_not_union<bit_zero>(); test_is_not_union<NotEmpty>(); test_is_not_union<Abstract>(); + test_is_not_union<incomplete_type>(); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_void.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_void.pass.cpp index 1647666adf2e2..952a5b748f532 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_void.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_void.pass.cpp @@ -67,6 +67,7 @@ class Abstract }; enum Enum {zero, one}; +struct incomplete_type; typedef void (*FunctionPtr)(); @@ -89,4 +90,5 @@ int main() test_is_not_void<Abstract>(); test_is_not_void<Enum>(); test_is_not_void<FunctionPtr>(); + test_is_not_void<incomplete_type>(); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp index 3b6ccade7e742..13cad58c0ef3f 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp @@ -34,8 +34,13 @@ void test_lvalue_ref() static_assert(!std::is_function<T>::value, ""); } +struct incomplete_type; + int main() { test_lvalue_ref<int&>(); test_lvalue_ref<const int&>(); + +// LWG#2582 + static_assert(!std::is_lvalue_reference<incomplete_type>::value, ""); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp index 6f546efdf51e1..a895a8d447b66 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp @@ -48,6 +48,8 @@ class Class { }; +struct incomplete_type; + int main() { test_member_function_pointer<void (Class::*)()>(); @@ -133,4 +135,7 @@ int main() test_member_function_pointer<void (Class::*)(int,...) const volatile &&>(); test_member_function_pointer<void (Class::*)(int, char,...) const volatile &&>(); #endif + +// LWG#2582 + static_assert(!std::is_member_function_pointer<incomplete_type>::value, ""); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer_no_variadics.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer_no_variadics.pass.cpp index e13e58632a325..b0edea37e8e89 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer_no_variadics.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer_no_variadics.pass.cpp @@ -48,6 +48,8 @@ class Class { }; +struct incomplete_type; + int main() { test_member_function_pointer<void (Class::*)()>(); @@ -73,4 +75,7 @@ int main() test_member_function_pointer<void (Class::*)(...) volatile>(); test_member_function_pointer<void (Class::*)(int, ...) volatile>(); test_member_function_pointer<void (Class::*)(int, char, ...) volatile>(); + +// LWG#2582 + static_assert(!std::is_member_function_pointer<incomplete_type>::value, ""); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp index 4e6699cc3e7c0..76deef4291e71 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp @@ -12,12 +12,13 @@ // member_object_pointer #include <type_traits> +#include "test_macros.h" template <class T> void test_member_object_pointer_imp() { static_assert(!std::is_void<T>::value, ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(!std::is_null_pointer<T>::value, ""); #endif static_assert(!std::is_integral<T>::value, ""); @@ -47,7 +48,12 @@ class Class { }; +struct incomplete_type; + int main() { test_member_object_pointer<int Class::*>(); + +// LWG#2582 + static_assert(!std::is_member_object_pointer<incomplete_type>::value, ""); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp index 1c7a32fc9dc97..076204c9c094e 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp @@ -14,8 +14,9 @@ #include <type_traits> #include <cstddef> // for std::nullptr_t +#include "test_macros.h" -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 template <class T> void test_nullptr_imp() { @@ -44,9 +45,14 @@ void test_nullptr() test_nullptr_imp<const volatile T>(); } +struct incomplete_type; + int main() { test_nullptr<std::nullptr_t>(); + +// LWG#2582 + static_assert(!std::is_null_pointer<incomplete_type>::value, ""); } #else int main() {} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp index 7073c106b44b7..f9c83c67d2195 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp @@ -12,12 +12,14 @@ // pointer #include <type_traits> +#include "test_macros.h" + template <class T> void test_pointer_imp() { static_assert(!std::is_void<T>::value, ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(!std::is_null_pointer<T>::value, ""); #endif static_assert(!std::is_integral<T>::value, ""); @@ -43,10 +45,15 @@ void test_pointer() test_pointer_imp<const volatile T>(); } +struct incomplete_type; + int main() { test_pointer<void*>(); test_pointer<int*>(); test_pointer<const int*>(); test_pointer<void (*)(int)>(); + +// LWG#2582 + static_assert(!std::is_pointer<incomplete_type>::value, ""); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp index 7964424036348..99fd2887981f9 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp @@ -12,12 +12,13 @@ // rvalue_ref #include <type_traits> +#include "test_macros.h" template <class T> void test_rvalue_ref() { static_assert(!std::is_void<T>::value, ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(!std::is_null_pointer<T>::value, ""); #endif static_assert(!std::is_integral<T>::value, ""); @@ -34,10 +35,15 @@ void test_rvalue_ref() static_assert(!std::is_function<T>::value, ""); } +struct incomplete_type; + int main() { #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES test_rvalue_ref<int&&>(); test_rvalue_ref<const int&&>(); + +// LWG#2582 + static_assert(!std::is_rvalue_reference<incomplete_type>::value, ""); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp index 6cabb717c0c68..36ad00400d359 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp @@ -12,12 +12,13 @@ // union #include <type_traits> +#include "test_macros.h" template <class T> void test_union_imp() { static_assert(!std::is_void<T>::value, ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(!std::is_null_pointer<T>::value, ""); #endif static_assert(!std::is_integral<T>::value, ""); @@ -49,7 +50,12 @@ union Union double __; }; +struct incomplete_type; + int main() { test_union<Union>(); + +// LWG#2582 + static_assert(!std::is_union<incomplete_type>::value, ""); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp index f20bcf87ea150..c7597eb4eaf77 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp @@ -12,12 +12,13 @@ // void #include <type_traits> +#include "test_macros.h" template <class T> void test_void_imp() { static_assert( std::is_void<T>::value, ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(!std::is_null_pointer<T>::value, ""); #endif static_assert(!std::is_integral<T>::value, ""); @@ -43,7 +44,12 @@ void test_void() test_void_imp<const volatile T>(); } +struct incomplete_type; + int main() { test_void<void>(); + +// LWG#2582 + static_assert(!std::is_void<incomplete_type>::value, ""); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/array.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/array.pass.cpp index 3476d5ceea2ba..f601bd12cadbd 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.comp/array.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/array.pass.cpp @@ -38,9 +38,12 @@ typedef char array[3]; typedef const char const_array[3]; typedef char incomplete_array[]; +class incomplete_type; + int main() { test_array<array>(); test_array<const_array>(); test_array<incomplete_array>(); + test_array<incomplete_type[]>(); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/class.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/class.pass.cpp index 49e41380ca273..5fa5da12aef8a 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.comp/class.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/class.pass.cpp @@ -38,7 +38,10 @@ class Class { }; +class incomplete_type; + int main() { test_class<Class>(); + test_class<incomplete_type>(); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_arithmetic.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_arithmetic.pass.cpp index a3f18d52a7067..02c539712c653 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_arithmetic.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_arithmetic.pass.cpp @@ -45,6 +45,8 @@ void test_is_not_arithmetic() #endif } +class incomplete_type; + class Empty { }; @@ -98,6 +100,7 @@ int main() test_is_not_arithmetic<Enum>(); test_is_not_arithmetic<FunctionPtr>(); test_is_not_arithmetic<Empty>(); + test_is_not_arithmetic<incomplete_type>(); test_is_not_arithmetic<bit_zero>(); test_is_not_arithmetic<NotEmpty>(); test_is_not_arithmetic<Abstract>(); diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_compound.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_compound.pass.cpp index 6a1798ab5adc2..d8d5162c1a02b 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_compound.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_compound.pass.cpp @@ -45,6 +45,8 @@ void test_is_not_compound() #endif } +class incomplete_type; + class Empty { }; @@ -81,6 +83,7 @@ int main() test_is_compound<int&&>(); test_is_compound<Union>(); test_is_compound<Empty>(); + test_is_compound<incomplete_type>(); test_is_compound<bit_zero>(); test_is_compound<int*>(); test_is_compound<const int*>(); diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_fundamental.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_fundamental.pass.cpp index e16337e05f1ce..f776196dd7a98 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_fundamental.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_fundamental.pass.cpp @@ -45,6 +45,8 @@ void test_is_not_fundamental() #endif } +class incomplete_type; + class Empty { }; @@ -94,7 +96,7 @@ int main() test_is_fundamental<long double>(); test_is_fundamental<char16_t>(); test_is_fundamental<char32_t>(); - + test_is_not_fundamental<char[3]>(); test_is_not_fundamental<char[]>(); test_is_not_fundamental<void *>(); @@ -103,6 +105,7 @@ int main() test_is_not_fundamental<int&&>(); test_is_not_fundamental<Union>(); test_is_not_fundamental<Empty>(); + test_is_not_fundamental<incomplete_type>(); test_is_not_fundamental<bit_zero>(); test_is_not_fundamental<int*>(); test_is_not_fundamental<const int*>(); diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_member_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_member_pointer.pass.cpp index 890da659e2180..c2804885ac50b 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_member_pointer.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_member_pointer.pass.cpp @@ -45,6 +45,8 @@ void test_is_not_member_pointer() #endif } +class incomplete_type; + class Empty { }; @@ -73,9 +75,9 @@ typedef void (*FunctionPtr)(); int main() { -// Arithmetic types (3.9.1), enumeration types, pointer types, pointer to member types (3.9.2), -// std::nullptr_t, and cv-qualified versions of these types (3.9.3) -// are collectively called scalar types. +// Arithmetic types (3.9.1), enumeration types, pointer types, pointer to member types (3.9.2), +// std::nullptr_t, and cv-qualified versions of these types (3.9.3) +// are collectively called scalar types. test_is_member_pointer<int Empty::*>(); test_is_member_pointer<void (Empty::*)(int)>(); @@ -93,6 +95,7 @@ int main() test_is_not_member_pointer<char[]>(); test_is_not_member_pointer<Union>(); test_is_not_member_pointer<Empty>(); + test_is_not_member_pointer<incomplete_type>(); test_is_not_member_pointer<bit_zero>(); test_is_not_member_pointer<NotEmpty>(); test_is_not_member_pointer<Abstract>(); diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_object.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_object.pass.cpp index ff7dda30d111c..311215b816438 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_object.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_object.pass.cpp @@ -45,6 +45,8 @@ void test_is_not_object() #endif } +class incomplete_type; + class Empty { }; @@ -73,7 +75,7 @@ typedef void (*FunctionPtr)(); int main() { -// An object type is a (possibly cv-qualified) type that is not a function type, +// An object type is a (possibly cv-qualified) type that is not a function type, // not a reference type, and not a void type. test_is_object<std::nullptr_t>(); @@ -86,8 +88,8 @@ int main() test_is_object<int*>(); test_is_object<const int*>(); test_is_object<Enum>(); - test_is_object<Empty>(); - test_is_object<bit_zero>(); + test_is_object<incomplete_type>(); + test_is_object<bit_zero>(); test_is_object<NotEmpty>(); test_is_object<Abstract>(); test_is_object<FunctionPtr>(); diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_reference.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_reference.pass.cpp index e56c8f7618147..b546458bdcb82 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_reference.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_reference.pass.cpp @@ -45,6 +45,8 @@ void test_is_not_reference() #endif } +class incomplete_type; + class Empty { }; @@ -87,6 +89,7 @@ int main() test_is_not_reference<void *>(); test_is_not_reference<FunctionPtr>(); test_is_not_reference<Union>(); + test_is_not_reference<incomplete_type>(); test_is_not_reference<Empty>(); test_is_not_reference<bit_zero>(); test_is_not_reference<int*>(); diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_scalar.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_scalar.pass.cpp index 2b412a68833bf..39ac07ad4bc51 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_scalar.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_scalar.pass.cpp @@ -45,6 +45,8 @@ void test_is_not_scalar() #endif } +class incomplete_type; + class Empty { }; @@ -73,9 +75,9 @@ typedef void (*FunctionPtr)(); int main() { -// Arithmetic types (3.9.1), enumeration types, pointer types, pointer to member types (3.9.2), -// std::nullptr_t, and cv-qualified versions of these types (3.9.3) -// are collectively called scalar types. +// Arithmetic types (3.9.1), enumeration types, pointer types, pointer to member types (3.9.2), +// std::nullptr_t, and cv-qualified versions of these types (3.9.3) +// are collectively called scalar types. test_is_scalar<std::nullptr_t>(); test_is_scalar<short>(); @@ -104,6 +106,7 @@ int main() test_is_not_scalar<char[]>(); test_is_not_scalar<Union>(); test_is_not_scalar<Empty>(); + test_is_not_scalar<incomplete_type>(); test_is_not_scalar<bit_zero>(); test_is_not_scalar<NotEmpty>(); test_is_not_scalar<Abstract>(); diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp deleted file mode 100644 index 1c715e04970c7..0000000000000 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp +++ /dev/null @@ -1,71 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// type_traits - -// extension - -// template <typename _Tp> struct __has_operator_addressof - - -#include <type_traits> - -#ifndef _LIBCPP_HAS_NO_CONSTEXPR - -struct A -{ -}; - -struct B -{ - constexpr B* operator&() const; -}; - -struct D; - -struct C -{ - template <class U> - D operator,(U&&); -}; - -struct E -{ - constexpr C operator&() const; -}; - -struct F {}; -constexpr F* operator&(F const &) { return nullptr; } - -struct G {}; -constexpr G* operator&(G &&) { return nullptr; } - -struct H {}; -constexpr H* operator&(H const &&) { return nullptr; } - -struct J -{ - constexpr J* operator&() const &&; -}; - -#endif // _LIBCPP_HAS_NO_CONSTEXPR - -int main() -{ -#ifndef _LIBCPP_HAS_NO_CONSTEXPR - static_assert(std::__has_operator_addressof<int>::value == false, ""); - static_assert(std::__has_operator_addressof<A>::value == false, ""); - static_assert(std::__has_operator_addressof<B>::value == true, ""); - static_assert(std::__has_operator_addressof<E>::value == true, ""); - static_assert(std::__has_operator_addressof<F>::value == true, ""); - static_assert(std::__has_operator_addressof<G>::value == true, ""); - static_assert(std::__has_operator_addressof<H>::value == true, ""); - static_assert(std::__has_operator_addressof<J>::value == true, ""); -#endif // _LIBCPP_HAS_NO_CONSTEXPR -} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp index 36020139ec586..7330f4b351258 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp @@ -13,6 +13,8 @@ #include <type_traits> +#include "test_macros.h" + template <class T> void test_has_virtual_destructor() { diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp index c0f6bb9bdfafc..b734a1aa60d86 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp @@ -77,7 +77,7 @@ int main() test_is_not_assignable<void, const void> (); test_is_not_assignable<const void, const void> (); test_is_not_assignable<int(), int> (); - + // pointer to incomplete template type test_is_assignable<X<D>*&, X<D>*> (); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp index 7f63ae40aca78..616f25180a600 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp @@ -29,6 +29,8 @@ void test_is_const() #endif } +struct A; // incomplete + int main() { test_is_const<void>(); @@ -39,6 +41,8 @@ int main() test_is_const<char[3]>(); test_is_const<char[]>(); + test_is_const<A>(); + static_assert(!std::is_const<int&>::value, ""); static_assert(!std::is_const<const int&>::value, ""); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp index 5401d95532b1d..9f8fdc7fc6357 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp @@ -8,6 +8,8 @@ //===----------------------------------------------------------------------===// // type_traits +// XFAIL: apple-clang-6.0 +// The Apple-6 compiler gets is_constructible<void ()> wrong. // template <class T, class... Args> // struct is_constructible; @@ -19,7 +21,7 @@ struct A { explicit A(int); A(int, double); -#if __has_feature(cxx_access_control_sfinae) +#if TEST_STD_VER >= 11 private: #endif A(char); @@ -89,7 +91,7 @@ int main() test_is_constructible<int&, int&> (); test_is_not_constructible<A> (); -#if __has_feature(cxx_access_control_sfinae) +#if TEST_STD_VER >= 11 test_is_not_constructible<A, char> (); #else test_is_constructible<A, char> (); @@ -99,4 +101,13 @@ int main() test_is_not_constructible<int&> (); test_is_not_constructible<Abstract> (); test_is_not_constructible<AbstractDestructor> (); + +// LWG 2560 -- postpone this test until bots updated +// test_is_not_constructible<void()> (); +#if TEST_STD_VER > 11 +// test_is_not_constructible<void() const> (); +// test_is_not_constructible<void() volatile> (); +// test_is_not_constructible<void() &> (); +// test_is_not_constructible<void() &&> (); +#endif } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp index 421f865a623c4..ac8b80bbd3a4d 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp @@ -79,7 +79,7 @@ int main() test_is_not_copy_assignable<int[]> (); test_is_not_copy_assignable<int[3]> (); #endif -#if __has_feature(cxx_access_control_sfinae) +#if TEST_STD_VER >= 11 test_is_not_copy_assignable<B> (); #endif test_is_not_copy_assignable<void> (); diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp index fe2e01429b22b..684d85d3d40ce 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp @@ -89,7 +89,7 @@ int main() test_is_not_copy_constructible<void>(); test_is_not_copy_constructible<Abstract>(); test_is_not_copy_constructible<C>(); -#if __has_feature(cxx_access_control_sfinae) +#if TEST_STD_VER >= 11 test_is_not_copy_constructible<B>(); #endif } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp index 7b46eeaab66b9..318147e5d4a34 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp @@ -100,7 +100,7 @@ int main() test_is_not_default_constructible<char[]>(); test_is_not_default_constructible<Abstract>(); test_is_not_default_constructible<NoDefaultConstructor>(); -#if __has_feature(cxx_access_control_sfinae) +#if TEST_STD_VER >= 11 test_is_not_default_constructible<B>(); #endif } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp index 60d607aba61c3..5e8bfeaa41d28 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp @@ -11,9 +11,15 @@ // is_destructible +// Prevent warning when testing the Abstract test type. +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wdelete-non-virtual-dtor" +#endif + #include <type_traits> #include "test_macros.h" + template <class T> void test_is_destructible() { diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp index baf85e3e81395..5a440598bb020 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11 // type_traits // is_final @@ -14,8 +15,6 @@ #include <type_traits> #include "test_macros.h" -#if _LIBCPP_STD_VER > 11 - struct P final { }; union U1 { }; union U2 final { }; @@ -54,13 +53,10 @@ int main () { test_is_not_final<int>(); test_is_not_final<int*>(); - test_is_final <P>(); - test_is_not_final<P*>(); + test_is_final <P>(); + test_is_not_final<P*>(); test_is_not_final<U1>(); test_is_not_final<U1*>(); - test_is_final <U2>(); - test_is_not_final<U2*>(); + test_is_final <U2>(); + test_is_not_final<U2*>(); } -#else -int main () {} -#endif diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp index c778a5d24b2e6..8200b468fe3a4 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp @@ -107,7 +107,7 @@ int main() #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES test_is_nothrow_constructible<Tuple &&, Empty> (); // See bug #19616. #endif - + test_is_not_nothrow_constructible<A, int> (); test_is_not_nothrow_constructible<A, int, double> (); test_is_not_nothrow_constructible<A> (); diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp index 42c9807efa833..58e0e0f98b580 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp @@ -11,6 +11,11 @@ // is_nothrow_destructible +// Prevent warning when testing the Abstract test type. +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wdelete-non-virtual-dtor" +#endif + #include <type_traits> #include "test_macros.h" diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_swappable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_swappable.pass.cpp new file mode 100644 index 0000000000000..7510b4e7293c9 --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_swappable.pass.cpp @@ -0,0 +1,83 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// type_traits + +// is_swappable + +#include <type_traits> +#include <vector> +#include "test_macros.h" + +namespace MyNS { + +// Make the test types non-copyable so that generic std::swap is not valid. +struct A { + A(A const&) = delete; + A& operator=(A const&) = delete; +}; + +struct B { + B(B const&) = delete; + B& operator=(B const&) = delete; +}; + +void swap(A&, A&) noexcept {} +void swap(B&, B&) {} + +struct M { + M(M const&) = delete; + M& operator=(M const&) = delete; +}; + +void swap(M&&, M&&) noexcept {} + +struct ThrowingMove { + ThrowingMove(ThrowingMove&&) {} + ThrowingMove& operator=(ThrowingMove&&) { return *this; } +}; + +} // namespace MyNS + +int main() +{ + using namespace MyNS; + { + // Test that is_swappable applies an lvalue reference to the type. + static_assert(std::is_nothrow_swappable<int>::value, ""); + static_assert(std::is_nothrow_swappable<int&>::value, ""); + static_assert(!std::is_nothrow_swappable<M>::value, ""); + static_assert(!std::is_nothrow_swappable<M&&>::value, ""); + } + { + // Test that it correctly deduces the noexcept of swap. + static_assert(std::is_nothrow_swappable<A>::value, ""); + static_assert(!std::is_nothrow_swappable<B>::value + && std::is_swappable<B>::value, ""); + static_assert(!std::is_nothrow_swappable<ThrowingMove>::value + && std::is_swappable<ThrowingMove>::value, ""); + } + { + // Test that it doesn't drop the qualifiers + static_assert(!std::is_nothrow_swappable<const A>::value, ""); + } + { + // test non-referenceable types + static_assert(!std::is_nothrow_swappable<void>::value, ""); + static_assert(!std::is_nothrow_swappable<int() const>::value, ""); + static_assert(!std::is_nothrow_swappable<int(int, ...) const &>::value, ""); + } + { + // test for presence of is_nothrow_swappable_v + static_assert(std::is_nothrow_swappable_v<int>, ""); + static_assert(!std::is_nothrow_swappable_v<void>, ""); + } +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_swappable_with.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_swappable_with.pass.cpp new file mode 100644 index 0000000000000..408231f6057f8 --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_swappable_with.pass.cpp @@ -0,0 +1,81 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// type_traits + +// is_nothrow_swappable_with + +#include <type_traits> +#include <vector> +#include "test_macros.h" + +namespace MyNS { + +struct A { + A(A const&) = delete; + A& operator=(A const&) = delete; +}; + +struct B { + B(B const&) = delete; + B& operator=(B const&) = delete; +}; + +struct C {}; +struct D {}; + +void swap(A&, A&) {} + +void swap(A&, B&) noexcept {} +void swap(B&, A&) noexcept {} + +void swap(A&, C&) noexcept {} +void swap(C&, A&) {} + +struct M {}; + +void swap(M&&, M&&) noexcept {} + +} // namespace MyNS + +int main() +{ + using namespace MyNS; + { + // Test that is_swappable_with doesn't apply an lvalue reference + // to the type. Instead it is up to the user. + static_assert(!std::is_nothrow_swappable_with<int, int>::value, ""); + static_assert(std::is_nothrow_swappable_with<int&, int&>::value, ""); + static_assert(std::is_nothrow_swappable_with<M, M>::value, ""); + static_assert(std::is_swappable_with<A&, A&>::value && + !std::is_nothrow_swappable_with<A&, A&>::value, ""); + } + { + // test that hetrogenius swap is allowed only if both 'swap(A, B)' and + // 'swap(B, A)' are valid. + static_assert(std::is_nothrow_swappable_with<A&, B&>::value, ""); + static_assert(!std::is_nothrow_swappable_with<A&, C&>::value && + std::is_swappable_with<A&, C&>::value, ""); + static_assert(!std::is_nothrow_swappable_with<D&, C&>::value, ""); + } + { + // test we guard against cv void inputs as required. + static_assert(!std::is_nothrow_swappable_with_v<void, int>, ""); + static_assert(!std::is_nothrow_swappable_with_v<int, void>, ""); + static_assert(!std::is_nothrow_swappable_with_v<const void, const volatile void>, ""); + + } + { + // test for presence of is_nothrow_swappable_with_v + static_assert(std::is_nothrow_swappable_with_v<int&, int&>, ""); + static_assert(!std::is_nothrow_swappable_with_v<int&&, int&&>, ""); + } +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp index b66e7a296f39a..6ce1c03775262 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp @@ -65,7 +65,7 @@ class Abstract virtual ~Abstract() = 0; }; -#if __has_feature(cxx_attributes) +#if TEST_STD_VER >= 11 class Final final { }; #else diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp index 94bf7fb580412..745efd00895c8 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp @@ -50,6 +50,8 @@ public: ~Class(); }; +struct A; // incomplete + int main() { test_is_not_signed<void>(); @@ -61,6 +63,7 @@ int main() test_is_not_signed<char[]>(); test_is_not_signed<bool>(); test_is_not_signed<unsigned>(); + test_is_not_signed<A>(); test_is_signed<int>(); test_is_signed<double>(); diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_swappable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_swappable.pass.cpp new file mode 100644 index 0000000000000..b17ca76fd5869 --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_swappable.pass.cpp @@ -0,0 +1,98 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// type_traits + +// is_swappable + +#include <type_traits> +#include <utility> +#include <vector> +#include "test_macros.h" + +namespace MyNS { + +// Make the test types non-copyable so that generic std::swap is not valid. +struct A { + A(A const&) = delete; + A& operator=(A const&) = delete; +}; + +struct B { + B(B const&) = delete; + B& operator=(B const&) = delete; +}; + +struct C {}; +struct D {}; + +void swap(A&, A&) {} + +void swap(A&, B&) {} +void swap(B&, A&) {} + +void swap(A&, C&) {} // missing swap(C, A) +void swap(D&, C&) {} + +struct M { + M(M const&) = delete; + M& operator=(M const&) = delete; +}; + +void swap(M&&, M&&) {} + +struct DeletedSwap { + friend void swap(DeletedSwap&, DeletedSwap&) = delete; +}; + +} // namespace MyNS + +namespace MyNS2 { + +struct AmbiguousSwap {}; + +template <class T> +void swap(T&, T&) {} + +} // end namespace MyNS2 + +int main() +{ + using namespace MyNS; + { + // Test that is_swappable applies an lvalue reference to the type. + static_assert(std::is_swappable<A>::value, ""); + static_assert(std::is_swappable<A&>::value, ""); + static_assert(!std::is_swappable<M>::value, ""); + static_assert(!std::is_swappable<M&&>::value, ""); + } + static_assert(!std::is_swappable<B>::value, ""); + static_assert(std::is_swappable<C>::value, ""); + { + // test non-referencable types + static_assert(!std::is_swappable<void>::value, ""); + static_assert(!std::is_swappable<int() const>::value, ""); + static_assert(!std::is_swappable<int() &>::value, ""); + } + { + // test that a deleted swap is correctly handled. + static_assert(!std::is_swappable<DeletedSwap>::value, ""); + } + { + // test that a swap with ambiguous overloads is handled correctly. + static_assert(!std::is_swappable<MyNS2::AmbiguousSwap>::value, ""); + } + { + // test for presence of is_swappable_v + static_assert(std::is_swappable_v<int>, ""); + static_assert(!std::is_swappable_v<M>, ""); + } +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_swappable_include_order.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_swappable_include_order.pass.cpp new file mode 100644 index 0000000000000..c3ae1706f0950 --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_swappable_include_order.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_swappable + +// IMPORTANT: The include order is part of the test. We want to pick up +// the following definitions in this order: +// 1) is_swappable, is_nothrow_swappable +// 2) iter_swap, swap_ranges +// 3) swap(T (&)[N], T (&)[N]) +// This test checks that (1) and (2) see forward declarations +// for (3). +#include <type_traits> +#include <algorithm> +#include <utility> + +#include "test_macros.h" + +int main() +{ + // Use a builtin type so we don't get ADL lookup. + typedef double T[17][29]; + { + LIBCPP_STATIC_ASSERT(std::__is_swappable<T>::value, ""); +#if TEST_STD_VER > 14 + static_assert(std::is_swappable_v<T>, ""); +#endif + } + { + T t1 = {}; + T t2 = {}; + std::iter_swap(t1, t2); + std::swap_ranges(t1, t1 + 17, t2); + } +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_swappable_with.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_swappable_with.pass.cpp new file mode 100644 index 0000000000000..a049eab9a1923 --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_swappable_with.pass.cpp @@ -0,0 +1,78 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// type_traits + +// is_swappable_with + +#include <type_traits> +#include <vector> +#include "test_macros.h" + +namespace MyNS { + +struct A { + A(A const&) = delete; + A& operator=(A const&) = delete; +}; + +struct B { + B(B const&) = delete; + B& operator=(B const&) = delete; +}; + +struct C {}; +struct D {}; + +void swap(A&, A&) {} + +void swap(A&, B&) {} +void swap(B&, A&) {} + +void swap(A&, C&) {} // missing swap(C, A) +void swap(D&, C&) {} + +struct M {}; + +void swap(M&&, M&&) {} + +} // namespace MyNS + +int main() +{ + using namespace MyNS; + { + // Test that is_swappable_with doesn't apply an lvalue reference + // to the type. Instead it is up to the user. + static_assert(!std::is_swappable_with<int, int>::value, ""); + static_assert(std::is_swappable_with<int&, int&>::value, ""); + static_assert(std::is_swappable_with<M, M>::value, ""); + static_assert(std::is_swappable_with<A&, A&>::value, ""); + } + { + // test that heterogeneous swap is allowed only if both 'swap(A, B)' and + // 'swap(B, A)' are valid. + static_assert(std::is_swappable_with<A&, B&>::value, ""); + static_assert(!std::is_swappable_with<A&, C&>::value, ""); + static_assert(!std::is_swappable_with<D&, C&>::value, ""); + } + { + // test that cv void is guarded against as required. + static_assert(!std::is_swappable_with_v<void, int>, ""); + static_assert(!std::is_swappable_with_v<int, void>, ""); + static_assert(!std::is_swappable_with_v<const void, const volatile void>, ""); + } + { + // test for presence of is_swappable_with_v + static_assert(std::is_swappable_with_v<int&, int&>, ""); + static_assert(!std::is_swappable_with_v<D&, C&>, ""); + } +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp index 3ebb9dba429d0..a9b538b2dffc7 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp @@ -11,6 +11,8 @@ // is_trivially_assignable +// XFAIL: gcc-4.9 + #include <type_traits> #include "test_macros.h" diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp index 25429f5470e7b..966573c9f0fe5 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp @@ -11,6 +11,8 @@ // is_trivially_copy_assignable +// XFAIL: gcc-4.9 + #include <type_traits> #include "test_macros.h" diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp index 9556959e12621..2922f22766696 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp @@ -11,6 +11,8 @@ // is_trivially_copy_constructible +// XFAIL: gcc-4.9 + #include <type_traits> #include "test_macros.h" diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp index c19a29ffb5869..42ecdb3b896a8 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp @@ -11,6 +11,8 @@ // is_trivially_copyable +// XFAIL: gcc-4.9 + #include <type_traits> #include <cassert> #include "test_macros.h" diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp index 9e2507067d2d3..3372e615d71de 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp @@ -11,6 +11,11 @@ // is_trivially_destructible +// Prevent warning when testing the Abstract test type. +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wdelete-non-virtual-dtor" +#endif + #include <type_traits> #include "test_macros.h" diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp index eca596ee1c19e..9a27c73cdfd8b 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp @@ -11,6 +11,8 @@ // is_trivially_move_assignable +// XFAIL: gcc-4.9 + #include <type_traits> #include "test_macros.h" diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp index 313da175f7156..941ff31f89da8 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp @@ -11,6 +11,8 @@ // is_trivially_move_constructible +// XFAIL: gcc-4.9 + #include <type_traits> #include "test_macros.h" @@ -60,7 +62,7 @@ struct A A(const A&); }; -#if __has_feature(cxx_defaulted_functions) +#if TEST_STD_VER >= 11 struct MoveOnly1 { @@ -89,7 +91,7 @@ int main() test_is_trivially_move_constructible<const int*>(); test_is_trivially_move_constructible<bit_zero>(); -#if __has_feature(cxx_defaulted_functions) +#if TEST_STD_VER >= 11 static_assert(!std::is_trivially_move_constructible<MoveOnly1>::value, ""); static_assert( std::is_trivially_move_constructible<MoveOnly2>::value, ""); #endif diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp index 9ca42432df169..376c7e005ce9e 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp @@ -50,6 +50,8 @@ public: ~Class(); }; +struct A; // incomplete + int main() { test_is_not_unsigned<void>(); @@ -61,6 +63,7 @@ int main() test_is_not_unsigned<char[]>(); test_is_not_unsigned<int>(); test_is_not_unsigned<double>(); + test_is_not_unsigned<A>(); test_is_unsigned<bool>(); test_is_unsigned<unsigned>(); diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp index 36697a3f3eba0..cc8d66ae6888c 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp @@ -29,6 +29,8 @@ void test_is_volatile() #endif } +struct A; // incomplete + int main() { test_is_volatile<void>(); @@ -39,6 +41,8 @@ int main() test_is_volatile<char[3]>(); test_is_volatile<char[]>(); + test_is_volatile<A>(); + static_assert(!std::is_volatile<int&>::value, ""); static_assert(!std::is_volatile<volatile int&>::value, ""); } diff --git a/test/std/utilities/meta/version.pass.cpp b/test/std/utilities/meta/version.pass.cpp deleted file mode 100644 index 3a1033bbb5605..0000000000000 --- a/test/std/utilities/meta/version.pass.cpp +++ /dev/null @@ -1,20 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// <type_traits> - -#include <type_traits> - -#ifndef _LIBCPP_VERSION -#error _LIBCPP_VERSION not defined -#endif - -int main() -{ -} |