KUMI v3.1.0
Exquisite Epidote
Loading...
Searching...
No Matches

◆ field_cast()

decltype(auto) constexpr field_cast ( T && t)
related

Casts the provided value to the target type using static_cast.

Note
If the type to convert to models kumi::concepts::field, 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:286

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 = 1 );
auto caster = ( "y"_id = 'x' );
std::cout << field << "\n";
std::cout << kumi::field_cast<char>(field) << "\n";
std::cout << kumi::field_cast<decltype(caster)>(field) << "\n";
}