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<
17 std::is_integral_v<T> && !std::is_same_v<unsigned, std::uint32_t>, T>
18Convert(unsigned value, To<T>) {
19 return utils::numeric_cast<T>(value);
20}
21
22template <typename T>
23std::enable_if_t<
24 std::is_integral_v<T> && !std::is_same_v<unsigned, std::uint32_t>, unsigned>
25Convert(const T& value, To<unsigned>) {
26 return utils::numeric_cast<unsigned>(value);
27}
28
29} // namespace chaotic::convert
30
31USERVER_NAMESPACE_END