aboutsummaryrefslogtreecommitdiffstats
path: root/include/chilbert/StaticBitVec.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-09-16 21:19:57 -0400
committerDavid Robillard <d@drobilla.net>2022-09-16 22:31:06 -0400
commit2e4d666eec1a372d4b64c527d6c4945ad98d2b58 (patch)
treea3a61d346c3d4e5b590b08db446d17307df0e3c5 /include/chilbert/StaticBitVec.hpp
parentbf05ef949750cfca6e001b0f767cd2173441fc8c (diff)
downloadchilbert-2e4d666eec1a372d4b64c527d6c4945ad98d2b58.tar.gz
chilbert-2e4d666eec1a372d4b64c527d6c4945ad98d2b58.tar.bz2
chilbert-2e4d666eec1a372d4b64c527d6c4945ad98d2b58.zip
Update clang-format configuration
Diffstat (limited to 'include/chilbert/StaticBitVec.hpp')
-rw-r--r--include/chilbert/StaticBitVec.hpp100
1 files changed, 60 insertions, 40 deletions
diff --git a/include/chilbert/StaticBitVec.hpp b/include/chilbert/StaticBitVec.hpp
index 9aff3ad..1cd59b0 100644
--- a/include/chilbert/StaticBitVec.hpp
+++ b/include/chilbert/StaticBitVec.hpp
@@ -42,75 +42,95 @@ namespace chilbert {
*
* @tparam N Number of bits.
*/
-template <size_t N>
+template<size_t N>
class StaticBitVec : public detail::MultiBitVec<StaticBitVec<N>>
{
public:
- using Rack = typename detail::MultiBitVec<StaticBitVec<N>>::Rack;
+ using Rack = typename detail::MultiBitVec<StaticBitVec<N>>::Rack;
- using detail::MultiBitVec<StaticBitVec<N>>::bits_per_rack;
+ using detail::MultiBitVec<StaticBitVec<N>>::bits_per_rack;
- StaticBitVec() = default;
+ StaticBitVec() = default;
- /// Constructor for compatibility with DynamicBitVec
- explicit StaticBitVec(const size_t bits) { assert(bits == size()); }
+ /// Constructor for compatibility with DynamicBitVec
+ explicit StaticBitVec(const size_t bits) { assert(bits == size()); }
- /// Constructor for compatibility with DynamicBitVec
- StaticBitVec(const size_t bits, const Rack value)
- : StaticBitVec{bits}
- {
- m_racks[0] = value;
- }
+ /// Constructor for compatibility with DynamicBitVec
+ StaticBitVec(const size_t bits, const Rack value)
+ : StaticBitVec{bits}
+ {
+ m_racks[0] = value;
+ }
- /// Return the size in bits
- size_t size() const { return N; }
+ /// Return the size in bits
+ size_t size() const { return N; }
- /// Return a reference to the `index`th rack
+ /// Return a reference to the `index`th rack
#ifndef NDEBUG
- const auto& rack(const size_t index) const { return m_racks.at(index); }
- auto& rack(const size_t index) { return m_racks.at(index); }
+ const auto& rack(const size_t index) const
+ {
+ return m_racks.at(index);
+ }
+ auto& rack(const size_t index)
+ {
+ return m_racks.at(index);
+ }
#else
- const auto& rack(const size_t index) const { return m_racks[index]; }
- auto& rack(const size_t index) { return m_racks[index]; }
+ const auto& rack(const size_t index) const
+ {
+ return m_racks[index];
+ }
+ auto& rack(const size_t index)
+ {
+ return m_racks[index];
+ }
#endif
- /// Return a raw pointer to the racks
- Rack* data() { return m_racks.data(); }
- const Rack* data() const { return m_racks.data(); }
-
- /// Return the total size of all racks in bytes
- static constexpr size_t data_size() { return num_racks() * sizeof(Rack); }
-
- /// Return the number of racks
- static constexpr size_t num_racks()
- {
- return (std::max(N, size_t(1)) + bits_per_rack - 1) / bits_per_rack;
- }
+ /// Return a raw pointer to the racks
+ Rack* data()
+ {
+ return m_racks.data();
+ }
+ const Rack* data() const
+ {
+ return m_racks.data();
+ }
+
+ /// Return the total size of all racks in bytes
+ static constexpr size_t data_size()
+ {
+ return num_racks() * sizeof(Rack);
+ }
+
+ /// Return the number of racks
+ static constexpr size_t num_racks()
+ {
+ return (std::max(N, size_t(1)) + bits_per_rack - 1) / bits_per_rack;
+ }
private:
- std::array<Rack, num_racks()> m_racks{};
+ std::array<Rack, num_racks()> m_racks{};
};
namespace detail {
-template <size_t N>
-struct is_bitvec<StaticBitVec<N>>
-{
- constexpr static bool value = true;
+template<size_t N>
+struct is_bitvec<StaticBitVec<N>> {
+ constexpr static bool value = true;
};
-template <size_t N>
+template<size_t N>
void
gray_code(StaticBitVec<N>& value)
{
- gray_code(static_cast<MultiBitVec<StaticBitVec<N>>&>(value));
+ gray_code(static_cast<MultiBitVec<StaticBitVec<N>>&>(value));
}
-template <size_t N>
+template<size_t N>
void
gray_code_inv(StaticBitVec<N>& value)
{
- gray_code_inv(static_cast<MultiBitVec<StaticBitVec<N>>&>(value));
+ gray_code_inv(static_cast<MultiBitVec<StaticBitVec<N>>&>(value));
}
} // namespace detail