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

◆ make_streamable()

template<typename T >
auto kumi::_::make_streamable ( T const &  e)

#include <kumi/detail/streamable.hpp>

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

Note
This function is an implementation detail and only documented to show how to use the as_streamable extension point.
Template Parameters
TType of the element to output.
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";
}
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:37