refactor: move ctors that are only used internally

This commit is contained in:
ToruNiina
2020-01-19 18:30:27 +09:00
parent f2c8d0e279
commit 0934d90f90

View File

@@ -529,14 +529,6 @@ class basic_value
assigner(this->boolean_, b); assigner(this->boolean_, b);
return *this; return *this;
} }
template<typename Container>
basic_value(boolean b, detail::region<Container> reg)
: type_(value_t::boolean),
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
comments_(region_info_->comments())
{
assigner(this->boolean_, b);
}
basic_value(boolean b, std::vector<std::string> comments) basic_value(boolean b, std::vector<std::string> comments)
: type_(value_t::boolean), : type_(value_t::boolean),
region_info_(std::make_shared<region_base>(region_base{})), region_info_(std::make_shared<region_base>(region_base{})),
@@ -557,19 +549,6 @@ class basic_value
assigner(this->integer_, static_cast<integer>(i)); assigner(this->integer_, static_cast<integer>(i));
} }
template<typename T, typename Container, typename std::enable_if<
detail::conjunction<
std::is_integral<T>,
detail::negation<std::is_same<T, boolean>>
>::value, std::nullptr_t>::type = nullptr>
basic_value(T i, detail::region<Container> reg)
: type_(value_t::integer),
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
comments_(region_info_->comments())
{
assigner(this->integer_, static_cast<integer>(i));
}
template<typename T, typename std::enable_if<detail::conjunction< template<typename T, typename std::enable_if<detail::conjunction<
std::is_integral<T>, detail::negation<std::is_same<T, boolean>>>::value, std::is_integral<T>, detail::negation<std::is_same<T, boolean>>>::value,
std::nullptr_t>::type = nullptr> std::nullptr_t>::type = nullptr>
@@ -604,15 +583,6 @@ class basic_value
assigner(this->floating_, static_cast<floating>(f)); assigner(this->floating_, static_cast<floating>(f));
} }
template<typename T, typename Container, typename std::enable_if<
std::is_floating_point<T>::value, std::nullptr_t>::type = nullptr>
basic_value(T f, detail::region<Container> reg)
: type_(value_t::floating),
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
comments_(region_info_->comments())
{
assigner(this->floating_, static_cast<floating>(f));
}
template<typename T, typename std::enable_if< template<typename T, typename std::enable_if<
std::is_floating_point<T>::value, std::nullptr_t>::type = nullptr> std::is_floating_point<T>::value, std::nullptr_t>::type = nullptr>
@@ -643,14 +613,6 @@ class basic_value
{ {
assigner(this->string_, std::move(s)); assigner(this->string_, std::move(s));
} }
template<typename Container>
basic_value(toml::string s, detail::region<Container> reg)
: type_(value_t::string),
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
comments_(region_info_->comments())
{
assigner(this->string_, std::move(s));
}
basic_value& operator=(toml::string s) basic_value& operator=(toml::string s)
{ {
this->cleanup(); this->cleanup();
@@ -782,14 +744,6 @@ class basic_value
{ {
assigner(this->local_date_, ld); assigner(this->local_date_, ld);
} }
template<typename Container>
basic_value(const local_date& ld, detail::region<Container> reg)
: type_(value_t::local_date),
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
comments_(region_info_->comments())
{
assigner(this->local_date_, ld);
}
basic_value& operator=(const local_date& ld) basic_value& operator=(const local_date& ld)
{ {
this->cleanup(); this->cleanup();
@@ -814,14 +768,6 @@ class basic_value
{ {
assigner(this->local_time_, lt); assigner(this->local_time_, lt);
} }
template<typename Container>
basic_value(const local_time& lt, detail::region<Container> reg)
: type_(value_t::local_time),
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
comments_(region_info_->comments())
{
assigner(this->local_time_, lt);
}
basic_value(const local_time& lt, std::vector<std::string> comments) basic_value(const local_time& lt, std::vector<std::string> comments)
: type_(value_t::local_time), : type_(value_t::local_time),
region_info_(std::make_shared<region_base>(region_base{})), region_info_(std::make_shared<region_base>(region_base{})),
@@ -872,14 +818,6 @@ class basic_value
{ {
assigner(this->local_datetime_, ldt); assigner(this->local_datetime_, ldt);
} }
template<typename Container>
basic_value(const local_datetime& ldt, detail::region<Container> reg)
: type_(value_t::local_datetime),
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
comments_(region_info_->comments())
{
assigner(this->local_datetime_, ldt);
}
basic_value(const local_datetime& ldt, std::vector<std::string> comments) basic_value(const local_datetime& ldt, std::vector<std::string> comments)
: type_(value_t::local_datetime), : type_(value_t::local_datetime),
region_info_(std::make_shared<region_base>(region_base{})), region_info_(std::make_shared<region_base>(region_base{})),
@@ -904,14 +842,6 @@ class basic_value
{ {
assigner(this->offset_datetime_, odt); assigner(this->offset_datetime_, odt);
} }
template<typename Container>
basic_value(const offset_datetime& odt, detail::region<Container> reg)
: type_(value_t::offset_datetime),
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
comments_(region_info_->comments())
{
assigner(this->offset_datetime_, odt);
}
basic_value(const offset_datetime& odt, std::vector<std::string> comments) basic_value(const offset_datetime& odt, std::vector<std::string> comments)
: type_(value_t::offset_datetime), : type_(value_t::offset_datetime),
region_info_(std::make_shared<region_base>(region_base{})), region_info_(std::make_shared<region_base>(region_base{})),
@@ -958,14 +888,6 @@ class basic_value
{ {
assigner(this->array_, ary); assigner(this->array_, ary);
} }
template<typename Container>
basic_value(const array_type& ary, detail::region<Container> reg)
: type_(value_t::array),
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
comments_(region_info_->comments())
{
assigner(this->array_, ary);
}
basic_value(const array_type& ary, std::vector<std::string> comments) basic_value(const array_type& ary, std::vector<std::string> comments)
: type_(value_t::array), : type_(value_t::array),
region_info_(std::make_shared<region_base>(region_base{})), region_info_(std::make_shared<region_base>(region_base{})),
@@ -1079,14 +1001,6 @@ class basic_value
{ {
assigner(this->table_, tab); assigner(this->table_, tab);
} }
template<typename Container>
basic_value(const table_type& tab, detail::region<Container> reg)
: type_(value_t::table),
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
comments_(region_info_->comments())
{
assigner(this->table_, tab);
}
basic_value(const table_type& tab, std::vector<std::string> comments) basic_value(const table_type& tab, std::vector<std::string> comments)
: type_(value_t::table), : type_(value_t::table),
region_info_(std::make_shared<region_base>(region_base{})), region_info_(std::make_shared<region_base>(region_base{})),
@@ -1216,6 +1130,93 @@ class basic_value
} }
// for internal use ------------------------------------------------------ // for internal use ------------------------------------------------------
//
// Those constructors take detail::region that contains parse result.
template<typename Container>
basic_value(boolean b, detail::region<Container> reg)
: type_(value_t::boolean),
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
comments_(region_info_->comments())
{
assigner(this->boolean_, b);
}
template<typename T, typename Container, typename std::enable_if<
detail::conjunction<
std::is_integral<T>, detail::negation<std::is_same<T, boolean>>
>::value, std::nullptr_t>::type = nullptr>
basic_value(T i, detail::region<Container> reg)
: type_(value_t::integer),
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
comments_(region_info_->comments())
{
assigner(this->integer_, static_cast<integer>(i));
}
template<typename T, typename Container, typename std::enable_if<
std::is_floating_point<T>::value, std::nullptr_t>::type = nullptr>
basic_value(T f, detail::region<Container> reg)
: type_(value_t::floating),
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
comments_(region_info_->comments())
{
assigner(this->floating_, static_cast<floating>(f));
}
template<typename Container>
basic_value(toml::string s, detail::region<Container> reg)
: type_(value_t::string),
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
comments_(region_info_->comments())
{
assigner(this->string_, std::move(s));
}
template<typename Container>
basic_value(const local_date& ld, detail::region<Container> reg)
: type_(value_t::local_date),
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
comments_(region_info_->comments())
{
assigner(this->local_date_, ld);
}
template<typename Container>
basic_value(const local_time& lt, detail::region<Container> reg)
: type_(value_t::local_time),
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
comments_(region_info_->comments())
{
assigner(this->local_time_, lt);
}
template<typename Container>
basic_value(const local_datetime& ldt, detail::region<Container> reg)
: type_(value_t::local_datetime),
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
comments_(region_info_->comments())
{
assigner(this->local_datetime_, ldt);
}
template<typename Container>
basic_value(const offset_datetime& odt, detail::region<Container> reg)
: type_(value_t::offset_datetime),
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
comments_(region_info_->comments())
{
assigner(this->offset_datetime_, odt);
}
template<typename Container>
basic_value(const array_type& ary, detail::region<Container> reg)
: type_(value_t::array),
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
comments_(region_info_->comments())
{
assigner(this->array_, ary);
}
template<typename Container>
basic_value(const table_type& tab, detail::region<Container> reg)
: type_(value_t::table),
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
comments_(region_info_->comments())
{
assigner(this->table_, tab);
}
template<typename T, typename Container, typename std::enable_if< template<typename T, typename Container, typename std::enable_if<
detail::is_exact_toml_type<T, value_type>::value, detail::is_exact_toml_type<T, value_type>::value,