is_polymorphic.pass.cpp revision b64f8b07c104c6cc986570ac8ee0ed16a9f23976
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// type_traits 11 12// is_polymorphic 13 14#include <type_traits> 15 16template <class T> 17void test_is_polymorphic() 18{ 19 static_assert( std::is_polymorphic<T>::value, ""); 20 static_assert( std::is_polymorphic<const T>::value, ""); 21 static_assert( std::is_polymorphic<volatile T>::value, ""); 22 static_assert( std::is_polymorphic<const volatile T>::value, ""); 23} 24 25template <class T> 26void test_is_not_polymorphic() 27{ 28 static_assert(!std::is_polymorphic<T>::value, ""); 29 static_assert(!std::is_polymorphic<const T>::value, ""); 30 static_assert(!std::is_polymorphic<volatile T>::value, ""); 31 static_assert(!std::is_polymorphic<const volatile T>::value, ""); 32} 33 34class Empty 35{ 36}; 37 38class NotEmpty 39{ 40 virtual ~NotEmpty(); 41}; 42 43union Union {}; 44 45struct bit_zero 46{ 47 int : 0; 48}; 49 50class Abstract 51{ 52 virtual ~Abstract() = 0; 53}; 54 55int main() 56{ 57 test_is_not_polymorphic<void>(); 58 test_is_not_polymorphic<int&>(); 59 test_is_not_polymorphic<int>(); 60 test_is_not_polymorphic<double>(); 61 test_is_not_polymorphic<int*>(); 62 test_is_not_polymorphic<const int*>(); 63 test_is_not_polymorphic<char[3]>(); 64 test_is_not_polymorphic<char[3]>(); 65 test_is_not_polymorphic<Union>(); 66 test_is_not_polymorphic<Empty>(); 67 test_is_not_polymorphic<bit_zero>(); 68 69 test_is_polymorphic<NotEmpty>(); 70 test_is_polymorphic<Abstract>(); 71} 72