@@ -113,14 +113,6 @@ class MRDOCS_DECL
113
113
114
114
Value (char c) noexcept : Value(std::string_view(&c, 1 )) {}
115
115
116
- template <class Enum >
117
- requires
118
- std::is_enum_v<Enum> &&
119
- (!std::same_as<Enum, dom::Kind>)
120
- Value (Enum v) noexcept
121
- : Value(static_cast <std::underlying_type_t <Enum>>(v))
122
- {}
123
-
124
116
template <std::size_t N>
125
117
Value (char const (&sz)[N])
126
118
: Value(String(sz))
@@ -800,6 +792,45 @@ ValueFrom(T&& t)
800
792
return v;
801
793
}
802
794
795
+ /* * Convert an object of type `T` to @ref dom::Value with a context
796
+
797
+ This function attempts to convert an object
798
+ of type `T` to @ref dom::Value using
799
+
800
+ @li a user-provided overload of `tag_invoke`.
801
+
802
+ @li one of @ref dom::Value's constructors,
803
+
804
+ Conversion of other types is done by calling an overload of `tag_invoke`
805
+ found by argument-dependent lookup. Its signature should be similar to:
806
+
807
+ @code
808
+ void tag_invoke( ValueFromTag, dom::Value&, T );
809
+ @endcode
810
+
811
+ @par Exception Safety
812
+ Strong guarantee.
813
+
814
+ @tparam T The type of the object to convert.
815
+
816
+ @param t The object to convert.
817
+
818
+ @return @ref dom::Value out parameter.
819
+
820
+ @see @ref dom::ValueFromTag,
821
+ <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1895r0.pdf">
822
+ tag_invoke: A general pattern for supporting customisable functions</a>
823
+ */
824
+ template <class T , class Context >
825
+ requires HasValueFrom<T, Context>
826
+ Value
827
+ ValueFrom (T&& t, Context const & ctx)
828
+ {
829
+ dom::Value v;
830
+ ValueFrom (static_cast <T&&>(t), ctx, v);
831
+ return v;
832
+ }
833
+
803
834
} // dom
804
835
805
836
template <std::convertible_to<std::string_view> SV>
0 commit comments