-
Notifications
You must be signed in to change notification settings - Fork 506
Closed
Milestone
Description
Hi,
The following code fails with both static assertion indicating that enum_fuse does not work as expected:
If you uncomment the assertions you see that both value1 and value2 evaluate to 4;
Expected behavior: enum_fuse generates distinct values for every combination of input parameters
Actual behavior: enum_fuse sometimes returns the identical values
Seen on latest master and on v0.9.6
https://godbolt.org/z/PP5v76Pdq
#include <iostream>
#include "magic_enum.hpp"
#include "magic_enum_fuse.hpp"
enum class Continent
{
EUROPE,
ASIA,
AFRICA,
AMERICA,
AUSTRALIA,
};
enum class Color
{
RED,
GREEN,
};
static_assert(magic_enum::enum_fuse(Continent::AUSTRALIA, Continent::EUROPE).value() !=
magic_enum::enum_fuse(Continent::EUROPE, Continent::ASIA).value());
static_assert(magic_enum::enum_fuse(Continent::AUSTRALIA, Color::RED).value() !=
magic_enum::enum_fuse(Continent::EUROPE, Color::GREEN).value());
int main() {
auto value1 = magic_enum::enum_integer(magic_enum::enum_fuse(Continent::AUSTRALIA, Color::RED).value());
auto value2 = magic_enum::enum_integer(magic_enum::enum_fuse(Continent::EUROPE, Color::GREEN).value());
std::cout << "value1: " << value1 << std::endl;
std::cout << "value2: " << value2 << std::endl;
return 0;
}
CMakeLists.txt for minimal example
cmake_minimum_required(VERSION 3.14)
project(MagicEnumExample)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
include(FetchContent)
FetchContent_Declare(
magic_enum
GIT_REPOSITORY https://github.com/Neargye/magic_enum.git
GIT_TAG master
)
FetchContent_MakeAvailable(magic_enum)
include_directories(${magic_enum_SOURCE_DIR}/include/magic_enum)
add_executable(MagicEnumExample main.cpp)
target_link_libraries(MagicEnumExample PRIVATE magic_enum::magic_enum)
Metadata
Metadata
Assignees
Labels
No labels