diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-10-27 15:47:35 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-10-27 15:47:35 +0000 |
commit | 4a30d7f34efd30f21b560dbd3442a86482615b07 (patch) | |
tree | 1d78360f0990cde2c473191c4e7124cf03854a92 /lib | |
parent | Basic soft shadows (diff) | |
download | ilt-4a30d7f34efd30f21b560dbd3442a86482615b07.tar.bz2 ilt-4a30d7f34efd30f21b560dbd3442a86482615b07.tar.xz ilt-4a30d7f34efd30f21b560dbd3442a86482615b07.zip |
Add stream support for tuples
Diffstat (limited to 'lib')
-rw-r--r-- | lib/stream_support.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/stream_support.h b/lib/stream_support.h index 57d82a1..d71356c 100644 --- a/lib/stream_support.h +++ b/lib/stream_support.h @@ -6,6 +6,7 @@ #include <maths.h> #include <span> #include <sstream> +#include <tuple> #include <type_traits> template<typename S> @@ -49,6 +50,22 @@ namespace std { return (s << '(' << v.first << ", " << v.second << ')'); } + namespace { + template<typename... T, size_t... Idx> + std::ostream & + printTuple(std::ostream & s, const std::tuple<T...> & v, std::integer_sequence<size_t, Idx...>) + { + return ((s << (Idx ? ", " : "") << std::get<Idx>(v)), ...); + } + } + + template<typename... T> + std::ostream & + operator<<(std::ostream & s, const std::tuple<T...> & v) + { + return printTuple(s << '{', v, std::make_index_sequence<sizeof...(T)>()) << '}'; + } + inline std::ostream & operator<<(std::ostream & s, const Arc & arc) { |