nameof_module/doc/limitations.md

69 lines
3.4 KiB
Markdown
Raw Permalink Normal View History

2020-01-25 18:45:33 +00:00
# Limitations
## Nameof
2019-10-03 13:25:50 +00:00
* If the argument does not have a name, the compilation error `"Expression does not have a name."` occurs.
2019-10-03 13:25:50 +00:00
2020-01-25 18:45:33 +00:00
## Nameof Type
2019-10-03 13:25:50 +00:00
2022-11-08 09:01:28 +00:00
* This library uses a compiler-specific hack (based on `__PRETTY_FUNCTION__` / `__FUNCSIG__`).
2019-10-03 13:25:50 +00:00
* nameof_type and nameof_type_rtti return a compiler-specific type name.
2019-10-03 13:25:50 +00:00
* To check if nameof_type is supported by your compiler use the macro `NAMEOF_TYPE_SUPPORTED` or constexpr constant `nameof::is_nameof_type_supported`.</br>
If nameof_type is used on an unsupported compiler, a compilation error occurs. To suppress the error define the macro `NAMEOF_TYPE_NO_CHECK_SUPPORT`.
2019-10-03 13:25:50 +00:00
* To check if nameof_type_rtti is supported by your compiler use macro `NAMEOF_TYPE_RTTI_SUPPORTED` or constexpr constant `nameof::is_nameof_type_rtti_supported`.</br>
If nameof_type_rtti is used on an unsupported compiler, a compilation error occurs. To suppress the error define the macro `NAMEOF_TYPE_NO_CHECK_SUPPORT`.
2020-09-07 17:12:54 +00:00
2023-03-30 15:10:22 +00:00
* To check is nameof_member supported compiler use macro `NAMEOF_MEMBER_SUPPORTED` or constexpr constant `nameof::is_nameof_member_supported`.</br>
If nameof_member used on unsupported compiler, occurs the compilation error. To suppress error define macro `NAMEOF_TYPE_NO_CHECK_SUPPORT`.
* To check is nameof_pointer supported compiler use macro `NAMEOF_POINTER_SUPPORTED` or constexpr constant `nameof::is_nameof_pointer_supported`.</br>
If nameof_pointer used on unsupported compiler, occurs the compilation error. To suppress error define macro `NAMEOF_TYPE_NO_CHECK_SUPPORT`.
2020-12-29 18:45:54 +00:00
## Nameof Enum
2019-10-03 13:30:48 +00:00
2019-10-03 13:25:50 +00:00
* This library uses a compiler-specific hack (based on `__PRETTY_FUNCTION__` / `__FUNCSIG__`), which works on Clang >= 5, MSVC >= 15.3 and GCC >= 9.
2020-12-29 18:45:54 +00:00
* Do not use [nameof](https://github.com/Neargye/nameof) and [magic_enum](https://github.com/Neargye/magic_enum) in the same project to get enum name.
* To check if nameof_enum is supported by your compiler use the macro `NAMEOF_ENUM_SUPPORTED` or constexpr constant `nameof::is_nameof_enum_supported`.</br>
If nameof_enum is used on an unsupported compiler, a compilation error occurs. To suppress the error define the macro `NAMEOF_ENUM_NO_CHECK_SUPPORT`.
2019-10-03 13:25:50 +00:00
2020-01-25 18:45:33 +00:00
* Enum value must be in range `[NAMEOF_ENUM_RANGE_MIN, NAMEOF_ENUM_RANGE_MAX]`.
2019-10-03 13:25:50 +00:00
2020-01-25 18:45:33 +00:00
* By default `NAMEOF_ENUM_RANGE_MIN = -128`, `NAMEOF_ENUM_RANGE_MAX = 128`.
2019-10-03 13:25:50 +00:00
* `NAMEOF_ENUM_RANGE_MIN` must be less than or equal to `0` and must be greater than `INT16_MIN`.
2019-10-03 13:25:50 +00:00
2020-01-25 18:45:33 +00:00
* `NAMEOF_ENUM_RANGE_MAX` must be greater than `0` and must be less than `INT16_MAX`.
2019-10-03 13:25:50 +00:00
* If another range is needed for all enum types by default, redefine the macro `NAMEOF_ENUM_RANGE_MIN` and `NAMEOF_ENUM_RANGE_MAX`.
2020-01-25 18:45:33 +00:00
```cpp
#define NAMEOF_ENUM_RANGE_MIN 0
#define NAMEOF_ENUM_RANGE_MAX 256
#include <nameof.hpp>
```
* If another range is needed for a specific enum type, add specialization `enum_range` for necessary enum type. Specialization of `enum_range` must be injected in `namespace nameof::customize`.
2020-01-25 18:45:33 +00:00
```cpp
#include <nameof.hpp>
2020-02-14 13:04:48 +00:00
enum class number { one = 100, two = 200, three = 300 };
2020-01-25 18:45:33 +00:00
template <>
2020-12-29 18:45:54 +00:00
struct nameof::customize::enum_range<number> {
2020-01-25 18:45:33 +00:00
static constexpr int min = 100;
static constexpr int max = 300;
};
```
* Won't work if a value is aliased, support for enum-aliases is compiler-implementation-defined.
2020-12-29 18:45:54 +00:00
* Won't work if the enum is a forward declaration.
2020-05-12 08:48:55 +00:00
* Intellisense Visual Studio may have some problems analyzing `nameof`.