Skip to content

Commit ec3bec2

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

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

include/cpp2util.h

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

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

552560
//-------------------------------------------------------------------------------------------------------------
553561
// Built-in as (partial)

0 commit comments

Comments
 (0)