feat: add operator+= to toml::string

This commit is contained in:
ToruNiina 2019-10-09 21:51:14 +09:00
parent 06086a9ff7
commit 258e62f8f3

View File

@ -2,6 +2,7 @@
// Distributed under the MIT License. // Distributed under the MIT License.
#ifndef TOML11_STRING_HPP #ifndef TOML11_STRING_HPP
#define TOML11_STRING_HPP #define TOML11_STRING_HPP
#include <algorithm>
#include <string> #include <string>
#include <cstdint> #include <cstdint>
#if __cplusplus >= 201703L #if __cplusplus >= 201703L
@ -45,6 +46,11 @@ struct string
operator std::string const& () const& noexcept {return str;} operator std::string const& () const& noexcept {return str;}
operator std::string&& () && noexcept {return std::move(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 #if __cplusplus >= 201703L
explicit string(std::string_view s): kind(string_t::basic), str(s){} explicit string(std::string_view s): kind(string_t::basic), str(s){}
string(std::string_view s, string_t k): kind(k), 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 explicit operator std::string_view() const noexcept
{return std::string_view(str);} {return std::string_view(str);}
string& operator+=(const std::string_view& rhs) {str += rhs; return *this;}
#endif #endif
string_t kind; string_t kind;