File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -746,6 +746,31 @@ auto as( std::variant<Ts...> const& x ) {
746
746
throw std::bad_variant_access ();
747
747
}
748
748
749
+ template < auto value, typename ... Ts >
750
+ auto is_impl ( std::variant<Ts...> const & v ) -> bool {
751
+ if (v.valueless_by_exception ()) return false ;
752
+ // Need to guard this with is_any otherwise the holds_alternative is illegal
753
+ if constexpr (is_any<std::monostate, Ts...>) if (std::holds_alternative<std::monostate>(v)) return false ;
754
+
755
+ return std::visit ([](auto && arg) -> bool {
756
+ return cpp2::is<value>(arg);
757
+ }, v);
758
+ }
759
+
760
+ template < auto value, typename ... Ts >
761
+ auto is ( std::variant<Ts...> const & v ) -> bool {
762
+ return cpp2::is_impl<value>(v);
763
+ }
764
+
765
+ template < cstring_wrapper value, typename ... Ts >
766
+ auto is ( std::variant<Ts...> const & v ) -> bool {
767
+ return cpp2::is_impl<value>(v);
768
+ }
769
+
770
+ template < double_wrapper value, typename ... Ts >
771
+ auto is ( std::variant<Ts...> const & v ) -> bool {
772
+ return cpp2::is_impl<value>(v);
773
+ }
749
774
750
775
// -------------------------------------------------------------------------------------------------------------
751
776
// std::any is and as
You can’t perform that action at this time.
0 commit comments