mirror of
https://github.com/AnthonyCalandra/modern-cpp-features.git
synced 2025-12-17 10:04:35 +03:00
Direct list initialization of enums.
This commit is contained in:
11
README.md
11
README.md
@@ -16,6 +16,7 @@ C++17 includes the following new language features:
|
|||||||
- [selection statements with initializer](#selection-statements-with-initializer)
|
- [selection statements with initializer](#selection-statements-with-initializer)
|
||||||
- [constexpr if](#constexpr-if)
|
- [constexpr if](#constexpr-if)
|
||||||
- [utf-8 character literals](#utf-8-character-literals)
|
- [utf-8 character literals](#utf-8-character-literals)
|
||||||
|
- [direct-list-initialization of enums](#direct-list-initialization-of-enums)
|
||||||
|
|
||||||
C++17 includes the following new library features:
|
C++17 includes the following new library features:
|
||||||
- [std::variant](#stdvariant)
|
- [std::variant](#stdvariant)
|
||||||
@@ -266,6 +267,16 @@ A character literal that begins with `u8` is a character literal of type `char`.
|
|||||||
char x = u8'x';
|
char x = u8'x';
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Direct List Initialization of Enums
|
||||||
|
Enums can now be initialized using braced syntax.
|
||||||
|
```c++
|
||||||
|
enum byte : unsigned char {};
|
||||||
|
byte b{0}; // OK
|
||||||
|
byte c{-1}; // ERROR
|
||||||
|
byte d = byte{1}; // OK
|
||||||
|
byte e = byte{256}; // ERROR
|
||||||
|
```
|
||||||
|
|
||||||
## C++17 Library Features
|
## C++17 Library Features
|
||||||
|
|
||||||
### std::variant
|
### std::variant
|
||||||
|
|||||||
Reference in New Issue
Block a user