-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCpp.cpp
More file actions
140 lines (107 loc) · 3.14 KB
/
Cpp.cpp
File metadata and controls
140 lines (107 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/**
* \file Cpp.cpp
* \brief Test C++ syntax for IDEs
*
* \see VSCode - https://code.visualstudio.com/docs/cpp/colorization-cpp
*
* \todo
*/
//--------------------------------------------------------------------------------------------------
// PP
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpessimizing-move"
// Impl - std::move
#pragma GCC diagnostic pop
#include <StdStream/StdStream.h>
#include <StdTest/StdTest.h>
#include <Stl.h>
#define PP_VAR "pp_test"
#define PP_VAR_2(x) PP_VAR "_" x
#define PP_OPERATOR_SS(x) x
//--------------------------------------------------------------------------------------------------
using namespace std::literals::string_view_literals; // Enables the sv suffix
namespace my
{
int varNamespace {5};
}
using namespace my;
bool globalVar {false};
//--------------------------------------------------------------------------------------------------
class SyntaxCpp
{
public:
enum class Type
{
No = 0,
Yes = 1
};
static const int op = PP_OPERATOR_SS(7);
SyntaxCpp() = default;
~SyntaxCpp() = default;
std::string_view get() const;
bool fooMethod(const bool isDebug) const;
static int fooMethodStatic(bool &isDebug);
private:
Type _type {Type::No};
int _member {0};
static int _memberStatic;
};
//--------------------------------------------------------------------------------------------------
int SyntaxCpp::_memberStatic {-1};
//--------------------------------------------------------------------------------------------------
std::string_view
SyntaxCpp::get() const
{
return "[SyntaxCpp]"sv;
}
//--------------------------------------------------------------------------------------------------
bool
SyntaxCpp::fooMethod(
const bool a_isDebug ///< [in]
) const
{
return a_isDebug ? false : true;
}
//--------------------------------------------------------------------------------------------------
/* static */
int
SyntaxCpp::fooMethodStatic(
bool &out_isDebug ///< [out]
)
{
// [out]
out_isDebug = false;
return out_isDebug ? 0 : _memberStatic;
}
//--------------------------------------------------------------------------------------------------
inline std::ostream &
operator << (
std::ostream &out_os,
const SyntaxCpp &a_value
)
{
out_os << a_value.get();
return out_os;
}
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
int main(int, char **)
{
// PP
{
STD_TRACE_FUNC;
std::cout << STD_TRACE_VAR(PP_VAR) << std::endl;
std::string str = PP_VAR_2("2");
std::cout << STD_TRACE_VAR(str) << std::endl;
}
std::cout << STD_TRACE_VAR(my::varNamespace) << std::endl;
std::cout << STD_TRACE_VAR(::globalVar) << std::endl;
SyntaxCpp syntax;
syntax.fooMethod(::globalVar);
syntax.fooMethodStatic(::globalVar);
std::cout << "SyntaxCpp: " << syntax << std::endl;
return EXIT_SUCCESS;
}
//--------------------------------------------------------------------------------------------------
#if OUTPUT
#endif