feat(utility): add bind_front for enum_switch partial application (#200) - #471
Open
ezralicodes wants to merge 4 commits into
Open
feat(utility): add bind_front for enum_switch partial application (#200)#471ezralicodes wants to merge 4 commits into
ezralicodes wants to merge 4 commits into
Conversation
…argye#200) Signed-off-by: ezralicodes <ezralicodes@users.noreply.github.com>
…argye#200) Signed-off-by: ezralicodes <ezralicodes@users.noreply.github.com>
…argye#200) Signed-off-by: ezralicodes <ezralicodes@users.noreply.github.com>
…argye#200) Signed-off-by: ezralicodes <ezralicodes@users.noreply.github.com>
Neargye
reviewed
Aug 15, 2026
|
|
||
| * Zero is not reflected for flag enums. | ||
|
|
||
| * GCC 16 with `-std=c++26` may miscompile string parsing that uses `find`/`remove_prefix` on flag names. `enum_flags_cast` uses an explicit token loop instead; see [#467](https://github.com/Neargye/magic_enum/issues/467). |
Owner
There was a problem hiding this comment.
This was never required and should be removed; internal documentation remains in the comments.
Neargye
reviewed
Aug 15, 2026
| } | ||
| } | ||
|
|
||
| TEST_CASE("bind_front") { |
Owner
|
Please also export |
Neargye
reviewed
Aug 15, 2026
| constexpr decltype(auto) operator()(CallArgs&&... call_args) const { | ||
| return std::apply( | ||
| fn_, | ||
| std::tuple_cat(bound_, |
Owner
There was a problem hiding this comment.
Please avoid tuple_cat here: it copies bound arguments into a temporary and breaks mutable callables, lvalue references, move-only values, and reference returns. Invoke the stored arguments directly via std::get, preserving the wrapper value category with &, const&, &&, and const&& overloads.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
magic_enum::bind_fronttomagic_enum_utility.hppas a C++17-friendly partial-application helper. Maintainer suggested this for nestedenum_switchuse cases on MSVC (#200).Also documents the GCC 16 C++26
enum_flags_castworkaround (#467).Test plan
bind_frontcase intest/test.cpp