Skip to content

Commit d461a50

Browse files
committed
is(): made is() compile-time when possible
1 parent 50c848c commit d461a50

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
@@ -1629,13 +1629,13 @@ constexpr auto is( X&& ) {
16291629
// Types
16301630
//
16311631
template< typename C, typename X >
1632-
auto is( X const& x ) -> bool {
1632+
constexpr auto is( X const& x ) -> auto {
16331633
if constexpr (
16341634
std::is_same_v<C, X>
16351635
|| std::is_base_of_v<C, X>
16361636
)
16371637
{
1638-
return true;
1638+
return std::true_type{};
16391639
}
16401640
else if constexpr (
16411641
std::is_polymorphic_v<C>
@@ -1660,12 +1660,12 @@ auto is( X const& x ) -> bool {
16601660
)
16611661
{
16621662
if (x != nullptr) {
1663-
return is<std::remove_pointer_t<C>>(*x);
1663+
return bool{is<std::remove_pointer_t<C>>(*x)};
16641664
}
16651665
return false;
16661666
}
16671667
else {
1668-
return false;
1668+
return std::false_type{};
16691669
}
16701670
}
16711671

0 commit comments

Comments
 (0)