ソースを参照

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

Sam Jaffe 3 年 前
コミット
32b877b3ab
1 ファイル変更8 行追加0 行削除
  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 {