1#include <tuple>
2
3template <int Arg>
4class TestObj
5{
6public:
7 int getArg()
8 {
9 return Arg;
10 }
11};
12
13//----------------------------------------------------------------------
14// Define a template class that we can specialize with an enumeration
15//----------------------------------------------------------------------
16enum class EnumType
17{
18 Member,
19 Subclass
20};
21
22template <EnumType Arg> class EnumTemplate;
23
24//----------------------------------------------------------------------
25// Specialization for use when "Arg" is "EnumType::Member"
26//----------------------------------------------------------------------
27template <>
28class EnumTemplate<EnumType::Member>
29{
30public:
31 EnumTemplate(int m) :
32 m_member(m)
33 {
34 }
35
36 int getMember() const
37 {
38 return m_member;
39 }
40
41protected:
42 int m_member;
43};
44
45//----------------------------------------------------------------------
46// Specialization for use when "Arg" is "EnumType::Subclass"
47//----------------------------------------------------------------------
48template <>
49class EnumTemplate<EnumType::Subclass> :
50 public EnumTemplate<EnumType::Member>
51{
52public:
53 EnumTemplate(int m) : EnumTemplate<EnumType::Member>(m)
54 {
55 }
56};
57
58template <typename FLOAT> struct T1 { FLOAT f = 1.5; };
59template <typename FLOAT> struct T2 { FLOAT f = 2.5; int i = 42; };
60template <typename FLOAT, template <typename> class ...Args> class C { std::tuple<Args<FLOAT>...> V; };
61
62int main(int argc, char **argv)
63{
64 TestObj<1> testpos;
65 TestObj<-1> testneg;
66 EnumTemplate<EnumType::Member> member(123);
67 EnumTemplate<EnumType::Subclass> subclass(123*2);
68 C<float, T1> c1;
69 C<double, T1, T2> c2;
70 return testpos.getArg() - testneg.getArg() + member.getMember()*2 - subclass.getMember(); // Breakpoint 1
71}
72

source code of lldb/test/API/lang/cpp/template/main.cpp