1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10 11// __is_referenceable<Tp> 12// 13// [defns.referenceable] defines "a referenceable type" as: 14// An object type, a function type that does not have cv-qualifiers 15// or a ref-qualifier, or a reference type. 16// 17 18#include <type_traits> 19#include <cassert> 20 21#include "test_macros.h" 22 23struct Foo {}; 24 25static_assert((!std::__is_referenceable<void>::value), ""); 26static_assert(( std::__is_referenceable<int>::value), ""); 27static_assert(( std::__is_referenceable<int[3]>::value), ""); 28static_assert(( std::__is_referenceable<int[]>::value), ""); 29static_assert(( std::__is_referenceable<int &>::value), ""); 30static_assert(( std::__is_referenceable<const int &>::value), ""); 31static_assert(( std::__is_referenceable<int *>::value), ""); 32static_assert(( std::__is_referenceable<const int *>::value), ""); 33static_assert(( std::__is_referenceable<Foo>::value), ""); 34static_assert(( std::__is_referenceable<const Foo>::value), ""); 35static_assert(( std::__is_referenceable<Foo &>::value), ""); 36static_assert(( std::__is_referenceable<const Foo &>::value), ""); 37#if TEST_STD_VER >= 11 38static_assert(( std::__is_referenceable<Foo &&>::value), ""); 39static_assert(( std::__is_referenceable<const Foo &&>::value), ""); 40#endif 41 42static_assert(( std::__is_referenceable<int __attribute__((__vector_size__( 8)))>::value), ""); 43static_assert(( std::__is_referenceable<const int __attribute__((__vector_size__( 8)))>::value), ""); 44static_assert(( std::__is_referenceable<float __attribute__((__vector_size__(16)))>::value), ""); 45static_assert(( std::__is_referenceable<const float __attribute__((__vector_size__(16)))>::value), ""); 46 47// Functions without cv-qualifiers are referenceable 48static_assert(( std::__is_referenceable<void ()>::value), ""); 49#if TEST_STD_VER >= 11 50static_assert((!std::__is_referenceable<void () const>::value), ""); 51static_assert((!std::__is_referenceable<void () &>::value), ""); 52static_assert((!std::__is_referenceable<void () const &>::value), ""); 53static_assert((!std::__is_referenceable<void () &&>::value), ""); 54static_assert((!std::__is_referenceable<void () const &&>::value), ""); 55#endif 56 57static_assert(( std::__is_referenceable<void (int)>::value), ""); 58#if TEST_STD_VER >= 11 59static_assert((!std::__is_referenceable<void (int) const>::value), ""); 60static_assert((!std::__is_referenceable<void (int) &>::value), ""); 61static_assert((!std::__is_referenceable<void (int) const &>::value), ""); 62static_assert((!std::__is_referenceable<void (int) &&>::value), ""); 63static_assert((!std::__is_referenceable<void (int) const &&>::value), ""); 64#endif 65 66static_assert(( std::__is_referenceable<void (int, float)>::value), ""); 67#if TEST_STD_VER >= 11 68static_assert((!std::__is_referenceable<void (int, float) const>::value), ""); 69static_assert((!std::__is_referenceable<void (int, float) &>::value), ""); 70static_assert((!std::__is_referenceable<void (int, float) const &>::value), ""); 71static_assert((!std::__is_referenceable<void (int, float) &&>::value), ""); 72static_assert((!std::__is_referenceable<void (int, float) const &&>::value), ""); 73#endif 74 75static_assert(( std::__is_referenceable<void (int, float, Foo &)>::value), ""); 76#if TEST_STD_VER >= 11 77static_assert((!std::__is_referenceable<void (int, float, Foo &) const>::value), ""); 78static_assert((!std::__is_referenceable<void (int, float, Foo &) &>::value), ""); 79static_assert((!std::__is_referenceable<void (int, float, Foo &) const &>::value), ""); 80static_assert((!std::__is_referenceable<void (int, float, Foo &) &&>::value), ""); 81static_assert((!std::__is_referenceable<void (int, float, Foo &) const &&>::value), ""); 82#endif 83 84static_assert(( std::__is_referenceable<void (...)>::value), ""); 85#if TEST_STD_VER >= 11 86static_assert((!std::__is_referenceable<void (...) const>::value), ""); 87static_assert((!std::__is_referenceable<void (...) &>::value), ""); 88static_assert((!std::__is_referenceable<void (...) const &>::value), ""); 89static_assert((!std::__is_referenceable<void (...) &&>::value), ""); 90static_assert((!std::__is_referenceable<void (...) const &&>::value), ""); 91#endif 92 93static_assert(( std::__is_referenceable<void (int, ...)>::value), ""); 94#if TEST_STD_VER >= 11 95static_assert((!std::__is_referenceable<void (int, ...) const>::value), ""); 96static_assert((!std::__is_referenceable<void (int, ...) &>::value), ""); 97static_assert((!std::__is_referenceable<void (int, ...) const &>::value), ""); 98static_assert((!std::__is_referenceable<void (int, ...) &&>::value), ""); 99static_assert((!std::__is_referenceable<void (int, ...) const &&>::value), ""); 100#endif 101 102static_assert(( std::__is_referenceable<void (int, float, ...)>::value), ""); 103#if TEST_STD_VER >= 11 104static_assert((!std::__is_referenceable<void (int, float, ...) const>::value), ""); 105static_assert((!std::__is_referenceable<void (int, float, ...) &>::value), ""); 106static_assert((!std::__is_referenceable<void (int, float, ...) const &>::value), ""); 107static_assert((!std::__is_referenceable<void (int, float, ...) &&>::value), ""); 108static_assert((!std::__is_referenceable<void (int, float, ...) const &&>::value), ""); 109#endif 110 111static_assert(( std::__is_referenceable<void (int, float, Foo &, ...)>::value), ""); 112#if TEST_STD_VER >= 11 113static_assert((!std::__is_referenceable<void (int, float, Foo &, ...) const>::value), ""); 114static_assert((!std::__is_referenceable<void (int, float, Foo &, ...) &>::value), ""); 115static_assert((!std::__is_referenceable<void (int, float, Foo &, ...) const &>::value), ""); 116static_assert((!std::__is_referenceable<void (int, float, Foo &, ...) &&>::value), ""); 117static_assert((!std::__is_referenceable<void (int, float, Foo &, ...) const &&>::value), ""); 118#endif 119 120// member functions with or without cv-qualifiers are referenceable 121static_assert(( std::__is_referenceable<void (Foo::*)()>::value), ""); 122static_assert(( std::__is_referenceable<void (Foo::*)() const>::value), ""); 123#if TEST_STD_VER >= 11 124static_assert(( std::__is_referenceable<void (Foo::*)() &>::value), ""); 125static_assert(( std::__is_referenceable<void (Foo::*)() const &>::value), ""); 126static_assert(( std::__is_referenceable<void (Foo::*)() &&>::value), ""); 127static_assert(( std::__is_referenceable<void (Foo::*)() const &&>::value), ""); 128#endif 129 130static_assert(( std::__is_referenceable<void (Foo::*)(int)>::value), ""); 131static_assert(( std::__is_referenceable<void (Foo::*)(int) const>::value), ""); 132#if TEST_STD_VER >= 11 133static_assert(( std::__is_referenceable<void (Foo::*)(int) &>::value), ""); 134static_assert(( std::__is_referenceable<void (Foo::*)(int) const &>::value), ""); 135static_assert(( std::__is_referenceable<void (Foo::*)(int) &&>::value), ""); 136static_assert(( std::__is_referenceable<void (Foo::*)(int) const &&>::value), ""); 137#endif 138 139static_assert(( std::__is_referenceable<void (Foo::*)(int, float)>::value), ""); 140static_assert(( std::__is_referenceable<void (Foo::*)(int, float) const>::value), ""); 141#if TEST_STD_VER >= 11 142static_assert(( std::__is_referenceable<void (Foo::*)(int, float) &>::value), ""); 143static_assert(( std::__is_referenceable<void (Foo::*)(int, float) const &>::value), ""); 144static_assert(( std::__is_referenceable<void (Foo::*)(int, float) &&>::value), ""); 145static_assert(( std::__is_referenceable<void (Foo::*)(int, float) const &&>::value), ""); 146#endif 147 148static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &)>::value), ""); 149static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &) const>::value), ""); 150#if TEST_STD_VER >= 11 151static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &) &>::value), ""); 152static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &) const &>::value), ""); 153static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &) &&>::value), ""); 154static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &) const &&>::value), ""); 155#endif 156 157static_assert(( std::__is_referenceable<void (Foo::*)(...)>::value), ""); 158static_assert(( std::__is_referenceable<void (Foo::*)(...) const>::value), ""); 159#if TEST_STD_VER >= 11 160static_assert(( std::__is_referenceable<void (Foo::*)(...) &>::value), ""); 161static_assert(( std::__is_referenceable<void (Foo::*)(...) const &>::value), ""); 162static_assert(( std::__is_referenceable<void (Foo::*)(...) &&>::value), ""); 163static_assert(( std::__is_referenceable<void (Foo::*)(...) const &&>::value), ""); 164#endif 165 166static_assert(( std::__is_referenceable<void (Foo::*)(int, ...)>::value), ""); 167static_assert(( std::__is_referenceable<void (Foo::*)(int, ...) const>::value), ""); 168#if TEST_STD_VER >= 11 169static_assert(( std::__is_referenceable<void (Foo::*)(int, ...) &>::value), ""); 170static_assert(( std::__is_referenceable<void (Foo::*)(int, ...) const &>::value), ""); 171static_assert(( std::__is_referenceable<void (Foo::*)(int, ...) &&>::value), ""); 172static_assert(( std::__is_referenceable<void (Foo::*)(int, ...) const &&>::value), ""); 173#endif 174 175static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...)>::value), ""); 176static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...) const>::value), ""); 177#if TEST_STD_VER >= 11 178static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...) &>::value), ""); 179static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...) const &>::value), ""); 180static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...) &&>::value), ""); 181static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...) const &&>::value), ""); 182#endif 183 184static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...)>::value), ""); 185static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...) const>::value), ""); 186#if TEST_STD_VER >= 11 187static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...) &>::value), ""); 188static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...) const &>::value), ""); 189static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...) &&>::value), ""); 190static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...) const &&>::value), ""); 191#endif 192 193int main () {} 194