Zen C++ Libraries
Zero-dependency re-usable components for C++
Loading...
Searching...
No Matches
formatting.hpp
1
2#include <concepts>
3#include <ostream>
4#include <sstream>
5
6#include "zen/config.hpp"
7
8ZEN_NAMESPACE_START
9
10template<typename T>
11concept has_display = requires(T value, std::ostream& out) {
12 { value.display(out) } -> std::same_as<void>;
13};
14
15template<typename T>
16std::string display(const T& value);
17
18template<has_display T>
19std::string display(const T& value) {
20 std::ostringstream out;
21 value.display(out);
22 return out.str();
23}
24
25ZEN_NAMESPACE_END
Definition value.hpp:34
Definition formatting.hpp:11