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