diff options
Diffstat (limited to 'test/libcxx/utilities/meta')
3 files changed, 284 insertions, 0 deletions
diff --git a/test/libcxx/utilities/meta/is_referenceable.pass.cpp b/test/libcxx/utilities/meta/is_referenceable.pass.cpp new file mode 100644 index 000000000000..42b1f2dc3014 --- /dev/null +++ b/test/libcxx/utilities/meta/is_referenceable.pass.cpp @@ -0,0 +1,193 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// + +// __is_referenceable<Tp> +// +// [defns.referenceable] defines "a referenceable type" as: +// An object type, a function type that does not have cv-qualifiers +// or a ref-qualifier, or a reference type. +// + +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +struct Foo {}; + +static_assert((!std::__is_referenceable<void>::value), ""); +static_assert(( std::__is_referenceable<int>::value), ""); +static_assert(( std::__is_referenceable<int[3]>::value), ""); +static_assert(( std::__is_referenceable<int[]>::value), ""); +static_assert(( std::__is_referenceable<int &>::value), ""); +static_assert(( std::__is_referenceable<const int &>::value), ""); +static_assert(( std::__is_referenceable<int *>::value), ""); +static_assert(( std::__is_referenceable<const int *>::value), ""); +static_assert(( std::__is_referenceable<Foo>::value), ""); +static_assert(( std::__is_referenceable<const Foo>::value), ""); +static_assert(( std::__is_referenceable<Foo &>::value), ""); +static_assert(( std::__is_referenceable<const Foo &>::value), ""); +#if TEST_STD_VER >= 11 +static_assert(( std::__is_referenceable<Foo &&>::value), ""); +static_assert(( std::__is_referenceable<const Foo &&>::value), ""); +#endif + +static_assert(( std::__is_referenceable<int __attribute__((__vector_size__( 8)))>::value), ""); +static_assert(( std::__is_referenceable<const int __attribute__((__vector_size__( 8)))>::value), ""); +static_assert(( std::__is_referenceable<float __attribute__((__vector_size__(16)))>::value), ""); +static_assert(( std::__is_referenceable<const float __attribute__((__vector_size__(16)))>::value), ""); + +// Functions without cv-qualifiers are referenceable +static_assert(( std::__is_referenceable<void ()>::value), ""); +#if TEST_STD_VER >= 11 +static_assert((!std::__is_referenceable<void () const>::value), ""); +static_assert((!std::__is_referenceable<void () &>::value), ""); +static_assert((!std::__is_referenceable<void () const &>::value), ""); +static_assert((!std::__is_referenceable<void () &&>::value), ""); +static_assert((!std::__is_referenceable<void () const &&>::value), ""); +#endif + +static_assert(( std::__is_referenceable<void (int)>::value), ""); +#if TEST_STD_VER >= 11 +static_assert((!std::__is_referenceable<void (int) const>::value), ""); +static_assert((!std::__is_referenceable<void (int) &>::value), ""); +static_assert((!std::__is_referenceable<void (int) const &>::value), ""); +static_assert((!std::__is_referenceable<void (int) &&>::value), ""); +static_assert((!std::__is_referenceable<void (int) const &&>::value), ""); +#endif + +static_assert(( std::__is_referenceable<void (int, float)>::value), ""); +#if TEST_STD_VER >= 11 +static_assert((!std::__is_referenceable<void (int, float) const>::value), ""); +static_assert((!std::__is_referenceable<void (int, float) &>::value), ""); +static_assert((!std::__is_referenceable<void (int, float) const &>::value), ""); +static_assert((!std::__is_referenceable<void (int, float) &&>::value), ""); +static_assert((!std::__is_referenceable<void (int, float) const &&>::value), ""); +#endif + +static_assert(( std::__is_referenceable<void (int, float, Foo &)>::value), ""); +#if TEST_STD_VER >= 11 +static_assert((!std::__is_referenceable<void (int, float, Foo &) const>::value), ""); +static_assert((!std::__is_referenceable<void (int, float, Foo &) &>::value), ""); +static_assert((!std::__is_referenceable<void (int, float, Foo &) const &>::value), ""); +static_assert((!std::__is_referenceable<void (int, float, Foo &) &&>::value), ""); +static_assert((!std::__is_referenceable<void (int, float, Foo &) const &&>::value), ""); +#endif + +static_assert(( std::__is_referenceable<void (...)>::value), ""); +#if TEST_STD_VER >= 11 +static_assert((!std::__is_referenceable<void (...) const>::value), ""); +static_assert((!std::__is_referenceable<void (...) &>::value), ""); +static_assert((!std::__is_referenceable<void (...) const &>::value), ""); +static_assert((!std::__is_referenceable<void (...) &&>::value), ""); +static_assert((!std::__is_referenceable<void (...) const &&>::value), ""); +#endif + +static_assert(( std::__is_referenceable<void (int, ...)>::value), ""); +#if TEST_STD_VER >= 11 +static_assert((!std::__is_referenceable<void (int, ...) const>::value), ""); +static_assert((!std::__is_referenceable<void (int, ...) &>::value), ""); +static_assert((!std::__is_referenceable<void (int, ...) const &>::value), ""); +static_assert((!std::__is_referenceable<void (int, ...) &&>::value), ""); +static_assert((!std::__is_referenceable<void (int, ...) const &&>::value), ""); +#endif + +static_assert(( std::__is_referenceable<void (int, float, ...)>::value), ""); +#if TEST_STD_VER >= 11 +static_assert((!std::__is_referenceable<void (int, float, ...) const>::value), ""); +static_assert((!std::__is_referenceable<void (int, float, ...) &>::value), ""); +static_assert((!std::__is_referenceable<void (int, float, ...) const &>::value), ""); +static_assert((!std::__is_referenceable<void (int, float, ...) &&>::value), ""); +static_assert((!std::__is_referenceable<void (int, float, ...) const &&>::value), ""); +#endif + +static_assert(( std::__is_referenceable<void (int, float, Foo &, ...)>::value), ""); +#if TEST_STD_VER >= 11 +static_assert((!std::__is_referenceable<void (int, float, Foo &, ...) const>::value), ""); +static_assert((!std::__is_referenceable<void (int, float, Foo &, ...) &>::value), ""); +static_assert((!std::__is_referenceable<void (int, float, Foo &, ...) const &>::value), ""); +static_assert((!std::__is_referenceable<void (int, float, Foo &, ...) &&>::value), ""); +static_assert((!std::__is_referenceable<void (int, float, Foo &, ...) const &&>::value), ""); +#endif + +// member functions with or without cv-qualifiers are referenceable +static_assert(( std::__is_referenceable<void (Foo::*)()>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)() const>::value), ""); +#if TEST_STD_VER >= 11 +static_assert(( std::__is_referenceable<void (Foo::*)() &>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)() const &>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)() &&>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)() const &&>::value), ""); +#endif + +static_assert(( std::__is_referenceable<void (Foo::*)(int)>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int) const>::value), ""); +#if TEST_STD_VER >= 11 +static_assert(( std::__is_referenceable<void (Foo::*)(int) &>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int) const &>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int) &&>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int) const &&>::value), ""); +#endif + +static_assert(( std::__is_referenceable<void (Foo::*)(int, float)>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int, float) const>::value), ""); +#if TEST_STD_VER >= 11 +static_assert(( std::__is_referenceable<void (Foo::*)(int, float) &>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int, float) const &>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int, float) &&>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int, float) const &&>::value), ""); +#endif + +static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &)>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &) const>::value), ""); +#if TEST_STD_VER >= 11 +static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &) &>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &) const &>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &) &&>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &) const &&>::value), ""); +#endif + +static_assert(( std::__is_referenceable<void (Foo::*)(...)>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(...) const>::value), ""); +#if TEST_STD_VER >= 11 +static_assert(( std::__is_referenceable<void (Foo::*)(...) &>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(...) const &>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(...) &&>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(...) const &&>::value), ""); +#endif + +static_assert(( std::__is_referenceable<void (Foo::*)(int, ...)>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int, ...) const>::value), ""); +#if TEST_STD_VER >= 11 +static_assert(( std::__is_referenceable<void (Foo::*)(int, ...) &>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int, ...) const &>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int, ...) &&>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int, ...) const &&>::value), ""); +#endif + +static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...)>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...) const>::value), ""); +#if TEST_STD_VER >= 11 +static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...) &>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...) const &>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...) &&>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...) const &&>::value), ""); +#endif + +static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...)>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...) const>::value), ""); +#if TEST_STD_VER >= 11 +static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...) &>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...) const &>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...) &&>::value), ""); +static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...) const &&>::value), ""); +#endif + +int main () {} diff --git a/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp b/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp new file mode 100644 index 000000000000..1c715e04970c --- /dev/null +++ b/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp @@ -0,0 +1,71 @@ +//===----------------------------------------------------------------------===// +// +// 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/libcxx/utilities/meta/version.pass.cpp b/test/libcxx/utilities/meta/version.pass.cpp new file mode 100644 index 000000000000..3a1033bbb560 --- /dev/null +++ b/test/libcxx/utilities/meta/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <type_traits> + +#include <type_traits> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} |