Skip to content

Commit b2a4714

Browse files
committed
Add is() matchers for templates
1 parent bef05a9 commit b2a4714

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

include/cpp2util.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,33 @@ static std::nullptr_t nonesuch = nullptr;
574574
// TODO: Does this really warrant a new synonym? Perhaps "is void" is enough
575575
using empty = void;
576576

577+
template <template <typename...> class C, typename... Ts>
578+
constexpr auto is(C< Ts...> const& ) -> bool {
579+
return true;
580+
}
581+
582+
#if defined(_MSC_VER)
583+
template <template <typename, typename...> class C, typename T>
584+
constexpr auto is( T const& ) -> bool {
585+
return false;
586+
}
587+
#else
588+
template <template <typename...> class C, typename T>
589+
constexpr auto is( T const& ) -> bool {
590+
return false;
591+
}
592+
#endif
593+
594+
template <template <typename,auto> class C, typename T, auto V>
595+
constexpr auto is( C<T, V> const& ) -> bool {
596+
return true;
597+
}
598+
599+
template <template <typename,auto> class C, typename T>
600+
constexpr auto is( T const& ) -> bool {
601+
return false;
602+
}
603+
577604
template< typename C, typename X >
578605
auto is( X const& ) -> bool {
579606
return false;

0 commit comments

Comments
 (0)