You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/limitations.md
+12-4Lines changed: 12 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,14 @@
1
1
# Limitations
2
2
3
-
* This library uses a compiler-specific hack based on `__PRETTY_FUNCTION__` / `__FUNCSIG__`.
3
+
* Without standard reflection, this library uses a compiler-specific hack based on `__PRETTY_FUNCTION__` / `__FUNCSIG__`.
4
+
5
+
## C++26 Standard Reflection
6
+
7
+
Standard reflection is selected automatically when available. Otherwise the compiler-specific implementation is used. Keep reflection settings consistent across all translation units and module BMIs.
Define `MAGIC_ENUM_FORCE_COMPILER_SPECIFIC_REFLECTION` before including `magic_enum.hpp` to force the compiler-specific implementation and its `enum_range` scan.
4
12
5
13
* Use `MAGIC_ENUM_SUPPORTED` or `magic_enum::is_magic_enum_supported` to check compiler support. Unsupported compilers cause compilation errors unless `MAGIC_ENUM_NO_CHECK_SUPPORT` is defined.
6
14
@@ -17,13 +25,13 @@
17
25
};
18
26
```
19
27
20
-
* `MAGIC_ENUM_RANGE_MIN` / `MAGIC_ENUM_RANGE_MAX` do not control flag reflection. Flag reflection scans bit positions available in `E`'s underlying type.
28
+
* `MAGIC_ENUM_RANGE_MIN` / `MAGIC_ENUM_RANGE_MAX` do not control flag reflection.
21
29
22
30
* Zero is not reflected for flag enums.
23
31
24
32
## Enum Range
25
33
26
-
* For non-flag enums, range-based reflection only considers values in `[MAGIC_ENUM_RANGE_MIN, MAGIC_ENUM_RANGE_MAX]`.
34
+
* `MAGIC_ENUM_RANGE_MIN` / `MAGIC_ENUM_RANGE_MAX` limit only compiler-specific reflection; standard reflection ignores them.
27
35
28
36
* By default, `MAGIC_ENUM_RANGE_MIN = -128`, `MAGIC_ENUM_RANGE_MAX = 127`.
29
37
@@ -68,7 +76,7 @@
68
76
69
77
## Aliasing
70
78
71
-
magic_enum [cannot reliably distinguish aliased enumerators](https://github.com/Neargye/magic_enum/issues/68). Its behavior with aliases is compiler-dependent.
79
+
Aliased enumerators share one reflected name. Compiler-specific reflection [depends on the compiler](https://github.com/Neargye/magic_enum/issues/68); standard reflection uses the first declaration.
*[`enum_index` returns index from enum value.](#enum_index)
13
13
*[`enum_contains` checks whether enum contains value or name.](#enum_contains)
14
-
*[`enum_reflected` checks whether enum value is in reflection range.](#enum_reflected)
14
+
*[`enum_reflected` checks whether enum value can be reflected.](#enum_reflected)
15
15
*[`enum_type_name` returns enum type name.](#enum_type_name)
16
16
*[`enum_fuse` combines enum values for switch/case statements.](#enum_fuse)
17
17
*[`enum_switch` transforms runtime enum value into constexpr constant.](#enum_switch)
@@ -37,6 +37,8 @@
37
37
38
38
* Use `MAGIC_ENUM_SUPPORTED` or `magic_enum::is_magic_enum_supported` to check compiler support. Unsupported compilers cause compilation errors unless `MAGIC_ENUM_NO_CHECK_SUPPORT` is defined.
39
39
40
+
* C++26 reflection is selected automatically when available. See [limitations](limitations.md#c26-standard-reflection).
41
+
40
42
*`Enum<T>` constrains C++17 function parameters to enum types.
41
43
42
44
* To add custom enum or type names, see [example](../example/example_custom_name.cpp).
@@ -52,6 +54,8 @@
52
54
#include <magic_enum/magic_enum.hpp>
53
55
```
54
56
57
+
The string aliases must have matching `value_type`s. `MAGIC_ENUM_USING_ALIAS_STRING` must name a default- and move-constructible owning string supporting `empty()`, `size()`, `data()`, `reserve()`, `append(count, character)`, and `append(data, size)`; return values are ignored.
58
+
55
59
* To keep configuration in separate header, define `MAGIC_ENUM_CONFIG_FILE`:
56
60
57
61
```cpp
@@ -61,6 +65,8 @@
61
65
62
66
Configuration header can contain these aliases and range macros.
63
67
68
+
* Define all configuration macros consistently before the first magic_enum include in every translation unit andmoduleBMI.
69
+
64
70
## `enum_cast`
65
71
66
72
```cpp
@@ -295,7 +301,7 @@ struct enum_range {
295
301
296
302
* `prefix_length` sets number of characters removed from start of each reflected enumerator name. If omitted, defaults to `0`.
297
303
298
-
* `min` and `max` are optional for non-flag enums and default to `MAGIC_ENUM_RANGE_MIN` / `MAGIC_ENUM_RANGE_MAX`. They are ignored for enum flags.
304
+
* `min` and `max` set compiler-specific scan bounds for non-flag enums. Standard reflection and enum flags ignore them.
299
305
300
306
* `as_flags<>` and `as_common<>` force subtype for individual API calls without changing `enum_range`.
301
307
@@ -340,6 +346,8 @@ struct enum_range {
340
346
}
341
347
```
342
348
349
+
If both an explicit `customize::enum_range<E>` specialization and an ADL `magic_enum_define_range_adl(E)` function are present, the explicit specialization is used and the ADL customization is ignored.
350
+
343
351
For flag enums, add `.flag<true>()`; `.minmax<...>()` is ignored.
*`MAGIC_ENUM_RANGE_MIN` / `MAGIC_ENUM_RANGE_MAX` do not control flag reflection. Flag reflection scans bit positions available in `E`'s underlying type.
606
+
*`MAGIC_ENUM_RANGE_MIN` / `MAGIC_ENUM_RANGE_MAX` do not control flag reflection.
0 commit comments