Skip to content

Commit afc2b96

Browse files
authored
Merge pull request #14741 from NixOS/better-variant-wrapper
Fix `MAKE_WRAPPER_CONSTRUCTOR` to not override special constructors
2 parents bc0af77 + e73bb66 commit afc2b96

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/libutil/include/nix/util/variant-wrapper.hh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
*
2323
* The moral equivalent of `using Raw::Raw;`
2424
*/
25-
#define MAKE_WRAPPER_CONSTRUCTOR(CLASS_NAME) \
26-
FORCE_DEFAULT_CONSTRUCTORS(CLASS_NAME) \
27-
\
28-
CLASS_NAME(auto &&... arg) \
29-
: raw(std::forward<decltype(arg)>(arg)...) \
30-
{ \
25+
#define MAKE_WRAPPER_CONSTRUCTOR(CLASS_NAME) \
26+
FORCE_DEFAULT_CONSTRUCTORS(CLASS_NAME) \
27+
\
28+
template<typename... Args> \
29+
requires(!(sizeof...(Args) == 1 && (std::is_same_v<std::remove_cvref_t<Args>, CLASS_NAME> && ...))) \
30+
CLASS_NAME(Args &&... arg) \
31+
: raw(std::forward<Args>(arg)...) \
32+
{ \
3133
}

0 commit comments

Comments
 (0)