KUMI v5.0.0
Gorgeous Garnet
Loading...
Searching...
No Matches

Casts the provided value to the target type using static_cast. More...

Functions

template<typename U, typename T>
decltype(auto) constexpr field_cast (T &&t) noexcept

Detailed Description

Casts the provided value to the target type using static_cast.

Function Documentation

◆ field_cast()

template<typename U, typename T>
decltype(auto) constexpr field_cast ( T && t)
related
Note
If the type to convert models kumi::concepts::field, the function does not rename the input parameter.
Template Parameters
UThe type to convert the parameter to.
Parameters
tA forwarding reference to the input object.
Returns
A value of type U.

Helper type

namespace kumi::result
{
template<typename Ts> struct field_cast;
template<typename T> using field_cast_t = typename field_cast<T>::type;
}
decltype(auto) constexpr field_cast(T &&t) noexcept
Definition field.hpp:320

Computes the return type of a call to kumi::field_cast

Example:

#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
using namespace kumi::literals;
auto field = ( "x"_id = 'x' );
using caster_t = decltype( "y"_id = 1 );
std::cout << field << "\n";
std::cout << kumi::field_cast<int>(field) << "\n";
std::cout << kumi::field_cast<caster_t>(field) << "\n";
}
Named wrapper over a type.
Definition field.hpp:26