Repository navigation
Replies: 1 comment 1 reply
#include <iostream>
#include <vector>
#include <iguana/field_reflection.hpp>
enum class FtEnum {
enum_0 = 0,
enum_1 = 1,
enum_2 = 2,
enum_3 = 3,
enum_4 = 4,
enum_5 = 5,
enum_6 = 6,
enum_7 = 7,
};
template <std::size_t N>
constexpr std::array<int, N> create_array() {
std::array<int, N> arr{};
for (std::size_t i = 0; i < N; ++i) { arr[i] = i; }
return arr;
}
template <>
struct iguana::enum_value<FtEnum> {
constexpr static size_t N = 8;
constexpr static std::array<int, N> value = create_array<N>();
};
int main(int argc, char** argv) {
static auto str_to_enum = iguana::get_enum_map<true, FtEnum>();
for (const auto& [key, value] : str_to_enum) {
auto strkey = std::string_view(key.data(), key.size());
auto intval = static_cast<int>(value);
std::cout << strkey << ": " << intval << std::endl;
}
std::cout << "main done!" << std::endl;
return 0;
}
|
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
https://github.com/qicosmos/iguana/blob/master/test/test_xml.cpp#L555
All reactions