userver: userver/chaotic/io/std/size_t.hpp Source File
Loading...
Searching...
No Matches
size_t.hpp
1#pragma once
2
3#include <cstddef>
4
5#include <userver/chaotic/convert/to.hpp>
6#include <userver/chaotic/io/std/uint64_t.hpp>
7#include <userver/utils/numeric_cast.hpp>
8
9USERVER_NAMESPACE_BEGIN
10
11namespace chaotic::convert {
12
13template <typename T>
14std::enable_if_t<std::is_integral_v<T> && !std::is_same_v<std::size_t, std::uint64_t>, T>
15Convert(const std::size_t& value, To<T>) {
16 return utils::numeric_cast<T>(value);
17}
18
19template <typename T>
20std::enable_if_t<std::is_integral_v<T> && !std::is_same_v<std::size_t, std::uint64_t>, std::size_t>
21Convert(const T& value, To<std::size_t>) {
22 return utils::numeric_cast<std::size_t>(value);
23}
24
25} // namespace chaotic::convert
26
27USERVER_NAMESPACE_END