cwg1170.cpp revision 8e8fb3be5bd78f0564444eca02b404566a5f3b5d
1// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 2// expected-no-diagnostics 3 4#if !__has_feature(cxx_access_control_sfinae) 5# error No support for access control as part of SFINAE? 6#endif 7 8typedef char yes_type; 9typedef char (&no_type)[2]; 10 11template<unsigned N> struct unsigned_c { }; 12 13template<typename T> 14class has_copy_constructor { 15 static T t; 16 17 template<typename U> static yes_type check(unsigned_c<sizeof(U(t))> * = 0); 18 template<typename U> static no_type check(...); 19 20public: 21 static const bool value = (sizeof(check<T>(0)) == sizeof(yes_type)); 22}; 23 24struct HasCopy { }; 25 26struct HasNonConstCopy { 27 HasNonConstCopy(HasNonConstCopy&); 28}; 29 30struct HasDeletedCopy { 31 HasDeletedCopy(const HasDeletedCopy&) = delete; 32}; 33 34struct HasPrivateCopy { 35private: 36 HasPrivateCopy(const HasPrivateCopy&); 37}; 38 39int check0[has_copy_constructor<HasCopy>::value? 1 : -1]; 40int check1[has_copy_constructor<HasNonConstCopy>::value? 1 : -1]; 41int check2[has_copy_constructor<HasDeletedCopy>::value? -1 : 1]; 42int check3[has_copy_constructor<HasPrivateCopy>::value? -1 : 1]; 43