Skip to content

Move magic enum to local and avoid allocation#144

Merged
mrts merged 1 commit into
mainfrom
magic_enum
Jul 6, 2026
Merged

Move magic enum to local and avoid allocation#144
mrts merged 1 commit into
mainfrom
magic_enum

Conversation

@metsma

@metsma metsma commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

WE2-1204

Signed-off-by: Raul Metsma raul@metsma.ee

Comment thread lib/libpcsc-cpp/include/pcsc-cpp/pcsc-cpp-utils.hpp
Comment thread include/electronic-id/enums.hpp Outdated
Comment thread include/electronic-id/enums.hpp
@metsma metsma force-pushed the magic_enum branch 4 times, most recently from 53d4a5a to 18cf0a9 Compare July 5, 2026 19:52
Comment thread include/electronic-id/enums.hpp Outdated
default:
throw std::logic_error("JsonWebSignatureAlgorithm::hashAlgorithm(): Invalid value "
+ std::to_string(value));
std::unreachable();

@mrts mrts Jul 6, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think std::unreachable() is justified as it causes a segmentation fault. The optimization is insignificant compared to the cost, let's keep it defensive and revert to using an exception and remove noexcept even if the constructor validates values today. I'll undo these changes for now, we can discuss this further when your'e back from vacation.

@metsma metsma Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point, but I disagree in this case. The constructor already validates the values, so this path should not be reachable.

The std::unreachable() is mainly there because compiler support (gcc) for exhaustive enum switch handling is limited, and adding a default case can hide missing enum cases in the future.

Comment thread lib/libpcsc-cpp/CMakeLists.txt Outdated
target_compile_features(${PROJECT_NAME}
PUBLIC
cxx_std_20
cxx_std_23

@mrts mrts Jul 6, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to use cxx_std_23 when we drop std::unreachable(). I'll undo this for now.

WE2-1204, WE2-1057

Signed-off-by: Raul Metsma <raul@metsma.ee>
@mrts mrts merged commit 845a7f5 into main Jul 6, 2026
16 checks passed
@mrts mrts deleted the magic_enum branch July 6, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants