mirror of
https://github.com/Neargye/magic_enum.git
synced 2026-01-09 23:34:23 +00:00
add support big range (#268)
* add support big range * remove string_view from n() * fix containers
This commit is contained in:
parent
4c54c094ea
commit
629f7b09af
10 changed files with 601 additions and 784 deletions
|
|
@ -1,27 +0,0 @@
|
|||
load("@rules_cc//cc:defs.bzl", "cc_binary")
|
||||
load("@magic_enum//bazel:copts.bzl", "COPTS")
|
||||
|
||||
_EXAMPLES = [
|
||||
"enum_flag_example",
|
||||
"example",
|
||||
#"example_containers_array", TODO
|
||||
#"example_containers_bitset", TODO
|
||||
#"example_containers_set", TODO
|
||||
"example_custom_name",
|
||||
"example_switch",
|
||||
]
|
||||
|
||||
[cc_binary(
|
||||
name = example,
|
||||
srcs = ["{}.cpp".format(example)],
|
||||
deps = ["@magic_enum"],
|
||||
copts = COPTS,
|
||||
) for example in _EXAMPLES]
|
||||
|
||||
cc_binary(
|
||||
name = "example_nonascii_name",
|
||||
srcs = ["example_nonascii_name.cpp"],
|
||||
deps = ["@magic_enum"],
|
||||
copts = COPTS,
|
||||
tags = ["manual"],
|
||||
)
|
||||
|
|
@ -20,9 +20,9 @@ endfunction()
|
|||
|
||||
make_example(example)
|
||||
make_example(enum_flag_example)
|
||||
#make_example(example_containers_array) TODO
|
||||
#make_example(example_containers_bitset) TODO
|
||||
#make_example(example_containers_set) TODO
|
||||
make_example(example_containers_array)
|
||||
make_example(example_containers_bitset)
|
||||
make_example(example_containers_set)
|
||||
make_example(example_custom_name)
|
||||
make_example(example_switch)
|
||||
if(MAGIC_ENUM_OPT_ENABLE_NONASCII)
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@
|
|||
#include <magic_enum_containers.hpp>
|
||||
|
||||
enum class Color { RED = 1, GREEN = 2, BLUE = 4 };
|
||||
template <>
|
||||
struct magic_enum::customize::enum_range<Color> {
|
||||
static constexpr bool is_flags = true;
|
||||
};
|
||||
|
||||
struct RGB {
|
||||
|
||||
|
|
@ -37,7 +41,6 @@ struct RGB {
|
|||
[[nodiscard]] constexpr bool operator==(RGB rgb) const noexcept { return std::equal_to{}(r, rgb.r) && std::equal_to{}(g, rgb.g) && std::equal_to{}(b, rgb.b); }
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& ostream, RGB rgb) {
|
||||
|
||||
ostream << "R=" << static_cast<std::uint32_t>(rgb.r) << " G=" << static_cast<std::uint32_t>(rgb.g) << " B=" << static_cast<std::uint32_t>(rgb.b);
|
||||
return ostream;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,10 @@
|
|||
#include <magic_enum_containers.hpp>
|
||||
|
||||
enum class Color { RED = 1, GREEN = 2, BLUE = 4 };
|
||||
template <>
|
||||
struct magic_enum::customize::enum_range<Color> {
|
||||
static constexpr bool is_flags = true;
|
||||
};
|
||||
|
||||
int main() {
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,10 @@
|
|||
#include <magic_enum_containers.hpp>
|
||||
|
||||
enum class Color { RED = 1, GREEN = 2, BLUE = 4 };
|
||||
template <>
|
||||
struct magic_enum::customize::enum_range<Color> {
|
||||
static constexpr bool is_flags = true;
|
||||
};
|
||||
|
||||
int main() {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue