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

◆ to_str()

kumi::str constexpr to_str ( auto e)
constexpr

#include <kumi/detail/streamable.hpp>

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

This function does not exist in the kumi namespace, it is supposed to be found via Argument Dependant Lookup for user defined types. 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.

Parameters
eThe 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";
}
kumi::str constexpr to_str(auto e)
Provides an extension point to_str in order to output types with no textual representation defined.
identifier definition class
Definition identifier.hpp:86
Fixed-size collection of heterogeneous tagged fields, tags are unique.
Definition record.hpp:36
Static string used to create named fields.
Definition str.hpp:24