mirror of
https://github.com/boostorg/redis.git
synced 2026-02-21 15:22:14 +00:00
34 lines
839 B
C++
34 lines
839 B
C++
/* Copyright (c) 2019 - 2021 Marcelo Zimbres Silva (mzimbres at gmail dot com)
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <charconv>
|
|
|
|
namespace aedis {
|
|
namespace resp3 {
|
|
namespace detail {
|
|
|
|
template <class T>
|
|
typename std::enable_if<std::is_integral<T>::value, void>::type
|
|
from_string_view(std::string_view s, T& n)
|
|
{
|
|
auto r = std::from_chars(s.data(), s.data() + s.size(), n);
|
|
if (r.ec == std::errc::invalid_argument)
|
|
throw std::runtime_error("from_chars: Unable to convert");
|
|
}
|
|
|
|
inline
|
|
void from_string_view(std::string_view s, std::string& r)
|
|
{ r = s; }
|
|
|
|
} // detail
|
|
} // resp3
|
|
} // aedis
|