101 "Convert only supports String, std::string, std::string_view, and const char*");
103 if constexpr (std::is_same_v<To, void>) {
105 if constexpr (std::is_same_v<From, String>) {
106 return std::string(from.utf8().data(), from.utf8().length());
107 }
else if constexpr (std::is_same_v<From, std::string> ||
108 std::is_same_v<From, std::string_view>) {
109 return String(from.data(), from.length());
110 }
else if constexpr (std::is_same_v<From, const char*>) {
119 "Convert only supports String, std::string, std::string_view, and const char*");
121 if constexpr (std::is_same_v<To, From>) {
123 }
else if constexpr (std::is_same_v<To, String>) {
124 if constexpr (std::is_same_v<From, const char*>) {
127 return String(from.data(), from.length());
129 }
else if constexpr (std::is_same_v<To, std::string>) {
130 if constexpr (std::is_same_v<From, String>) {
131 return std::string(from.utf8().data(), from.utf8().length());
132 }
else if constexpr (std::is_same_v<From, const char*>) {
133 return std::string(from);
135 return std::string(from);
137 }
else if constexpr (std::is_same_v<To, std::string_view>) {
138 if constexpr (std::is_same_v<From, String>) {
139 return std::string_view(from.utf8().data(), from.utf8().length());
140 }
else if constexpr (std::is_same_v<From, const char*>) {
141 return std::string_view(from);
143 return std::string_view(from);
145 }
else if constexpr (std::is_same_v<To, const char*>) {
146 static_assert(!std::is_same_v<To, const char*>,
147 "Direct conversion to const char* is not supported due to ownership issues. "
148 "Convert to String, std::string, or std::string_view instead.");
std::ostream & operator<<(std::ostream &os, const ultralight::String &str)
Stream output operator for ultralight::String.
Definition StringSTL.h:181
std::istream & operator>>(std::istream &is, ultralight::String &str)
Stream input operator for ultralight::String.
Definition StringSTL.h:194