[C++11] Strongly-typed enums
"Strongly-typed enums"는 C++11 이후에 도입된 기능으로 열거형(enum)의 새로운 형태를 나타낸다. 기존의 C 타입의 enum의 기존적인 문제였던 "암시적 변환", "기본 형식 지정 불가능", 그리고 "scope pollution"에 대한 문제를 해결하게 되었다. #include // Specifying underlying type as `unsigned int` enum class Color : unsigned int { Red = 0xff0000, Green = 0xff00, Blue = 0xff }; // `Red`/`Green` in `Alert` don't conflict with `Color` enum class Alert : bool { Red, Green }; int ..
C++/Modern C++(11, 14, 17, 20)
2023. 8. 26. 15:38