Skip to content

Commit 421a842

Browse files
committed
is(): made is() compile-time when possible
1 parent 5e30d99 commit 421a842

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

include/cpp2util.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -1602,13 +1602,13 @@ constexpr auto is( X&& ) {
16021602
// Types
16031603
//
16041604
template< typename C, typename X >
1605-
auto is( X const& x ) -> bool {
1605+
constexpr auto is( X const& x ) -> auto {
16061606
if constexpr (
16071607
std::is_same_v<C, X>
16081608
|| std::is_base_of_v<C, X>
16091609
)
16101610
{
1611-
return true;
1611+
return std::true_type{};
16121612
}
16131613
else if constexpr (
16141614
std::is_polymorphic_v<C>
@@ -1633,12 +1633,12 @@ auto is( X const& x ) -> bool {
16331633
)
16341634
{
16351635
if (x != nullptr) {
1636-
return is<std::remove_pointer_t<C>>(*x);
1636+
return bool{is<std::remove_pointer_t<C>>(*x)};
16371637
}
16381638
return false;
16391639
}
16401640
else {
1641-
return false;
1641+
return std::false_type{};
16421642
}
16431643
}
16441644

0 commit comments

Comments
 (0)