File tree 1 file changed +25
-0
lines changed 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -785,6 +785,31 @@ constexpr auto as( std::variant<Ts...> const& x ) {
785
785
throw std::bad_variant_access ();
786
786
}
787
787
788
+ template < auto value, typename ... Ts >
789
+ constexpr auto is_impl ( std::variant<Ts...> const & v ) -> bool {
790
+ if (v.valueless_by_exception ()) return false ;
791
+ // Need to guard this with is_any otherwise the holds_alternative is illegal
792
+ if constexpr (is_any<std::monostate, Ts...>) if (std::holds_alternative<std::monostate>(v)) return false ;
793
+
794
+ return std::visit ([](auto && arg) -> bool {
795
+ return cpp2::is<value>(CPP2_FORWARD (arg));
796
+ }, v);
797
+ }
798
+
799
+ template < auto value, typename ... Ts >
800
+ constexpr auto is ( std::variant<Ts...> const & v ) -> bool {
801
+ return cpp2::is_impl<value>(v);
802
+ }
803
+
804
+ template < cstring_wrapper value, typename ... Ts >
805
+ constexpr auto is ( std::variant<Ts...> const & v ) -> bool {
806
+ return cpp2::is_impl<value>(v);
807
+ }
808
+
809
+ template < double_wrapper value, typename ... Ts >
810
+ constexpr auto is ( std::variant<Ts...> const & v ) -> bool {
811
+ return cpp2::is_impl<value>(v);
812
+ }
788
813
789
814
// -------------------------------------------------------------------------------------------------------------
790
815
// std::any is and as
You can’t perform that action at this time.
0 commit comments