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 @@ -750,6 +750,31 @@ auto as( std::variant<Ts...> const& x ) {
750
750
throw std::bad_variant_access ();
751
751
}
752
752
753
+ template < auto value, typename ... Ts >
754
+ constexpr auto is_impl ( std::variant<Ts...> const & v ) -> bool {
755
+ if (v.valueless_by_exception ()) return false ;
756
+ // Need to guard this with is_any otherwise the holds_alternative is illegal
757
+ if constexpr (is_any<std::monostate, Ts...>) if (std::holds_alternative<std::monostate>(v)) return false ;
758
+
759
+ return std::visit ([](auto && arg) -> bool {
760
+ return cpp2::is<value>(CPP2_FORWARD (arg));
761
+ }, v);
762
+ }
763
+
764
+ template < auto value, typename ... Ts >
765
+ constexpr auto is ( std::variant<Ts...> const & v ) -> bool {
766
+ return cpp2::is_impl<value>(v);
767
+ }
768
+
769
+ template < cstring_wrapper value, typename ... Ts >
770
+ constexpr auto is ( std::variant<Ts...> const & v ) -> bool {
771
+ return cpp2::is_impl<value>(v);
772
+ }
773
+
774
+ template < double_wrapper value, typename ... Ts >
775
+ constexpr auto is ( std::variant<Ts...> const & v ) -> bool {
776
+ return cpp2::is_impl<value>(v);
777
+ }
753
778
754
779
// -------------------------------------------------------------------------------------------------------------
755
780
// std::any is and as
You can’t perform that action at this time.
0 commit comments