diff options
author | David Robillard <d@drobilla.net> | 2018-08-12 22:28:21 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-09-29 14:46:28 +0200 |
commit | 1d93b32df165b1ad96b2d1b17d553eb2a37b696c (patch) | |
tree | f15f9c821f9d0d2120ec5e4f7495ce8ab4ea3487 | |
parent | c28ab4461fd7868cff200283cc4cf6aded0f331f (diff) | |
download | chilbert-1d93b32df165b1ad96b2d1b17d553eb2a37b696c.tar.gz chilbert-1d93b32df165b1ad96b2d1b17d553eb2a37b696c.tar.bz2 chilbert-1d93b32df165b1ad96b2d1b17d553eb2a37b696c.zip |
Add print operators
-rw-r--r-- | chilbert/BigBitVec.hpp | 10 | ||||
-rw-r--r-- | chilbert/FixBitVec.hpp | 10 |
2 files changed, 20 insertions, 0 deletions
diff --git a/chilbert/BigBitVec.hpp b/chilbert/BigBitVec.hpp index 8f8dc6d..37ef870 100644 --- a/chilbert/BigBitVec.hpp +++ b/chilbert/BigBitVec.hpp @@ -26,6 +26,7 @@ #include <cstddef> #include <cstdlib> #include <cstring> +#include <iostream> #include <memory> #define FBVS_NEEDED(b) ((std::max(b, size_t(1)) + FBV_BITS - 1) / FBV_BITS) @@ -541,6 +542,15 @@ 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 bba25d9..0bc2032 100644 --- a/chilbert/FixBitVec.hpp +++ b/chilbert/FixBitVec.hpp @@ -25,6 +25,7 @@ #include <climits> #include <cstddef> #include <cstdint> +#include <iostream> namespace chilbert { @@ -266,6 +267,15 @@ grayCodeInv(CFixBitVec& value) grayCodeInv<FBV_UINT>(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 |