diff mbox

[C++,testcase,committed] Add SFINAE testcase

Message ID 51C78700.7020509@oracle.com
State New
Headers show

Commit Message

Paolo Carlini June 23, 2013, 11:38 p.m. UTC
Hi,

I added to mainline the testcase in Comment 16 of PR51213.

Thanks,
Paolo.

/////////////////////
2013-06-23  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/cpp0x/sfinae47.C: New.
diff mbox

Patch

Index: g++.dg/cpp0x/sfinae47.C
===================================================================
--- g++.dg/cpp0x/sfinae47.C	(revision 0)
+++ g++.dg/cpp0x/sfinae47.C	(working copy)
@@ -0,0 +1,25 @@ 
+// Source: Comment 16 of PR51213
+// { dg-do compile { target c++11 } }
+
+template <class T>
+T && declval();
+
+template <class T>
+constexpr auto hasSize(int) -> decltype(declval<T&>().size(), bool())
+{ return true; }
+
+template <class T>
+constexpr bool hasSize(...)
+{ return false; }
+
+struct A
+{
+  int size();
+};
+
+struct B : private A
+{
+};
+
+static_assert(hasSize<A>(0),  "A");
+static_assert(!hasSize<B>(0), "B");