Skip to content

Commit 6af7b2e

Browse files
committed
Add missing overload for is function to handle enums
1 parent fd0c99d commit 6af7b2e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

include/cpp2util.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,15 @@ auto is( X const& x ) -> bool {
548548
return x == X();
549549
}
550550

551+
template< auto value, typename X >
552+
requires std::is_enum_v<decltype(value)> && std::is_enum_v<X>
553+
auto is( X const& x ) -> bool {
554+
if constexpr (std::is_same_v<decltype(value),X>) {
555+
return x == value;
556+
} else {
557+
return false;
558+
}
559+
}
551560

552561
//-------------------------------------------------------------------------------------------------------------
553562
// Built-in as (partial)

0 commit comments

Comments
 (0)