Debian Codegraph @

cmake/cxx_tests/template_qualified_base_class.cpp

raw
1 // DESCRIPTION
2 //
3 // Test to check whether the compiler supports template-qualified base class specifiers.
4 // In sync with AC_CXX_TEMPLATE_QUALIFIED_BASE_CLASS (2008-04-12).
5 //
6 // COPYLEFT
7 //
8 // Copyright (c) 2008 Todd Veldhuizen
9 // Copyright (c) 2009 Theo Papadopoulo <[email protected]>
10 // Copyright (c) 2008 Luc Maisonobe <[email protected]>
11 //
12 // Copying and distribution of this file, with or without modification, are
13 // permitted in any medium without royalty provided the copyright notice
14 // and this notice are preserved.
15
16 #ifndef HAVE_TYPENAME
17 #define typename
18 #endif
19
20 class Base1 { public : int f () const { return 1; } };
21 class Base2 { public : int f () const { return 0; } };
22
23 template<class X> struct base_trait { typedef Base1 base; };
24
25 #ifdef HAVE_FULL_SPECIALIZATION_SYNTAX
26 template<> struct base_trait<float> { typedef Base2 base; };
27 #else
28 struct base_trait<float> { typedef Base2 base; };
29 #endif
30
31 template<class T>
32 class Weird: public base_trait<T>::base {
33 public :
34 typedef typename base_trait<T>::base base;
35 int g () const { return base::f (); }
36 };
37
38 int main() {
39 Weird<float> z;
40 return z.g();
41 }