userver: userver/chaotic/convert.hpp Source File
Loading...
Searching...
No Matches
convert.hpp
1#pragma once
2
3#include <type_traits>
4
5#include <userver/chaotic/convert/to.hpp>
6
7USERVER_NAMESPACE_BEGIN
8
9namespace chaotic::convert {
10
11template <typename T, typename U>
12U Convert(const T& value, To<U>) {
13 static_assert(
14 std::is_constructible_v<U, const T&>,
15 "There is no `Convert(const Value&, chaotic::convert::To<T>)` in "
16 "namespace of `T` or `chaotic::convert`. Probably you have not provided "
17 "a `Convert` function overload.");
18
19 return U{value};
20}
21
22} // namespace chaotic::convert
23
24USERVER_NAMESPACE_END