Skip to content

Commit e1ea91b

Browse files
committed
Add is() matchers for templates
1 parent b1754db commit e1ea91b

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
@@ -513,6 +513,33 @@ static std::nullptr_t nonesuch = nullptr;
513513
// TODO: Does this really warrant a new synonym? Perhaps "is void" is enough
514514
using empty = void;
515515

516+
template <template <typename...> class C, typename... Ts>
517+
constexpr auto is(const C<Ts...>&) -> bool {
518+
return true;
519+
}
520+
521+
#if defined(_MSC_VER)
522+
template <template <typename, typename...> class C, typename T>
523+
constexpr auto is(const T&) -> bool {
524+
return false;
525+
}
526+
#else
527+
template <template <typename...> class C, typename T>
528+
constexpr auto is(const T&) -> bool {
529+
return false;
530+
}
531+
#endif
532+
533+
template <template <typename,auto> class C, typename T, auto V>
534+
constexpr auto is(const C<T, V>&) -> bool {
535+
return true;
536+
}
537+
538+
template <template <typename,auto> class C, typename T>
539+
constexpr auto is(const T&) -> bool {
540+
return false;
541+
}
542+
516543
template< typename C, typename X >
517544
auto is( X const& ) -> bool {
518545
return false;

0 commit comments

Comments
 (0)