mirror of
https://github.com/aantron/better-enums.git
synced 2025-12-06 16:56:42 +08:00
Simplified README.
This commit is contained in:
parent
2d6b337419
commit
18cbeb0808
21
README.md
21
README.md
@ -35,20 +35,17 @@ See the [project page][project] for full documentation.
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Simply add `enum.h` to your project — that's it.
|
Simply add `enum.h` to your project.
|
||||||
|
|
||||||
Then, include it, and use the `BETTER_ENUM` macro. Your compiler will generate
|
|
||||||
the rich enums that are missing from standard C++.
|
|
||||||
|
|
||||||
## Additional features
|
## Additional features
|
||||||
|
|
||||||
- No dependencies and no external build tools. Uses only standard C++, though,
|
- Uses only standard C++, though, for C++98, variadic macro support is required
|
||||||
for C++98, variadic macro support is required.
|
(major compilers have it).
|
||||||
- Supported and tested on [clang, gcc, and msvc][testing].
|
- Supported and tested on [clang, gcc, and msvc][testing].
|
||||||
- Fast compilation. You have to declare a few dozen enums to slow down your
|
- Fast compilation. You have to declare a few dozen enums to slow down your
|
||||||
compiler as much as [just including `iostream` does][performance].
|
compiler as much as [only including `iostream` does][performance].
|
||||||
- Use any initializers and sparse ranges, just like with a built-in enum.
|
- Use any initializers and sparse ranges, just like with a built-in enum.
|
||||||
- Guaranteed size and alignment — you choose the representation type.
|
- Control over size and alignment — you choose the representation type.
|
||||||
- Stream operators.
|
- Stream operators.
|
||||||
- Does not use the heap and can be compiled with exceptions disabled, for use in
|
- Does not use the heap and can be compiled with exceptions disabled, for use in
|
||||||
minimal freestanding environments.
|
minimal freestanding environments.
|
||||||
@ -62,12 +59,12 @@ The biggest limitation is that the `BETTER_ENUM` macro can't be used inside a
|
|||||||
class. This seems [difficult to remove][nested]. There is a workaround with
|
class. This seems [difficult to remove][nested]. There is a workaround with
|
||||||
`typedef` (or C++11 `using`):
|
`typedef` (or C++11 `using`):
|
||||||
|
|
||||||
```cpp
|
```
|
||||||
BETTER_ENUM(UniquePrefix_Color, uint8_t, Red, Green, Blue)
|
BETTER_ENUM(SomePrefix_Color, uint8_t, Red, Green, Blue)
|
||||||
|
|
||||||
struct triplet {
|
struct triplet {
|
||||||
typedef UniquePrefix_Color Color;
|
typedef SomePrefix_Color Color;
|
||||||
Color r, g, b;
|
Color r, g, b;
|
||||||
};
|
};
|
||||||
|
|
||||||
triplet::Color color;
|
triplet::Color color;
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 79 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 8.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 10 KiB |
Loading…
x
Reference in New Issue
Block a user