mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 09:08:08 +08:00
Merge pull request #63 from chronoxor/master
Fix Visual Studio 2019 warnings in pedantic compilation mode (/W4 /WX)
This commit is contained in:
@@ -353,15 +353,15 @@ struct local_datetime
|
|||||||
explicit local_datetime(const std::chrono::system_clock::time_point& tp)
|
explicit local_datetime(const std::chrono::system_clock::time_point& tp)
|
||||||
{
|
{
|
||||||
const auto t = std::chrono::system_clock::to_time_t(tp);
|
const auto t = std::chrono::system_clock::to_time_t(tp);
|
||||||
std::tm time = detail::localtime_s(&t);
|
std::tm ltime = detail::localtime_s(&t);
|
||||||
|
|
||||||
this->date = local_date(time);
|
this->date = local_date(ltime);
|
||||||
this->time = local_time(time);
|
this->time = local_time(ltime);
|
||||||
|
|
||||||
// std::tm lacks subsecond information, so diff between tp and tm
|
// std::tm lacks subsecond information, so diff between tp and tm
|
||||||
// can be used to get millisecond & microsecond information.
|
// can be used to get millisecond & microsecond information.
|
||||||
const auto t_diff = tp -
|
const auto t_diff = tp -
|
||||||
std::chrono::system_clock::from_time_t(std::mktime(&time));
|
std::chrono::system_clock::from_time_t(std::mktime(<ime));
|
||||||
this->time.millisecond = static_cast<std::uint16_t>(
|
this->time.millisecond = static_cast<std::uint16_t>(
|
||||||
std::chrono::duration_cast<std::chrono::milliseconds>(t_diff).count());
|
std::chrono::duration_cast<std::chrono::milliseconds>(t_diff).count());
|
||||||
this->time.microsecond = static_cast<std::uint16_t>(
|
this->time.microsecond = static_cast<std::uint16_t>(
|
||||||
|
@@ -1363,7 +1363,7 @@ parse_inline_table(location<Container>& loc)
|
|||||||
table retval;
|
table retval;
|
||||||
if(!(loc.iter() != loc.end() && *loc.iter() == '{'))
|
if(!(loc.iter() != loc.end() && *loc.iter() == '{'))
|
||||||
{
|
{
|
||||||
return err(format_underline("[error] toml::parse_inline_table: ",
|
return err(format_underline("[error] toml::parse_inline_table: ",
|
||||||
{{std::addressof(loc), "the next token is not an inline table"}}));
|
{{std::addressof(loc), "the next token is not an inline table"}}));
|
||||||
}
|
}
|
||||||
loc.advance();
|
loc.advance();
|
||||||
@@ -1672,12 +1672,12 @@ result<table, std::string> parse_ml_table(location<Container>& loc)
|
|||||||
const auto newline = skip_line::invoke(loc);
|
const auto newline = skip_line::invoke(loc);
|
||||||
if(!newline && loc.iter() != loc.end())
|
if(!newline && loc.iter() != loc.end())
|
||||||
{
|
{
|
||||||
const auto before = loc.iter();
|
const auto before2 = loc.iter();
|
||||||
lex_ws::invoke(loc); // skip whitespace
|
lex_ws::invoke(loc); // skip whitespace
|
||||||
const auto msg = format_underline("[error] toml::parse_table: "
|
const auto msg = format_underline("[error] toml::parse_table: "
|
||||||
"invalid line format", {{std::addressof(loc), concat_to_string(
|
"invalid line format", {{std::addressof(loc), concat_to_string(
|
||||||
"expected newline, but got '", show_char(*loc.iter()), "'.")}});
|
"expected newline, but got '", show_char(*loc.iter()), "'.")}});
|
||||||
loc.reset(before);
|
loc.reset(before2);
|
||||||
return err(msg);
|
return err(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -113,21 +113,25 @@ struct result
|
|||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->succ)) success_type(s);
|
auto tmp = ::new(std::addressof(this->succ)) success_type(s);
|
||||||
assert(tmp == std::addressof(this->succ));
|
assert(tmp == std::addressof(this->succ));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
result(const failure_type& f): is_ok_(false)
|
result(const failure_type& f): is_ok_(false)
|
||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->fail)) failure_type(f);
|
auto tmp = ::new(std::addressof(this->fail)) failure_type(f);
|
||||||
assert(tmp == std::addressof(this->fail));
|
assert(tmp == std::addressof(this->fail));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
result(success_type&& s): is_ok_(true)
|
result(success_type&& s): is_ok_(true)
|
||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->succ)) success_type(std::move(s));
|
auto tmp = ::new(std::addressof(this->succ)) success_type(std::move(s));
|
||||||
assert(tmp == std::addressof(this->succ));
|
assert(tmp == std::addressof(this->succ));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
result(failure_type&& f): is_ok_(false)
|
result(failure_type&& f): is_ok_(false)
|
||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->fail)) failure_type(std::move(f));
|
auto tmp = ::new(std::addressof(this->fail)) failure_type(std::move(f));
|
||||||
assert(tmp == std::addressof(this->fail));
|
assert(tmp == std::addressof(this->fail));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename U>
|
template<typename U>
|
||||||
@@ -135,24 +139,28 @@ struct result
|
|||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->succ)) success_type(s.value);
|
auto tmp = ::new(std::addressof(this->succ)) success_type(s.value);
|
||||||
assert(tmp == std::addressof(this->succ));
|
assert(tmp == std::addressof(this->succ));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
template<typename U>
|
template<typename U>
|
||||||
result(const failure<U>& f): is_ok_(false)
|
result(const failure<U>& f): is_ok_(false)
|
||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->fail)) failure_type(f.value);
|
auto tmp = ::new(std::addressof(this->fail)) failure_type(f.value);
|
||||||
assert(tmp == std::addressof(this->fail));
|
assert(tmp == std::addressof(this->fail));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
template<typename U>
|
template<typename U>
|
||||||
result(success<U>&& s): is_ok_(true)
|
result(success<U>&& s): is_ok_(true)
|
||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->succ)) success_type(std::move(s.value));
|
auto tmp = ::new(std::addressof(this->succ)) success_type(std::move(s.value));
|
||||||
assert(tmp == std::addressof(this->succ));
|
assert(tmp == std::addressof(this->succ));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
template<typename U>
|
template<typename U>
|
||||||
result(failure<U>&& f): is_ok_(false)
|
result(failure<U>&& f): is_ok_(false)
|
||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->fail)) failure_type(std::move(f.value));
|
auto tmp = ::new(std::addressof(this->fail)) failure_type(std::move(f.value));
|
||||||
assert(tmp == std::addressof(this->fail));
|
assert(tmp == std::addressof(this->fail));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
result& operator=(const success_type& s)
|
result& operator=(const success_type& s)
|
||||||
@@ -161,6 +169,7 @@ struct result
|
|||||||
this->is_ok_ = true;
|
this->is_ok_ = true;
|
||||||
auto tmp = ::new(std::addressof(this->succ)) success_type(s);
|
auto tmp = ::new(std::addressof(this->succ)) success_type(s);
|
||||||
assert(tmp == std::addressof(this->succ));
|
assert(tmp == std::addressof(this->succ));
|
||||||
|
(void)tmp;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
result& operator=(const failure_type& f)
|
result& operator=(const failure_type& f)
|
||||||
@@ -169,6 +178,7 @@ struct result
|
|||||||
this->is_ok_ = false;
|
this->is_ok_ = false;
|
||||||
auto tmp = ::new(std::addressof(this->fail)) failure_type(f);
|
auto tmp = ::new(std::addressof(this->fail)) failure_type(f);
|
||||||
assert(tmp == std::addressof(this->fail));
|
assert(tmp == std::addressof(this->fail));
|
||||||
|
(void)tmp;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
result& operator=(success_type&& s)
|
result& operator=(success_type&& s)
|
||||||
@@ -177,6 +187,7 @@ struct result
|
|||||||
this->is_ok_ = true;
|
this->is_ok_ = true;
|
||||||
auto tmp = ::new(std::addressof(this->succ)) success_type(std::move(s));
|
auto tmp = ::new(std::addressof(this->succ)) success_type(std::move(s));
|
||||||
assert(tmp == std::addressof(this->succ));
|
assert(tmp == std::addressof(this->succ));
|
||||||
|
(void)tmp;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
result& operator=(failure_type&& f)
|
result& operator=(failure_type&& f)
|
||||||
@@ -185,6 +196,7 @@ struct result
|
|||||||
this->is_ok_ = false;
|
this->is_ok_ = false;
|
||||||
auto tmp = ::new(std::addressof(this->fail)) failure_type(std::move(f));
|
auto tmp = ::new(std::addressof(this->fail)) failure_type(std::move(f));
|
||||||
assert(tmp == std::addressof(this->fail));
|
assert(tmp == std::addressof(this->fail));
|
||||||
|
(void)tmp;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,6 +207,7 @@ struct result
|
|||||||
this->is_ok_ = true;
|
this->is_ok_ = true;
|
||||||
auto tmp = ::new(std::addressof(this->succ)) success_type(s.value);
|
auto tmp = ::new(std::addressof(this->succ)) success_type(s.value);
|
||||||
assert(tmp == std::addressof(this->succ));
|
assert(tmp == std::addressof(this->succ));
|
||||||
|
(void)tmp;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
template<typename U>
|
template<typename U>
|
||||||
@@ -204,6 +217,7 @@ struct result
|
|||||||
this->is_ok_ = false;
|
this->is_ok_ = false;
|
||||||
auto tmp = ::new(std::addressof(this->fail)) failure_type(f.value);
|
auto tmp = ::new(std::addressof(this->fail)) failure_type(f.value);
|
||||||
assert(tmp == std::addressof(this->fail));
|
assert(tmp == std::addressof(this->fail));
|
||||||
|
(void)tmp;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
template<typename U>
|
template<typename U>
|
||||||
@@ -213,6 +227,7 @@ struct result
|
|||||||
this->is_ok_ = true;
|
this->is_ok_ = true;
|
||||||
auto tmp = ::new(std::addressof(this->succ)) success_type(std::move(s.value));
|
auto tmp = ::new(std::addressof(this->succ)) success_type(std::move(s.value));
|
||||||
assert(tmp == std::addressof(this->succ));
|
assert(tmp == std::addressof(this->succ));
|
||||||
|
(void)tmp;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
template<typename U>
|
template<typename U>
|
||||||
@@ -222,6 +237,7 @@ struct result
|
|||||||
this->is_ok_ = false;
|
this->is_ok_ = false;
|
||||||
auto tmp = ::new(std::addressof(this->fail)) failure_type(std::move(f.value));
|
auto tmp = ::new(std::addressof(this->fail)) failure_type(std::move(f.value));
|
||||||
assert(tmp == std::addressof(this->fail));
|
assert(tmp == std::addressof(this->fail));
|
||||||
|
(void)tmp;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,11 +249,13 @@ struct result
|
|||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->succ)) success_type(other.as_ok());
|
auto tmp = ::new(std::addressof(this->succ)) success_type(other.as_ok());
|
||||||
assert(tmp == std::addressof(this->succ));
|
assert(tmp == std::addressof(this->succ));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->fail)) failure_type(other.as_err());
|
auto tmp = ::new(std::addressof(this->fail)) failure_type(other.as_err());
|
||||||
assert(tmp == std::addressof(this->fail));
|
assert(tmp == std::addressof(this->fail));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result(result&& other): is_ok_(other.is_ok())
|
result(result&& other): is_ok_(other.is_ok())
|
||||||
@@ -246,11 +264,13 @@ struct result
|
|||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->succ)) success_type(std::move(other.as_ok()));
|
auto tmp = ::new(std::addressof(this->succ)) success_type(std::move(other.as_ok()));
|
||||||
assert(tmp == std::addressof(this->succ));
|
assert(tmp == std::addressof(this->succ));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->fail)) failure_type(std::move(other.as_err()));
|
auto tmp = ::new(std::addressof(this->fail)) failure_type(std::move(other.as_err()));
|
||||||
assert(tmp == std::addressof(this->fail));
|
assert(tmp == std::addressof(this->fail));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,11 +281,13 @@ struct result
|
|||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->succ)) success_type(other.as_ok());
|
auto tmp = ::new(std::addressof(this->succ)) success_type(other.as_ok());
|
||||||
assert(tmp == std::addressof(this->succ));
|
assert(tmp == std::addressof(this->succ));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->fail)) failure_type(other.as_err());
|
auto tmp = ::new(std::addressof(this->fail)) failure_type(other.as_err());
|
||||||
assert(tmp == std::addressof(this->fail));
|
assert(tmp == std::addressof(this->fail));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
template<typename U, typename F>
|
template<typename U, typename F>
|
||||||
@@ -275,11 +297,13 @@ struct result
|
|||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->succ)) success_type(std::move(other.as_ok()));
|
auto tmp = ::new(std::addressof(this->succ)) success_type(std::move(other.as_ok()));
|
||||||
assert(tmp == std::addressof(this->succ));
|
assert(tmp == std::addressof(this->succ));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->fail)) failure_type(std::move(other.as_err()));
|
auto tmp = ::new(std::addressof(this->fail)) failure_type(std::move(other.as_err()));
|
||||||
assert(tmp == std::addressof(this->fail));
|
assert(tmp == std::addressof(this->fail));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,11 +314,13 @@ struct result
|
|||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->succ)) success_type(other.as_ok());
|
auto tmp = ::new(std::addressof(this->succ)) success_type(other.as_ok());
|
||||||
assert(tmp == std::addressof(this->succ));
|
assert(tmp == std::addressof(this->succ));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->fail)) failure_type(other.as_err());
|
auto tmp = ::new(std::addressof(this->fail)) failure_type(other.as_err());
|
||||||
assert(tmp == std::addressof(this->fail));
|
assert(tmp == std::addressof(this->fail));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
is_ok_ = other.is_ok();
|
is_ok_ = other.is_ok();
|
||||||
return *this;
|
return *this;
|
||||||
@@ -306,11 +332,13 @@ struct result
|
|||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->succ)) success_type(std::move(other.as_ok()));
|
auto tmp = ::new(std::addressof(this->succ)) success_type(std::move(other.as_ok()));
|
||||||
assert(tmp == std::addressof(this->succ));
|
assert(tmp == std::addressof(this->succ));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->fail)) failure_type(std::move(other.as_err()));
|
auto tmp = ::new(std::addressof(this->fail)) failure_type(std::move(other.as_err()));
|
||||||
assert(tmp == std::addressof(this->fail));
|
assert(tmp == std::addressof(this->fail));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
is_ok_ = other.is_ok();
|
is_ok_ = other.is_ok();
|
||||||
return *this;
|
return *this;
|
||||||
@@ -324,11 +352,13 @@ struct result
|
|||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->succ)) success_type(other.as_ok());
|
auto tmp = ::new(std::addressof(this->succ)) success_type(other.as_ok());
|
||||||
assert(tmp == std::addressof(this->succ));
|
assert(tmp == std::addressof(this->succ));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->fail)) failure_type(other.as_err());
|
auto tmp = ::new(std::addressof(this->fail)) failure_type(other.as_err());
|
||||||
assert(tmp == std::addressof(this->fail));
|
assert(tmp == std::addressof(this->fail));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
is_ok_ = other.is_ok();
|
is_ok_ = other.is_ok();
|
||||||
return *this;
|
return *this;
|
||||||
@@ -341,11 +371,13 @@ struct result
|
|||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->succ)) success_type(std::move(other.as_ok()));
|
auto tmp = ::new(std::addressof(this->succ)) success_type(std::move(other.as_ok()));
|
||||||
assert(tmp == std::addressof(this->succ));
|
assert(tmp == std::addressof(this->succ));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto tmp = ::new(std::addressof(this->fail)) failure_type(std::move(other.as_err()));
|
auto tmp = ::new(std::addressof(this->fail)) failure_type(std::move(other.as_err()));
|
||||||
assert(tmp == std::addressof(this->fail));
|
assert(tmp == std::addressof(this->fail));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
is_ok_ = other.is_ok();
|
is_ok_ = other.is_ok();
|
||||||
return *this;
|
return *this;
|
||||||
|
@@ -79,7 +79,7 @@ std::string concat_to_string(Ts&& ... args)
|
|||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
T from_string(const std::string& str, U&& opt)
|
T from_string(const std::string& str, U&& opt)
|
||||||
{
|
{
|
||||||
T v(std::forward<U>(opt));
|
T v(static_cast<T>(std::forward<U>(opt)));
|
||||||
std::istringstream iss(str);
|
std::istringstream iss(str);
|
||||||
iss >> v;
|
iss >> v;
|
||||||
return v;
|
return v;
|
||||||
|
@@ -48,6 +48,7 @@ class value
|
|||||||
{
|
{
|
||||||
const auto tmp = ::new(std::addressof(dst)) T(std::forward<U>(v));
|
const auto tmp = ::new(std::addressof(dst)) T(std::forward<U>(v));
|
||||||
assert(tmp == std::addressof(dst));
|
assert(tmp == std::addressof(dst));
|
||||||
|
(void)tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
using region_base = detail::region_base;
|
using region_base = detail::region_base;
|
||||||
|
Reference in New Issue
Block a user