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

◆ label_of()

template<typename T>
str kumi::label_of ( )
inlinenodiscardconstevalnoexcept

Extracts the label from a kumi::concepts::field or returns the parameter.

Note
If the unqualified type of input does not model kumi::concepts::field, returns kumi::unkown.
Template Parameters
TThe type to extract label from.
Returns
The label of the field as a kumi::str.

Helper type

namespace kumi::result
{
template<typename Ts> struct label_of;
template<typename T> using label_of_t = typename name_of<T>::type;
}
consteval str label_of() noexcept
Extracts the label from a kumi::concepts::field or returns the parameter.
Definition field.hpp:188

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

Example:

#include <kumi/kumi.hpp>
#include <iostream>
struct my_id : kumi::identifier<my_id>
{
using kumi::identifier<my_id>::operator=;
friend constexpr auto to_str(my_id) { return kumi::str{"Specific label"}; }
};
inline constexpr my_id my_kw{};
int main()
{
using namespace kumi::literals;
auto field = ( "x"_id = 1 );
int standard = { 12 };
auto custom = (my_kw = 255);
std::cout << field << "\n";
std::cout << kumi::label_of<decltype(field)>() << "\n";
std::cout << standard << "\n";
std::cout << kumi::label_of<decltype(standard)>() << "\n";
std::cout << custom << "\n";
std::cout << kumi::label_of<decltype(custom)>() << "\n";
}
kumi::str constexpr to_str(auto e)
Provides an extension point to_str in order to output types with no textual representation defined.
Named wrapper over a type.
Definition field.hpp:26
identifier definition class
Definition identifier.hpp:86
Static string used to create named fields.
Definition str.hpp:24