diff options
-rw-r--r-- | chilbert/BigBitVec.hpp | 9 | ||||
-rw-r--r-- | chilbert/FixBitVec.hpp | 9 | ||||
-rw-r--r-- | chilbert/Operators.hpp | 11 |
3 files changed, 11 insertions, 18 deletions
diff --git a/chilbert/BigBitVec.hpp b/chilbert/BigBitVec.hpp index 5b5f408..70a917b 100644 --- a/chilbert/BigBitVec.hpp +++ b/chilbert/BigBitVec.hpp @@ -482,15 +482,6 @@ grayCodeInv(CBigBitVec& value) } } -inline std::ostream& -operator<<(std::ostream& os, const CBigBitVec& vec) -{ - for (size_t i = 0; i < vec.size(); ++i) { - os << vec.test(vec.size() - i - 1); - } - return os; -} - } // namespace chilbert #endif diff --git a/chilbert/FixBitVec.hpp b/chilbert/FixBitVec.hpp index 0eab0e9..d4313ba 100644 --- a/chilbert/FixBitVec.hpp +++ b/chilbert/FixBitVec.hpp @@ -379,15 +379,6 @@ grayCodeInv(CFixBitVec& value) grayCodeInv<CFixBitVec::Rack>(value.rack()); } -inline std::ostream& -operator<<(std::ostream& os, const CFixBitVec& vec) -{ - for (size_t i = 0; i < vec.size(); ++i) { - os << vec.test(vec.size() - i - 1); - } - return os; -} - } // namespace chilbert #endif diff --git a/chilbert/Operators.hpp b/chilbert/Operators.hpp index 9ae022a..683c792 100644 --- a/chilbert/Operators.hpp +++ b/chilbert/Operators.hpp @@ -21,6 +21,7 @@ #include "chilbert/Traits.hpp" +#include <iostream> #include <type_traits> namespace chilbert { @@ -78,6 +79,16 @@ operator>>(const T& vec, const size_t bits) return r; } +template <class T> +inline std::enable_if_t<is_bitvec_v<T>, std::ostream>& +operator<<(std::ostream& os, const T& vec) +{ + for (size_t i = 0; i < vec.size(); ++i) { + os << vec.test(vec.size() - i - 1); + } + return os; +} + } // namespace chilbert #endif |