Przeglądaj źródła

refactor: use string_view instead of string for from_string for ease-of-user

Sam Jaffe 2 lat temu
rodzic
commit
8cb0538fd3

+ 2 - 1
include/serializer/jsonizer.h

@@ -50,7 +50,8 @@ public:
    * @return A newly constructed object by value
    */
   template <typename T> T from_stream(std::istream & in) const;
-  template <typename T> T from_string(std::string const & in) const;
+  template <typename T> T from_string(std::string_view in) const;
+
   /**
    * @brief Write an object out to a datastream, such as std::cout or a file
    * @param T the input type to be serialized

+ 1 - 1
include/serializer/jsonizer_ios.tpp

@@ -25,7 +25,7 @@ template <typename T> T Jsonizer::from_stream(std::istream & in) const {
   return from_json<T>(root);
 }
 
-template <typename T> T Jsonizer::from_string(std::string const & in) const {
+template <typename T> T Jsonizer::from_string(std::string_view in) const {
   std::stringstream ss;
   ss << in;
   return from_stream<T>(ss);