summaryrefslogtreecommitdiff
path: root/lib/stream_support.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stream_support.hpp')
-rw-r--r--lib/stream_support.hpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/stream_support.hpp b/lib/stream_support.hpp
index 0552b9d..3f0165c 100644
--- a/lib/stream_support.hpp
+++ b/lib/stream_support.hpp
@@ -5,6 +5,11 @@
#include <maths.h>
#include <span>
#include <sstream>
+#include <type_traits>
+
+template<typename T>
+concept spanable = std::is_constructible_v<std::span<const typename T::value_type>, T> && !std::is_same_v<char,
+ std::decay_t<typename T::value_type>>;
namespace std {
template<typename T, std::size_t L>
@@ -34,16 +39,9 @@ namespace std {
return (s << std::span {&v[0], L});
}
- template<typename T, std::size_t L>
- std::ostream &
- operator<<(std::ostream & s, const array<T, L> & v)
- {
- return (s << std::span {v});
- }
-
- template<typename T>
+ template<spanable T>
std::ostream &
- operator<<(std::ostream & s, const vector<T> & v)
+ operator<<(std::ostream & s, const T & v)
{
return (s << std::span {v});
}
@@ -61,7 +59,7 @@ streamed_string(const T & v)
{
std::stringstream ss;
ss << v;
- return ss.str();
+ return std::move(ss).str();
}
#define CLOG(x) std::cerr << #x " : " << x << "\n";