From fcdca58617caf6a8c034a91588d6abb399be6b57 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 18 May 2021 00:06:37 +0100 Subject: Initial commit, still lots to do! --- lib/bitset.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 lib/bitset.h (limited to 'lib/bitset.h') diff --git a/lib/bitset.h b/lib/bitset.h new file mode 100644 index 0000000..40ee3ed --- /dev/null +++ b/lib/bitset.h @@ -0,0 +1,45 @@ +#ifndef MYGRATE_BITSET_H +#define MYGRATE_BITSET_H + +#include +#include +#include + +namespace MyGrate { + class BitSet { + public: + class Iterator { + public: + using iterator_category = std::forward_iterator_tag; + using difference_type = int; + using value_type = bool; + using pointer = bool *; + using reference = bool; + + explicit Iterator(); + explicit Iterator(const std::byte *); + + bool operator*() const; + bool operator!=(const Iterator &) const; + bool operator==(const Iterator &) const; + + Iterator & operator++(); + Iterator operator++(int); + + private: + const std::byte * b; + std::byte m {1}; + }; + + explicit BitSet(const std::span b); + + std::size_t size() const; + Iterator begin() const; + Iterator end() const; + + private: + const std::span bytes; + }; +} + +#endif -- cgit v1.2.3