mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 17:58:09 +08:00
feat: add ctor to value to init with string_view
This commit is contained in:
@@ -14,6 +14,9 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#if __cplusplus >= 201703L
|
||||||
|
#include <string_view>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace toml
|
namespace toml
|
||||||
{
|
{
|
||||||
@@ -293,6 +296,29 @@ class value
|
|||||||
assigner(this->string_, toml::string(std::string(s), kind));
|
assigner(this->string_, toml::string(std::string(s), kind));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if __cplusplus >= 201703L
|
||||||
|
value(std::string_view s)
|
||||||
|
: type_(value_t::String),
|
||||||
|
region_info_(std::make_shared<region_base>(region_base{}))
|
||||||
|
{
|
||||||
|
assigner(this->string_, toml::string(s));
|
||||||
|
}
|
||||||
|
value& operator=(std::string_view s)
|
||||||
|
{
|
||||||
|
this->cleanup();
|
||||||
|
this->type_ = value_t::String;
|
||||||
|
this->region_info_ = std::make_shared<region_base>(region_base{});
|
||||||
|
assigner(this->string_, toml::string(s));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
value(std::string_view s, string_t kind)
|
||||||
|
: type_(value_t::String),
|
||||||
|
region_info_(std::make_shared<region_base>(region_base{}))
|
||||||
|
{
|
||||||
|
assigner(this->string_, toml::string(s, kind));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// local date ===========================================================
|
// local date ===========================================================
|
||||||
|
|
||||||
value(const local_date& ld)
|
value(const local_date& ld)
|
||||||
|
Reference in New Issue
Block a user