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

◆ make_str()

template<valid_display_name T>
str kumi::_::make_str ( T const & t)
consteval

#include <kumi/detail/streamable.hpp>

Provides an extension point to_str in order to output types with no textual representation defined.

Note
This function is an implementation detail and only documented to show how to use the to_str extension point. It is used in order to handle identifiers/fields display and manipulations. to_str needs to be constexpr callable, if not some concepts might fail unexpectedly
Template Parameters
TType of the element to output.
Parameters
tThe value of the element to output.
Returns
A kumi::str representing the input type

Example:

#include <kumi/kumi.hpp>
#include <iostream>
#include <string>
#include <cstdint>
namespace ns
{
struct tax_t : kumi::identifier<tax_t>
{
using kumi::identifier<tax_t>::operator=;
friend constexpr auto to_str(tax_t const&)
{
return kumi::str{"Taxes Threshold"};
}
};
inline constexpr tax_t tax{};
struct deduction_t : kumi::identifier<deduction_t>
{
using kumi::identifier<deduction_t>::operator=;
};
inline constexpr deduction_t deduction{};
}
int main()
{
kumi::record payment= {ns::tax = 12.80, ns::deduction = 10.8};
std::cout << payment << "\n";
}
identifier definition class
Definition identifier.hpp:78
Fixed-size collection of heterogeneous fields necessarily named, names are unique.
Definition record.hpp:29
Static string used to create named fields.
Definition str.hpp:20