1 | namespace N0 { |
2 | namespace N1 { |
3 | |
4 | namespace { |
5 | enum Enum { Enum_0 = 1, Enum_1 = 2, Enum_2 = 4, Enum_3 = 8 }; |
6 | enum class ScopedEnum { Enum_0 = 1, Enum_1 = 2, Enum_2 = 4, Enum_3 = 8 }; |
7 | } |
8 | |
9 | Enum Global = Enum_3; |
10 | |
11 | struct Base { |
12 | Enum m_e = Enum_1; |
13 | }; |
14 | |
15 | class Class : public Base { |
16 | public: |
17 | Class(Enum e) : m_ce(e) {} |
18 | |
19 | static int StaticFunc(const Class &c) { |
20 | return c.PrivateFunc(i: c.m_inner) + Global + ClassStatic; |
21 | } |
22 | |
23 | const Enum m_ce; |
24 | |
25 | static int ClassStatic; |
26 | static const int ClassStaticConst = 8; |
27 | static constexpr int ClassStaticConstexpr = 9; |
28 | static constexpr float ClassStaticConstexprFloat = 10.f; |
29 | static constexpr double ClassStaticConstexprDouble = 11.0; |
30 | static constexpr long double ClassStaticConstexprLongDouble = 12.0; |
31 | static const Enum ClassStaticConstEnum = Enum_3; |
32 | static const ScopedEnum ClassStaticConstScopedEnum = ScopedEnum::Enum_2; |
33 | |
34 | private: |
35 | struct Inner { |
36 | char x; |
37 | short y; |
38 | int z; |
39 | }; |
40 | |
41 | int PrivateFunc(const Inner &i) const { return i.z; } |
42 | |
43 | Inner m_inner{}; |
44 | }; |
45 | int Class::ClassStatic = 7; |
46 | |
47 | template<typename T> |
48 | struct Template { |
49 | template<Enum E> |
50 | void TemplateFunc() { |
51 | T::StaticFunc(T(E)); |
52 | } |
53 | }; |
54 | |
55 | void foo() { Template<Class>().TemplateFunc<Enum_0>(); } |
56 | |
57 | } // namespace N1 |
58 | } // namespace N0 |
59 | |
60 | int main() { |
61 | N0::N1::foo(); |
62 | return 0; |
63 | } |
64 | |