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