0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-03 02:28:55 +02:00

ircd: Minor fixes for g++-7 c++17.

This commit is contained in:
Jason Volk 2017-11-01 15:54:20 -07:00
parent 2902fcf71d
commit b1acf2cef1
2 changed files with 30 additions and 25 deletions

View file

@ -96,7 +96,8 @@ struct ircd::string_view
// (non-standard) our iterator-based assign
string_view &assign(const char *const &begin, const char *const &end)
{
*this = std::string_view{begin, size_t(std::distance(begin, end))};
this->~string_view();
new (this) string_view{begin, size_t(std::distance(begin, end))};
return *this;
}
@ -153,13 +154,25 @@ struct ircd::string_view
}{}
// Required due to current instability in stdlib
//string_view(const std::experimental::string_view &esv)
//:std::string_view{esv}
//{}
// string_view(const std::experimental::string_view &esv)
// :std::string_view{esv}
// {}
// Required due to current instability in stdlib
constexpr string_view(const std::experimental::fundamentals_v1::basic_string_view<char> &bsv)
:std::string_view{bsv}
// Required due to instability in stdlib
// constexpr string_view(const std::experimental::fundamentals_v1::basic_string_view<char> &bsv)
// :std::string_view{bsv}
// {}
// constexpr string_view(const char *const &start, const size_t &size)
// :std::string_view{start, size}
// {}
explicit string_view(const std::string &string)
:std::string_view{string.data(), string.size()}
{}
constexpr string_view(const std::string_view &sv)
:std::string_view{sv}
{}
/// Our default constructor sets the elements to 0 for best behavior by

View file

@ -135,10 +135,10 @@ ircd::replace(std::string s,
inline std::string
ircd::unquote(std::string &&str)
{
if(endswith(str, '"'))
if(endswith(string_view{str}, '"'))
str.pop_back();
if(startswith(str, '"'))
if(startswith(string_view{str}, '"'))
str = str.substr(1);
return std::move(str);
@ -332,13 +332,11 @@ ircd::rsplit(const string_view &str,
const auto pos(str.rfind(delim));
if(pos == string_view::npos) return
{
str,
string_view{}
str, string_view{}
};
else return
{
str.substr(0, pos),
str.substr(pos + delim.size())
str.substr(0, pos), str.substr(pos + delim.size())
};
}
@ -351,13 +349,11 @@ ircd::rsplit(const string_view &str,
const auto pos(str.find_last_of(delim));
if(pos == string_view::npos) return
{
str,
string_view{}
str, string_view{}
};
else return
{
str.substr(0, pos),
str.substr(pos + 1)
str.substr(0, pos), str.substr(pos + 1)
};
}
@ -370,13 +366,11 @@ ircd::split(const string_view &str,
const auto pos(str.find(delim));
if(pos == string_view::npos) return
{
str,
string_view{}
str, string_view{}
};
else return
{
str.substr(0, pos),
str.substr(pos + delim.size())
str.substr(0, pos), str.substr(pos + delim.size())
};
}
@ -389,13 +383,11 @@ ircd::split(const string_view &str,
const auto pos(str.find(delim));
if(pos == string_view::npos) return
{
str,
string_view{}
str, string_view{}
};
else return
{
str.substr(0, pos),
str.substr(pos + 1)
str.substr(0, pos), str.substr(pos + 1)
};
}