From 258e62f8f31df7b1f20cf57d355f941850139aa0 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Wed, 9 Oct 2019 21:51:14 +0900 Subject: [PATCH] feat: add operator+= to toml::string --- toml/string.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/toml/string.hpp b/toml/string.hpp index 98b355b..0551ccd 100644 --- a/toml/string.hpp +++ b/toml/string.hpp @@ -2,6 +2,7 @@ // Distributed under the MIT License. #ifndef TOML11_STRING_HPP #define TOML11_STRING_HPP +#include #include #include #if __cplusplus >= 201703L @@ -45,6 +46,11 @@ struct string operator std::string const& () const& noexcept {return str;} operator std::string&& () && noexcept {return std::move(str);} + string& operator+=(const char* rhs) {str += rhs; return *this;} + string& operator+=(const char rhs) {str += rhs; return *this;} + string& operator+=(const std::string& rhs) {str += rhs; return *this;} + string& operator+=(const string& rhs) {str += rhs.str; return *this;} + #if __cplusplus >= 201703L explicit string(std::string_view s): kind(string_t::basic), str(s){} string(std::string_view s, string_t k): kind(k), str(s){} @@ -54,6 +60,8 @@ struct string explicit operator std::string_view() const noexcept {return std::string_view(str);} + + string& operator+=(const std::string_view& rhs) {str += rhs; return *this;} #endif string_t kind;