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 @@ -813,6 +813,31 @@ auto as( std::variant<Ts...> const& x ) {
813
813
throw std::bad_variant_access ();
814
814
}
815
815
816
+ template < auto value, typename ... Ts >
817
+ constexpr auto is_impl ( std::variant<Ts...> const & v ) -> bool {
818
+ if (v.valueless_by_exception ()) return false ;
819
+ // Need to guard this with is_any otherwise the holds_alternative is illegal
820
+ if constexpr (is_any<std::monostate, Ts...>) if (std::holds_alternative<std::monostate>(v)) return false ;
821
+
822
+ return std::visit ([](auto && arg) -> bool {
823
+ return cpp2::is<value>(CPP2_FORWARD (arg));
824
+ }, v);
825
+ }
826
+
827
+ template < auto value, typename ... Ts >
828
+ constexpr auto is ( std::variant<Ts...> const & v ) -> bool {
829
+ return cpp2::is_impl<value>(v);
830
+ }
831
+
832
+ template < cstring_wrapper value, typename ... Ts >
833
+ constexpr auto is ( std::variant<Ts...> const & v ) -> bool {
834
+ return cpp2::is_impl<value>(v);
835
+ }
836
+
837
+ template < double_wrapper value, typename ... Ts >
838
+ constexpr auto is ( std::variant<Ts...> const & v ) -> bool {
839
+ return cpp2::is_impl<value>(v);
840
+ }
816
841
817
842
// -------------------------------------------------------------------------------------------------------------
818
843
// std::any is and as
You can’t perform that action at this time.
0 commit comments