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

◆ as_streamable()

auto as_streamable ( auto e)

#include <kumi/detail/streamable.hpp>

Provides an extension point as_streamable in order to output types with no stream operator defined.

This function does not exist in the kumi namespace, it is supposed to be found via Argument Dependant Lookup for user defined types.

Parameters
eThe value of the element to output.
Returns
A value that can be passed to an output stream.

Example:

#include <kumi/kumi.hpp>
#include <iostream>
#include <string>
#include <cstdint>
namespace ns
{
struct price
{
std::uint64_t integer;
std::uint64_t decimal;
};
auto as_streamable(price const& p)
{
return std::to_string(p.integer) + "."
+ std::to_string(p.decimal);
}
}
int main()
{
ns::price baguette{1, 50};
ns::price cards {7, 90};
kumi::tuple shop_list = {baguette, cards};
std::cout << shop_list << "\n";
}
auto as_streamable(auto e)
Provides an extension point as_streamable in order to output types with no stream operator defined.
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:33