formating test_package.cpp
This commit is contained in:
parent
b5a158d0d2
commit
4c5b75e56e
1 changed files with 7 additions and 7 deletions
|
@ -5,23 +5,23 @@
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
struct SomeStruct {};
|
struct SomeStruct {};
|
||||||
enum class Color { RED = -12, GREEN = 7, BLUE = 15 };
|
|
||||||
|
|
||||||
SomeStruct structvar;
|
SomeStruct structvar;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
// Compile-time.
|
// Compile-time.
|
||||||
constexpr auto name = NAMEOF(structvar);
|
constexpr auto name = NAMEOF(structvar);
|
||||||
static_assert("structvar" == name);
|
static_assert("structvar" == name);
|
||||||
|
|
||||||
// Nameof.
|
// Nameof.
|
||||||
using std::literals::string_view_literals::operator""sv;
|
|
||||||
|
|
||||||
std::string_view res1 = NAMEOF(structvar);
|
std::string_view res1 = NAMEOF(structvar);
|
||||||
std::string_view res2 = NAMEOF(::structvar);
|
std::string_view res2 = NAMEOF(::structvar);
|
||||||
|
|
||||||
std::cout << res1 << '\n' << res2 << '\n';
|
std::cout << res1 << '\n' << res2 << '\n';
|
||||||
|
|
||||||
bool success = res1 == "structvar"sv
|
using std::literals::string_view_literals::operator""sv;
|
||||||
&& res2 == "structvar"sv;
|
|
||||||
|
bool success = (res1 == "structvar"sv) && (res2 == "structvar"sv);
|
||||||
|
|
||||||
return success ? EXIT_SUCCESS : EXIT_FAILURE;
|
return success ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue