example_nonascii_name.cpp
Go to the documentation of this file.
1 // Licensed under the MIT License <http://opensource.org/licenses/MIT>.
2 // SPDX-License-Identifier: MIT
3 // Copyright (c) 2020 - 2024 Daniil Goncharov <neargye@gmail.com>.
4 // Copyright (c) 2020 - 2023 Uruha Komachin <uruhakomachin@gmail.com>.
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in all
14 // copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 // SOFTWARE.
23 
24 #include <iostream>
25 
27 
28 enum class Language : int {
29  日本語 = 10,
30  한국어 = 20,
31  English = 30,
32  😃 = 40,
33 };
34 
35 int main() {
36  std::cout << magic_enum::enum_name(Language::日本語) << std::endl; // Japanese
37  std::cout << magic_enum::enum_name(Language::한국어) << std::endl; // Korean
38  std::cout << magic_enum::enum_name(Language::English) << std::endl; // English
39  std::cout << magic_enum::enum_name(Language::😃) << std::endl; // Emoji
40 
41  std::cout << std::boolalpha;
42  std::cout << (magic_enum::enum_cast<Language>("日本語").value() == Language::日本語) << std::endl; // true
43 
44  return 0;
45 }
magic_enum.hpp
Language::日本語
@ 日本語
Language::한국어
@ 한국어
Language::😃
@ 😃
main
int main()
Definition: example_nonascii_name.cpp:35
Catch::cout
std::ostream & cout()
magic_enum::enum_name
constexpr auto enum_name() noexcept -> detail::enable_if_t< decltype(V), string_view >
Definition: magic_enum.hpp:1290
Language
Language
Definition: example_nonascii_name.cpp:28
Language::English
@ English


magic_enum
Author(s):
autogenerated on Fri Feb 21 2025 03:20:18