Explorar el Código

feat: add automatic binding for string-likes such as fs::path

Sam Jaffe hace 3 años
padre
commit
0bb49831e5
Se han modificado 1 ficheros con 8 adiciones y 0 borrados
  1. 8 0
      include/string_utils/cast.h

+ 8 - 0
include/string_utils/cast.h

@@ -114,6 +114,14 @@ template <typename T> struct cast_helper<T, std::enable_if_t<detail::is_tuple<T>
   }
 };
 
+template <typename T>
+struct cast_helper<T, std::enable_if_t<std::is_constructible_v<T, std::string_view>>> {
+  bool operator()(std::string_view str, T & to) const noexcept {
+    to = str;
+    return true;
+  }
+};
+
 template <typename... Ts>
 struct cast_helper<std::variant<Ts...>> {
   bool operator()(std::string_view str, std::variant<Ts...> & to) const noexcept {