mirror of
https://github.com/matrix-construct/construct
synced 2025-02-18 17:50:16 +01:00
ircd::util: Add string() convenience overloads for sized char buffer.
This commit is contained in:
parent
5e0659b2f9
commit
5ad9f96b2a
1 changed files with 13 additions and 1 deletions
|
@ -246,13 +246,25 @@ microtime(char *const &buf,
|
|||
|
||||
|
||||
template<class T>
|
||||
std::string
|
||||
auto
|
||||
string(const T &s)
|
||||
{
|
||||
using std::stringstream;
|
||||
return static_cast<stringstream &>(stringstream{} << s).str();
|
||||
}
|
||||
|
||||
inline auto
|
||||
string(const char *const &buf, const size_t &size)
|
||||
{
|
||||
return std::string{buf, size};
|
||||
}
|
||||
|
||||
inline auto
|
||||
string(const uint8_t *const &buf, const size_t &size)
|
||||
{
|
||||
return string(reinterpret_cast<const char *>(buf), size);
|
||||
}
|
||||
|
||||
inline auto
|
||||
operator!(const std::string &str)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue