Loading...
Searching...
No Matches
bitset_new.h
Go to the documentation of this file.
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2022 John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_BITSET_NEW_INCLUDED
#define ETL_BITSET_NEW_INCLUDED
#include "../platform.h"
#include "../algorithm.h"
#include "../binary.h"
#include "../char_traits.h"
#include "../enum_type.h"
#include "../error_handler.h"
#include "../exception.h"
#include "../integral_limits.h"
#include "../iterator.h"
#include "../largest.h"
#include "../log.h"
#include "../nullptr.h"
#include "../smallest.h"
#include "../span.h"
#include "../static_assert.h"
#include "../string.h"
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#if ETL_USING_STL
#include <algorithm>
#endif
#include "minmax_push.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
#endif
#if ETL_USING_CPP11
#define ETL_STR(x) x
#define ETL_STRL(x) L##x
#define ETL_STRu(x) u##x
#define ETL_STRU(x) U##x
#else
#define ETL_STR(x) x
#define ETL_STRL(x) x
#define ETL_STRu(x) x
#define ETL_STRU(x) x
#endif
//*****************************************************************************
//*****************************************************************************
namespace etl
{
//***************************************************************************
//***************************************************************************
struct bitset_storage_model
{
enum enum_type
{
Undefined = 0,
Single = 1,
Multi = 2
};
ETL_DECLARE_ENUM_TYPE(bitset_storage_model, char)
ETL_ENUM_TYPE(Undefined, "Undefined")
ETL_ENUM_TYPE(Single, "Single")
ETL_ENUM_TYPE(Multi, "Multi")
ETL_END_ENUM_TYPE
};
//***************************************************************************
//***************************************************************************
class bitset_exception : public etl::exception
{
public:
bitset_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
: exception(reason_, file_name_, line_number_)
{
}
};
//***************************************************************************
//***************************************************************************
class bitset_string_too_small : public bitset_exception
{
public:
bitset_string_too_small(string_type file_name_, numeric_type line_number_)
: bitset_exception(ETL_ERROR_TEXT("bitset:type_too_small", ETL_BITSET_FILE_ID"A"), file_name_, line_number_)
{
}
};
//***************************************************************************
//***************************************************************************
class bitset_overflow : public bitset_exception
{
public:
bitset_overflow(string_type file_name_, numeric_type line_number_)
: bitset_exception(ETL_ERROR_TEXT("bitset:overflow", ETL_BITSET_FILE_ID"B"), file_name_, line_number_)
{
}
};
//***************************************************************************
//***************************************************************************
class bitset_invalid_buffer : public bitset_exception
{
public:
bitset_invalid_buffer(string_type file_name_, numeric_type line_number_)
: bitset_exception(ETL_ERROR_TEXT("bitset:invalid buffer", ETL_BITSET_FILE_ID"C"), file_name_, line_number_)
{
}
};
//***************************************************************************
namespace private_bitset
{
template <typename TElement>
class bitset_impl_common
{
public:
typedef TElement element_type;
typedef TElement* pointer;
typedef const TElement* const_pointer;
typedef size_t size_type;
static ETL_CONSTANT size_t npos = etl::integral_limits<size_t>::max;
static ETL_CONSTANT size_t Bits_Per_Element = etl::integral_limits<TElement>::bits;
static ETL_CONSTANT TElement All_Set_Element = etl::integral_limits<TElement>::max;
static ETL_CONSTANT TElement All_Clear_Element = element_type(0);
};
template <typename TElement>
ETL_CONSTANT size_t bitset_impl_common<TElement>::npos;
template <typename TElement>
ETL_CONSTANT size_t bitset_impl_common<TElement>::Bits_Per_Element;
template <typename TElement>
ETL_CONSTANT TElement bitset_impl_common<TElement>::All_Set_Element;
template <typename TElement>
ETL_CONSTANT TElement bitset_impl_common<TElement>::All_Clear_Element;
} // namespace private_bitset
//*************************************************************************
//*************************************************************************
template <typename TElement, char Bitset_Layout>
class bitset_impl;
//*************************************************************************
//*************************************************************************
template <typename TElement>
class bitset_impl<TElement, etl::bitset_storage_model::Single> : public etl::private_bitset::bitset_impl_common<TElement>
{
public:
using typename etl::private_bitset::bitset_impl_common<TElement>::element_type;
using typename etl::private_bitset::bitset_impl_common<TElement>::pointer;
using typename etl::private_bitset::bitset_impl_common<TElement>::const_pointer;
using etl::private_bitset::bitset_impl_common<TElement>::Bits_Per_Element;
using etl::private_bitset::bitset_impl_common<TElement>::All_Set_Element;
using etl::private_bitset::bitset_impl_common<TElement>::All_Clear_Element;
using etl::private_bitset::bitset_impl_common<TElement>::npos;
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void set_all(pointer pbuffer, size_t /*number_of_elements*/, element_type top_mask) ETL_NOEXCEPT
{
*pbuffer = All_Set_Element & top_mask;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void set_position(pointer pbuffer, size_t position, bool value = true)
{
const element_type mask = element_type(element_type(1) << position);
if (value == true)
{
*pbuffer |= mask;
}
else
{
*pbuffer &= ~mask;
}
}
//*************************************************************************
//*************************************************************************
template <size_t Position>
static ETL_CONSTEXPR14 void set_position(pointer pbuffer, bool value = true)
{
const element_type mask = element_type(element_type(1) << Position);
if (value == true)
{
*pbuffer |= mask;
}
else
{
*pbuffer &= ~mask;
}
}
//*************************************************************************
//*************************************************************************
template <size_t Position, bool Value>
static ETL_CONSTEXPR14 void set_position(pointer pbuffer)
{
const element_type mask = element_type(element_type(1) << Position);
if (Value == true)
{
*pbuffer |= mask;
}
else
{
*pbuffer &= ~mask;
}
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void reset_all(pointer pbuffer, size_t /*number_of_elements*/) ETL_NOEXCEPT
{
*pbuffer = All_Clear_Element;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14
void
reset_position(pointer pbuffer, size_t position)
{
const element_type mask = element_type(element_type(1) << position);
*pbuffer &= ~mask;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void from_string(pointer pbuffer, size_t /*number_of_elements*/, size_t active_bits, const char* text) ETL_NOEXCEPT
{
reset_all(pbuffer, 1U);
if (text != ETL_NULLPTR)
{
size_t string_length = etl::strlen(text);
// Build from the string.
string_length = etl::min(active_bits, string_length);
if (string_length == 0U)
{
return;
}
element_type mask = element_type(element_type(1) << (string_length - 1U));
for (size_t i = 0U; i < string_length; ++i)
{
if (text[i] == ETL_STR('1'))
{
*pbuffer |= mask;
}
mask >>= 1U;
}
}
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void from_string(pointer pbuffer, size_t /*number_of_elements*/, size_t active_bits, const wchar_t* text) ETL_NOEXCEPT
{
reset_all(pbuffer, 1U);
if (text != ETL_NULLPTR)
{
size_t string_length = etl::strlen(text);
// Build from the string.
string_length = etl::min(active_bits, string_length);
if (string_length == 0U)
{
return;
}
element_type mask = element_type(element_type(1) << (string_length - 1U));
for (size_t i = 0U; i < string_length; ++i)
{
if (text[i] == ETL_STRL('1'))
{
*pbuffer |= mask;
}
mask >>= 1U;
}
}
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void from_string(pointer pbuffer, size_t /*number_of_elements*/, size_t active_bits, const char16_t* text) ETL_NOEXCEPT
{
reset_all(pbuffer, 1U);
if (text != ETL_NULLPTR)
{
size_t string_length = etl::strlen(text);
// Build from the string.
string_length = etl::min(active_bits, string_length);
if (string_length == 0U)
{
return;
}
element_type mask = element_type(element_type(1) << (string_length - 1U));
for (size_t i = 0U; i < string_length; ++i)
{
if (text[i] == ETL_STRu('1'))
{
*pbuffer |= mask;
}
mask >>= 1U;
}
}
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void from_string(pointer pbuffer, size_t /*number_of_elements*/, size_t active_bits, const char32_t* text) ETL_NOEXCEPT
{
reset_all(pbuffer, 1U);
if (text != ETL_NULLPTR)
{
size_t string_length = etl::strlen(text);
// Build from the string.
string_length = etl::min(active_bits, string_length);
if (string_length == 0U)
{
return;
}
element_type mask = element_type(element_type(1) << (string_length - 1U));
for (size_t i = 0U; i < string_length; ++i)
{
if (text[i] == ETL_STRU('1'))
{
*pbuffer |= mask;
}
mask >>= 1U;
}
}
}
//*************************************************************************
//*************************************************************************
template <typename T>
static ETL_CONSTEXPR14 T value(const_pointer pbuffer, size_t /*number_of_elements*/) ETL_NOEXCEPT
{
return T(*pbuffer);
}
//*************************************************************************
//*************************************************************************
template <typename T>
static ETL_CONSTEXPR14 T extract(const_pointer pbuffer, size_t position, size_t length = etl::integral_limits<T>::bits)
{
typedef typename etl::make_unsigned<T>::type unsigned_t;
const unsigned_t Mask = etl::make_lsb_mask<unsigned_t>(length);
const unsigned_t Shift = position % Bits_Per_Element;
unsigned_t value = static_cast<unsigned_t>(*pbuffer >> Shift) & Mask;
if ((length != etl::integral_limits<T>::bits) && etl::integral_limits<T>::is_signed)
{
value = static_cast<unsigned_t>(etl::sign_extend<T>(static_cast<T>(value), length));
}
return static_cast<T>(value);
}
//*************************************************************************
//*************************************************************************
#if ETL_USING_CPP11
template <typename T, size_t Position, size_t Length = etl::integral_limits<T>::bits>
#else
template <typename T, size_t Position, size_t Length>
#endif
static ETL_CONSTEXPR14 T extract(const_pointer pbuffer)
{
typedef typename etl::make_unsigned<T>::type unsigned_t;
const unsigned_t Mask = etl::make_lsb_mask<unsigned_t>(Length);
const unsigned_t Shift = Position % Bits_Per_Element;
unsigned_t value = static_cast<unsigned_t>(*pbuffer >> Shift) & Mask;
if ((Length != etl::integral_limits<T>::bits) && etl::integral_limits<T>::is_signed)
{
value = static_cast<unsigned_t>(etl::sign_extend<T>(static_cast<T>(value), Length));
}
return static_cast<T>(value);
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 bool test(const_pointer pbuffer, size_t position)
{
const element_type mask = element_type(element_type(1) << position);
return (*pbuffer & mask) != 0U;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 size_t count(const_pointer pbuffer, size_t /*number_of_elements*/) ETL_NOEXCEPT
{
return etl::count_bits(*pbuffer);
}
//*************************************************************************
// Are all the bits sets?
//*************************************************************************
static ETL_CONSTEXPR14 bool all(const_pointer pbuffer, size_t /*number_of_elements*/, element_type top_mask) ETL_NOEXCEPT
{
return (*pbuffer & top_mask) == top_mask;
}
//*************************************************************************
// Are all the mask bits sets?
//*************************************************************************
static ETL_CONSTEXPR14 bool all(const_pointer pbuffer, size_t /*number_of_elements*/, element_type top_mask, element_type mask) ETL_NOEXCEPT
{
return (*pbuffer & top_mask & mask) == mask;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 bool none(const_pointer pbuffer, size_t /*number_of_elements*/) ETL_NOEXCEPT
{
return *pbuffer == All_Clear_Element;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 bool none(const_pointer pbuffer, size_t /*number_of_elements*/, element_type mask) ETL_NOEXCEPT
{
return (*pbuffer & mask) == All_Clear_Element;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 bool any(const_pointer pbuffer, size_t /*number_of_elements*/) ETL_NOEXCEPT
{
return *pbuffer != All_Clear_Element;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 bool any(const_pointer pbuffer, size_t /*number_of_elements*/, element_type mask) ETL_NOEXCEPT
{
return (*pbuffer & mask) != All_Clear_Element;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void flip_all(pointer pbuffer, size_t /*number_of_elements*/) ETL_NOEXCEPT
{
*pbuffer = ~*pbuffer;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void flip_bits(pointer pbuffer, element_type mask = etl::integral_limits<element_type>::max) ETL_NOEXCEPT
{
*pbuffer ^= mask;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void flip_position(pointer pbuffer, size_t position)
{
const element_type mask = element_type(element_type(1) << position);
*pbuffer ^= mask;
}
//*************************************************************************
//*************************************************************************
template <typename TString>
static ETL_CONSTEXPR14 TString to_string(const_pointer pbuffer, size_t active_bits,
typename TString::value_type zero = typename TString::value_type('0'),
typename TString::value_type one = typename TString::value_type('1'))
{
TString result;
result.resize(active_bits, '\0');
// Check that the string type can contain the digits.
ETL_ASSERT_OR_RETURN_VALUE(result.size() == active_bits, ETL_ERROR(etl::bitset_string_too_small), result);
for (size_t i = active_bits; i > 0; --i)
{
result[active_bits - i] = test(pbuffer, i - 1) ? one : zero;
}
return result;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 size_t find_next(const_pointer pbuffer, size_t /*number_of_elements*/, size_t active_bits, bool state, size_t position)
ETL_NOEXCEPT
{
if (position < active_bits)
{
// Where to start.
size_t bit = position;
element_type mask = 1U << position;
// Needs checking?
if ((state && (*pbuffer != All_Clear_Element)) || (!state && (*pbuffer != All_Set_Element)))
{
// For each bit in the element...
while (bit < active_bits)
{
// Equal to the required state?
if (((*pbuffer & mask) != 0) == state)
{
return bit;
}
// Move on to the next bit.
mask <<= 1;
++bit;
}
}
}
return npos;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void operator_assignment(pointer lhs_pbuffer, const_pointer rhs_pbuffer, size_t /*number_of_elements*/) ETL_NOEXCEPT
{
*lhs_pbuffer = *rhs_pbuffer;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void operator_and(pointer lhs_pbuffer, const_pointer rhs_pbuffer, size_t /*number_of_elements*/) ETL_NOEXCEPT
{
*lhs_pbuffer &= *rhs_pbuffer;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void operator_or(pointer lhs_pbuffer, const_pointer rhs_pbuffer, size_t /*number_of_elements*/) ETL_NOEXCEPT
{
*lhs_pbuffer |= *rhs_pbuffer;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void operator_xor(pointer lhs_pbuffer, const_pointer rhs_pbuffer, size_t /*number_of_elements*/) ETL_NOEXCEPT
{
*lhs_pbuffer ^= *rhs_pbuffer;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void operator_not(pointer pbuffer, size_t /*number_of_elements*/) ETL_NOEXCEPT
{
*pbuffer = ~*pbuffer;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void operator_shift_left(pointer pbuffer, size_t /*number_of_elements*/, size_t active_bits, size_t shift) ETL_NOEXCEPT
{
if (shift >= active_bits)
{
reset_all(pbuffer, 1U);
}
else
{
*pbuffer <<= shift;
}
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void operator_shift_right(pointer pbuffer, size_t /*number_of_elements*/, size_t active_bits, size_t shift) ETL_NOEXCEPT
{
if (shift >= active_bits)
{
reset_all(pbuffer, 1U);
}
else
{
*pbuffer >>= shift;
}
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 bool operator_equality(const_pointer lhs_pbuffer, const_pointer rhs_pbuffer, size_t /*number_of_elements*/) ETL_NOEXCEPT
{
return (*lhs_pbuffer == *rhs_pbuffer);
}
//*************************************************************************
//*************************************************************************
template <typename TElementType>
static ETL_CONSTEXPR14 void initialise(pointer pbuffer, size_t /*number_of_elements*/, unsigned long long value) ETL_NOEXCEPT
{
*pbuffer = static_cast<TElementType>(value);
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void swap(pointer lhs_pbuffer, pointer rhs_pbuffer, size_t /*number_of_elements*/) ETL_NOEXCEPT
{
element_type temp = *lhs_pbuffer;
*lhs_pbuffer = *rhs_pbuffer;
*rhs_pbuffer = temp;
}
};
//*************************************************************************
//*************************************************************************
template <typename TElement>
class bitset_impl<TElement, etl::bitset_storage_model::Multi> : public etl::private_bitset::bitset_impl_common<TElement>
{
private:
typedef etl::private_bitset::bitset_impl_common<TElement> common;
public:
using typename etl::private_bitset::bitset_impl_common<TElement>::element_type;
using typename etl::private_bitset::bitset_impl_common<TElement>::pointer;
using typename etl::private_bitset::bitset_impl_common<TElement>::const_pointer;
using etl::private_bitset::bitset_impl_common<TElement>::Bits_Per_Element;
using etl::private_bitset::bitset_impl_common<TElement>::All_Set_Element;
using etl::private_bitset::bitset_impl_common<TElement>::All_Clear_Element;
using etl::private_bitset::bitset_impl_common<TElement>::npos;
//*************************************************************************
//*************************************************************************
template <size_t Position, size_t Length, size_t Bits_Per_Element>
struct value_is_in_one_element
{
static
ETL_CONSTANT bool value = ((Position + Length - 1) >> etl::log2<Bits_Per_Element>::value) == (Position >> etl::log2<Bits_Per_Element>::value);
};
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 bool test(const_pointer pbuffer, size_t position) ETL_NOEXCEPT
{
size_t index = position >> etl::log2<Bits_Per_Element>::value;
element_type mask = element_type(1) << (position & (Bits_Per_Element - 1));
return (pbuffer[index] & mask) != 0;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 size_t count(const_pointer pbuffer, size_t number_of_elements) ETL_NOEXCEPT
{
size_t count = 0;
while (number_of_elements-- != 0)
{
count += etl::count_bits(*pbuffer++);
}
return count;
}
//*************************************************************************
// Are all the bits sets?
//*************************************************************************
static ETL_CONSTEXPR14 bool all(const_pointer pbuffer, size_t number_of_elements, element_type top_mask) ETL_NOEXCEPT
{
// All but the last.
while (number_of_elements-- != 1U)
{
if (*pbuffer++ != All_Set_Element)
{
return false;
}
}
// The last.
if ((*pbuffer & top_mask) != top_mask)
{
return false;
}
return true;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 bool none(const_pointer pbuffer, size_t number_of_elements) ETL_NOEXCEPT
{
while (number_of_elements-- != 0)
{
if (*pbuffer++ != 0)
{
return false;
}
}
return true;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 bool any(const_pointer pbuffer, size_t number_of_elements) ETL_NOEXCEPT
{
bool any_set = false;
while (number_of_elements-- != 0)
{
if (*pbuffer++ != All_Clear_Element)
{
any_set = true;
break;
}
}
return any_set;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void set_all(pointer pbuffer, size_t number_of_elements, element_type top_mask) ETL_NOEXCEPT
{
while (number_of_elements-- != 1U)
{
*pbuffer++ = All_Set_Element;
}
*pbuffer = (All_Set_Element & top_mask);
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void set_position(pointer pbuffer, size_t position, bool value = true) ETL_NOEXCEPT
{
size_t index = position >> etl::log2<Bits_Per_Element>::value;
element_type bit = element_type(1) << (position & (Bits_Per_Element - 1));
if (value == true)
{
pbuffer[index] |= bit;
}
else
{
pbuffer[index] &= ~bit;
}
}
//*************************************************************************
//*************************************************************************
template <size_t Position>
static ETL_CONSTEXPR14 void set_position(pointer pbuffer, bool value = true)
{
size_t index = Position >> etl::log2<Bits_Per_Element>::value;
element_type bit = element_type(1) << (Position & (Bits_Per_Element - 1));
if (value == true)
{
pbuffer[index] |= bit;
}
else
{
pbuffer[index] &= ~bit;
}
}
//*************************************************************************
//*************************************************************************
template <size_t Position, bool Value>
static ETL_CONSTEXPR14 void set_position(pointer pbuffer)
{
size_t index = Position >> etl::log2<Bits_Per_Element>::value;
element_type bit = element_type(1) << (Position & (Bits_Per_Element - 1));
if (Value == true)
{
pbuffer[index] |= bit;
}
else
{
pbuffer[index] &= ~bit;
}
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void from_string(pointer pbuffer, size_t number_of_elements, size_t total_bits, const char* text) ETL_NOEXCEPT
{
if (text == ETL_NULLPTR)
{
etl::fill_n(pbuffer, number_of_elements, All_Clear_Element);
}
else
{
size_t string_length = etl::strlen(text);
size_t index = etl::min(number_of_elements - 1U, (string_length / Bits_Per_Element));
// Only reset elements we need to.
while (index != number_of_elements)
{
pbuffer[index++] = All_Clear_Element;
}
// Build from the string.
size_t i = etl::min(total_bits, string_length);
while (i > 0)
{
set_position(pbuffer, --i, *text++ == ETL_STR('1'));
}
}
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void from_string(pointer pbuffer, size_t number_of_elements, size_t total_bits, const wchar_t* text) ETL_NOEXCEPT
{
if (text == ETL_NULLPTR)
{
etl::fill_n(pbuffer, number_of_elements, All_Clear_Element);
}
else
{
size_t string_length = etl::strlen(text);
size_t index = etl::min(number_of_elements - 1U, (string_length / Bits_Per_Element));
// Only reset elements we need to.
while (index != number_of_elements)
{
pbuffer[index++] = All_Clear_Element;
}
// Build from the string.
size_t i = etl::min(total_bits, string_length);
while (i > 0)
{
set_position(pbuffer, --i, *text++ == ETL_STRL('1'));
}
}
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void from_string(pointer pbuffer, size_t number_of_elements, size_t total_bits, const char16_t* text) ETL_NOEXCEPT
{
if (text == ETL_NULLPTR)
{
etl::fill_n(pbuffer, number_of_elements, All_Clear_Element);
}
else
{
size_t string_length = etl::strlen(text);
size_t index = etl::min(number_of_elements - 1U, (string_length / Bits_Per_Element));
// Only reset elements we need to.
while (index != number_of_elements)
{
pbuffer[index++] = All_Clear_Element;
}
// Build from the string.
size_t i = etl::min(total_bits, string_length);
while (i > 0)
{
set_position(pbuffer, --i, *text++ == ETL_STRu('1'));
}
}
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void from_string(pointer pbuffer, size_t number_of_elements, size_t total_bits, const char32_t* text) ETL_NOEXCEPT
{
if (text == ETL_NULLPTR)
{
etl::fill_n(pbuffer, number_of_elements, All_Clear_Element);
}
else
{
size_t string_length = etl::strlen(text);
size_t index = etl::min(number_of_elements - 1U, (string_length / Bits_Per_Element));
// Only reset elements we need to.
while (index != number_of_elements)
{
pbuffer[index++] = All_Clear_Element;
}
// Build from the string.
size_t i = etl::min(total_bits, string_length);
while (i > 0)
{
set_position(pbuffer, --i, *text++ == ETL_STRU('1'));
}
}
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void reset_all(pointer pbuffer, size_t number_of_elements) ETL_NOEXCEPT
{
while (number_of_elements-- != 0U)
{
*pbuffer++ = All_Clear_Element;
}
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void reset_position(pointer pbuffer, size_t position) ETL_NOEXCEPT
{
const size_t index = position >> etl::log2<Bits_Per_Element>::value;
const element_type bit = element_type(1) << (position & (Bits_Per_Element - 1));
pbuffer[index] &= ~bit;
}
//*************************************************************************
//*************************************************************************
template <typename T>
static ETL_CONSTEXPR14 T value(const_pointer pbuffer, size_t number_of_elements) ETL_NOEXCEPT
{
T v = T(0);
const bool OK = (sizeof(T) * CHAR_BIT) >= (number_of_elements * Bits_Per_Element);
if (OK)
{
uint_least8_t shift = 0U;
for (size_t i = 0UL; i < number_of_elements; ++i)
{
v |= T(typename etl::make_unsigned<T>::type(pbuffer[i]) << shift);
shift += uint_least8_t(Bits_Per_Element);
}
}
return v;
}
//*************************************************************************
//*************************************************************************
template <typename T>
static ETL_CONSTEXPR14 typename etl::make_unsigned<T>::type extract_from_multiple_elements(const element_type* pbuffer, size_t element_index,
size_t active_bits_in_msb, size_t length) ETL_NOEXCEPT
{
typedef typename etl::make_unsigned<T>::type unsigned_t;
unsigned_t value(0);
// Extract the first element, if partially filled.
if (active_bits_in_msb < Bits_Per_Element)
{
element_type mask = etl::make_lsb_mask< element_type>(active_bits_in_msb);
value = pbuffer[element_index] & mask;
length -= active_bits_in_msb;
if (length >= Bits_Per_Element)
{
value = value << Bits_Per_Element;
}
--element_index;
}
// Loop through the fully filled elements
while (length >= Bits_Per_Element)
{
value |= pbuffer[element_index];
length -= Bits_Per_Element;
if (length >= Bits_Per_Element)
{
value = value << Bits_Per_Element;
}
--element_index;
}
// Extract the last element, if partially filled.
if (length != 0)
{
value = value << length;
element_type mask = etl::make_lsb_mask< element_type>(length);
value |= (pbuffer[element_index] >> (Bits_Per_Element - length)) & mask;
}
return value;
}
//*************************************************************************
//*************************************************************************
template <typename T>
static ETL_CONSTEXPR14 typename etl::make_unsigned<T>::type extract_from_buffer(const_pointer pbuffer, size_t position, size_t length)
ETL_NOEXCEPT
{
typedef typename etl::make_unsigned<T>::type unsigned_t;
unsigned_t value(0);
const size_t Msb_Element_Index = (position + length - 1) >> etl::log2<Bits_Per_Element>::value;
const size_t Lsb_Element_Index = position >> etl::log2<Bits_Per_Element>::value;
// Is the value contained within one element?
if (Msb_Element_Index == Lsb_Element_Index)
{
const unsigned_t Mask = etl::make_lsb_mask< unsigned_t>(length);
const unsigned_t Shift = position % Bits_Per_Element;
value = static_cast<unsigned_t>(pbuffer[Msb_Element_Index] >> Shift) & Mask;
}
else
{
// Get the number of active bits in the msb element
size_t active_bits_in_msb = (position + length) - (static_cast<size_t>(Msb_Element_Index) * Bits_Per_Element);
// Start with index of the element containing the msb.
size_t element_index = Msb_Element_Index;
value = extract_from_multiple_elements<T>(pbuffer, element_index, active_bits_in_msb, length);
}
return value;
}
//*************************************************************************
//*************************************************************************
template <typename T, size_t Position, size_t Length>
static ETL_CONSTEXPR14
typename etl::enable_if< value_is_in_one_element<Position, Length, Bits_Per_Element>::value, typename etl::make_unsigned<T>::type>::type
extract_from_buffer(const_pointer pbuffer)
{
typedef typename etl::make_unsigned<T>::type unsigned_t;
const size_t Element_Index = (Position + Length - 1) >> etl::log2<Bits_Per_Element>::value;
const unsigned_t Mask = etl::lsb_mask<unsigned_t, Length>::value;
const unsigned_t Shift = Position % Bits_Per_Element;
return static_cast<unsigned_t>(pbuffer[Element_Index] >> Shift) & Mask;
}
//*************************************************************************
//*************************************************************************
template <typename T, size_t Position, size_t Length>
static ETL_CONSTEXPR14
typename etl::enable_if< !value_is_in_one_element<Position, Length, Bits_Per_Element>::value, typename etl::make_unsigned<T>::type>::type
extract_from_buffer(const_pointer pbuffer)
{
// Start with index of the element containing the msb.
const size_t Msb_Element_Index = (Position + Length - 1) >> etl::log2<Bits_Per_Element>::value;
// Get the number of active bits in the first element
const size_t Active_Bits_In_Msb = ((Position + Length - 1) % Bits_Per_Element) + 1;
return extract_from_multiple_elements<T>(pbuffer, Msb_Element_Index, Active_Bits_In_Msb, Length);
}
//*************************************************************************
//*************************************************************************
template <typename T>
static ETL_CONSTEXPR14 T extract(const_pointer pbuffer, size_t position, size_t length = etl::integral_limits<T>::bits)
{
typedef typename etl::make_unsigned<T>::type unsigned_t;
unsigned_t value = extract_from_buffer<unsigned_t>(pbuffer, position, length);
if ((length != etl::integral_limits<T>::bits) && etl::integral_limits<T>::is_signed)
{
value = static_cast<unsigned_t>(etl::sign_extend<T>(static_cast<T>(value), length));
}
return static_cast<T>(value);
}
//*************************************************************************
//*************************************************************************
template <typename T, size_t Position, size_t Length>
static ETL_CONSTEXPR14 T extract(const_pointer pbuffer)
{
typedef typename etl::make_unsigned<T>::type unsigned_t;
unsigned_t value = extract_from_buffer<unsigned_t, Position, Length>(pbuffer);
if ((Length != etl::integral_limits<T>::bits) && etl::integral_limits<T>::is_signed)
{
value = static_cast<unsigned_t>(etl::sign_extend<T>(static_cast<T>(value), Length));
}
return static_cast<T>(value);
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void flip_all(pointer pbuffer, size_t number_of_elements) ETL_NOEXCEPT
{
operator_not(pbuffer, number_of_elements);
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void flip_position(pointer pbuffer, size_t position) ETL_NOEXCEPT
{
const size_t index = position >> etl::log2<Bits_Per_Element>::value;
const element_type bit = element_type(1) << (position & (Bits_Per_Element - 1));
pbuffer[index] ^= bit;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 size_t find_next(const_pointer pbuffer, size_t number_of_elements, size_t total_bits, bool state, size_t position)
ETL_NOEXCEPT
{
// Where to start.
size_t index = position >> log2<Bits_Per_Element>::value;
size_t bit = position & (Bits_Per_Element - 1);
element_type mask = 1 << bit;
// For each element in the bitset...
while (index < number_of_elements)
{
element_type value = pbuffer[index];
// Needs checking?
if ((state && (value != All_Clear_Element)) || (!state && (value != All_Set_Element)))
{
// For each bit in the element...
while ((bit < Bits_Per_Element) && (position < total_bits))
{
// Equal to the required state?
if (((value & mask) != 0) == state)
{
return position;
}
// Move on to the next bit.
mask <<= 1;
++position;
++bit;
}
}
else
{
position += (Bits_Per_Element - bit);
}
// Start at the beginning for all other elements.
bit = 0;
mask = 1;
++index;
}
return npos;
}
//*************************************************************************
//*************************************************************************
template <typename TString>
static ETL_CONSTEXPR14 TString to_string(const_pointer pbuffer, size_t active_bits, typename TString::value_type zero, typename TString::value_type one)
{
TString result;
result.resize(active_bits, '\0');
// Check that the string type can contain the digits.
ETL_ASSERT_OR_RETURN_VALUE(result.size() == active_bits, ETL_ERROR(etl::bitset_string_too_small), result);
for (size_t i = active_bits; i > 0; --i)
{
result[active_bits - i] = test(pbuffer, i - 1) ? one : zero;
}
return result;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void operator_assignment(pointer lhs_pbuffer, const_pointer rhs_pbuffer, size_t number_of_elements) ETL_NOEXCEPT
{
while (number_of_elements-- != 0)
{
*lhs_pbuffer = *rhs_pbuffer;
++lhs_pbuffer;
++rhs_pbuffer;
}
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void operator_and(pointer lhs_pbuffer, const_pointer rhs_pbuffer, size_t number_of_elements) ETL_NOEXCEPT
{
while (number_of_elements-- != 0)
{
*lhs_pbuffer &= *rhs_pbuffer;
++lhs_pbuffer;
++rhs_pbuffer;
}
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void operator_or(pointer lhs_pbuffer, const_pointer rhs_pbuffer, size_t number_of_elements) ETL_NOEXCEPT
{
while (number_of_elements-- != 0)
{
*lhs_pbuffer |= *rhs_pbuffer;
++lhs_pbuffer;
++rhs_pbuffer;
}
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void operator_xor(pointer lhs_pbuffer, const_pointer rhs_pbuffer, size_t number_of_elements) ETL_NOEXCEPT
{
while (number_of_elements-- != 0)
{
*lhs_pbuffer ^= *rhs_pbuffer;
++lhs_pbuffer;
++rhs_pbuffer;
}
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void operator_not(pointer pbuffer, size_t number_of_elements) ETL_NOEXCEPT
{
while (number_of_elements-- != 0)
{
*pbuffer = ~*pbuffer;
++pbuffer;
}
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void operator_shift_left(pointer pbuffer, size_t number_of_elements, size_t active_bits, size_t shift) ETL_NOEXCEPT
{
if (shift >= active_bits)
{
reset_all(pbuffer, number_of_elements);
}
else
{
// The place where the elements are split when shifting.
const size_t split_position = Bits_Per_Element - (shift % Bits_Per_Element);
// Where we are shifting from.
int src_index = int(number_of_elements - (shift / Bits_Per_Element) - 1U);
// Where we are shifting to.
int dst_index = int(number_of_elements - 1U);
// Shift control constants.
const size_t lsb_shift = Bits_Per_Element - split_position;
const size_t msb_shift = split_position;
const element_type lsb_mask = element_type(etl::integral_limits<element_type>::max >> (Bits_Per_Element - split_position));
const element_type msb_mask = etl::integral_limits<element_type>::max - lsb_mask;
const element_type lsb_shifted_mask = element_type(lsb_mask << lsb_shift);
// First lsb.
element_type lsb = element_type((pbuffer[src_index] & lsb_mask) << lsb_shift);
pbuffer[dst_index] = lsb;
--src_index;
// Now do the shifting.
while (src_index >= 0)
{
// Shift msb.
element_type msb = element_type((pbuffer[src_index] & msb_mask) >> msb_shift);
pbuffer[dst_index] = pbuffer[dst_index] | msb;
--dst_index;
// Shift lsb.
lsb = element_type((pbuffer[src_index] & lsb_mask) << lsb_shift);
pbuffer[dst_index] = lsb;
--src_index;
}
// Clear the remaining bits.
// First lsb.
pbuffer[dst_index] &= lsb_shifted_mask;
// The other remaining bytes on the right.
for (int i = 0; i < dst_index; ++i)
{
pbuffer[i] = 0;
}
}
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void operator_shift_right(pointer pbuffer, size_t number_of_elements, size_t active_bits, size_t shift) ETL_NOEXCEPT
{
if (shift >= active_bits)
{
reset_all(pbuffer, number_of_elements);
}
else
{
// The place where the elements are split when shifting.
const size_t split_position = shift % Bits_Per_Element;
// Where we are shifting from.
int src_index = int(shift / Bits_Per_Element);
// Where we are shifting to.
int dst_index = 0;
// Shift control constants.
const size_t lsb_shift = Bits_Per_Element - split_position;
const size_t msb_shift = split_position;
const element_type lsb_mask = element_type(etl::integral_limits<element_type>::max >> (Bits_Per_Element - split_position));
const element_type msb_mask = etl::integral_limits<element_type>::max - lsb_mask;
const element_type msb_shifted_mask = element_type(msb_mask >> msb_shift);
// Now do the shifting.
while (src_index < int(number_of_elements - 1))
{
// Shift msb.
element_type msb = element_type((pbuffer[src_index] & msb_mask) >> msb_shift);
++src_index;
// Shift lsb.
element_type lsb = element_type((pbuffer[src_index] & lsb_mask) << lsb_shift);
// Combine them.
pbuffer[dst_index] = lsb | msb;
++dst_index;
}
// Final msb.
element_type msb = element_type((pbuffer[src_index] & msb_mask) >> msb_shift);
pbuffer[dst_index] = msb;
// Clear the remaining bits.
// First msb.
pbuffer[dst_index] &= msb_shifted_mask;
++dst_index;
// The other remaining bytes.
while (dst_index < int(number_of_elements))
{
pbuffer[dst_index] = 0;
++dst_index;
}
}
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 bool operator_equality(const_pointer lhs_pbuffer, const_pointer rhs_pbuffer, size_t number_of_elements) ETL_NOEXCEPT
{
return etl::equal(lhs_pbuffer, lhs_pbuffer + number_of_elements, rhs_pbuffer);
}
//*************************************************************************
//*************************************************************************
template <typename TElementType>
static
ETL_CONSTEXPR14 typename etl::enable_if< etl::integral_limits<TElementType>::bits == etl::integral_limits<unsigned long long>::bits, void>::type
initialise(pointer pbuffer, size_t number_of_elements, unsigned long long value) ETL_NOEXCEPT
{
size_t i = 0UL;
// Set the non-zero elements.
pbuffer[i++] = value;
// Clear the remaining elements.
while (i != number_of_elements)
{
pbuffer[i++] = All_Clear_Element;
}
}
//*************************************************************************
//*************************************************************************
template <typename TElementType>
static
ETL_CONSTEXPR14 typename etl::enable_if< etl::integral_limits<TElementType>::bits != etl::integral_limits<unsigned long long>::bits, void>::type
initialise(pointer pbuffer, size_t number_of_elements, unsigned long long value) ETL_NOEXCEPT
{
size_t i = 0UL;
// Set the non-zero elements.
const unsigned long long Shift = etl::integral_limits<element_type>::bits;
while ((value != 0) && (i != number_of_elements))
{
pbuffer[i++] = value & All_Set_Element;
value = value >> Shift;
}
// Clear the remaining elements.
while (i != number_of_elements)
{
pbuffer[i++] = All_Clear_Element;
}
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR14 void swap(pointer pbuffer1, pointer pbuffer2, size_t number_of_elements)
{
etl::swap_ranges(pbuffer1, pbuffer1 + number_of_elements, pbuffer2);
}
};
namespace private_bitset
{
//***************************************************************************
template <size_t Active_Bits, typename TElement>
class bitset_common : public etl::private_bitset::bitset_impl_common<TElement>
{
public:
typedef typename etl::private_bitset::bitset_impl_common<TElement>::element_type element_type;
using etl::private_bitset::bitset_impl_common<TElement>::Bits_Per_Element;
using etl::private_bitset::bitset_impl_common<TElement>::All_Set_Element;
using etl::private_bitset::bitset_impl_common< TElement>::All_Clear_Element;
static ETL_CONSTANT size_t Number_Of_Elements =
(Active_Bits % Bits_Per_Element == 0) ? Active_Bits / Bits_Per_Element : Active_Bits / Bits_Per_Element + 1;
static ETL_CONSTANT size_t Size = Active_Bits;
static ETL_CONSTANT size_t Allocated_Bits = Number_Of_Elements * Bits_Per_Element;
#if ETL_USING_CPP11
static ETL_CONSTANT etl::bitset_storage_model Storage_Model =
(bitset_common<Active_Bits, TElement>::Number_Of_Elements == 1U) ? etl::bitset_storage_model::Single : etl::bitset_storage_model::Multi;
#else
static ETL_CONSTANT etl::bitset_storage_model Storage_Model;
#endif
typedef etl::span<element_type, Number_Of_Elements> span_type;
typedef etl::span<const element_type, Number_Of_Elements> const_span_type;
private:
static ETL_CONSTANT size_t Top_Mask_Shift = ((Bits_Per_Element - ((Number_Of_Elements * Bits_Per_Element) - Active_Bits)) % Bits_Per_Element);
public:
static ETL_CONSTANT TElement Top_Mask = element_type(Top_Mask_Shift == 0 ? All_Set_Element : ~(All_Set_Element << Top_Mask_Shift));
};
template <size_t Active_Bits, typename TElement>
ETL_CONSTANT size_t bitset_common<Active_Bits, TElement>::Number_Of_Elements;
template <size_t Active_Bits, typename TElement>
ETL_CONSTANT size_t bitset_common<Active_Bits, TElement>::Size;
#if ETL_USING_CPP11
template <size_t Active_Bits, typename TElement>
ETL_CONSTANT etl::bitset_storage_model bitset_common<Active_Bits, TElement>::Storage_Model;
#else
template <size_t Active_Bits, typename TElement>
ETL_CONSTANT etl::bitset_storage_model bitset_common<Active_Bits, TElement>::Storage_Model =
(bitset_common<Active_Bits, TElement>::Number_Of_Elements == 1U) ? etl::bitset_storage_model::Single : etl::bitset_storage_model::Multi;
#endif
template <size_t Active_Bits, typename TElement>
ETL_CONSTANT size_t bitset_common<Active_Bits, TElement>::Top_Mask_Shift;
template <size_t Active_Bits, typename TElement>
ETL_CONSTANT TElement bitset_common<Active_Bits, TElement>::Top_Mask;
} // namespace private_bitset
//***************************************************************************
//***************************************************************************
template <size_t Active_Bits = 0U, typename TElement = unsigned char>
class bitset;
//***************************************************************************
//***************************************************************************
template <>
class bitset<0U, unsigned char> : public etl::private_bitset::bitset_common<0U, unsigned char>
{
public:
typedef etl::private_bitset::bitset_common<0U, unsigned char>::element_type element_type;
typedef etl::private_bitset::bitset_common<0U, unsigned char>::span_type span_type;
typedef etl::private_bitset::bitset_common< 0U, unsigned char>::const_span_type const_span_type;
using etl::private_bitset::bitset_common<0U, unsigned char>::Bits_Per_Element;
using etl::private_bitset::bitset_common<0U, unsigned char>::All_Set_Element;
using etl::private_bitset::bitset_common<0U, unsigned char>::All_Clear_Element;
using etl::private_bitset::bitset_common<0U, unsigned char>::Number_Of_Elements;
using etl::private_bitset::bitset_common<0U, unsigned char>::Size;
using etl::private_bitset::bitset_common<0U, unsigned char>::Storage_Model;
using etl::private_bitset::bitset_common<0U, unsigned char>::Top_Mask;
using etl::private_bitset::bitset_common<0U, unsigned char>::Allocated_Bits;
};
//*************************************************************************
//*************************************************************************
template <size_t Active_Bits, typename TElement>
class bitset : public etl::private_bitset::bitset_common<Active_Bits, TElement>
{
public:
ETL_STATIC_ASSERT(etl::is_unsigned<TElement>::value, "The element type must be unsigned");
typedef typename etl::private_bitset::bitset_common< Active_Bits, TElement>::element_type element_type;
typedef typename etl::private_bitset::bitset_common< Active_Bits, TElement>::span_type span_type;
typedef typename etl::private_bitset::bitset_common< Active_Bits, TElement>::const_span_type const_span_type;
using etl::private_bitset::bitset_common<Active_Bits, TElement>::Bits_Per_Element;
using etl::private_bitset::bitset_common<Active_Bits, TElement>::All_Set_Element;
using etl::private_bitset::bitset_common<Active_Bits, TElement>::All_Clear_Element;
using etl::private_bitset::bitset_common<Active_Bits, TElement>::Number_Of_Elements;
using etl::private_bitset::bitset_common<Active_Bits, TElement>::Size;
using etl::private_bitset::bitset_common<Active_Bits, TElement>::Storage_Model;
using etl::private_bitset::bitset_common<Active_Bits, TElement>::Top_Mask;
using etl::private_bitset::bitset_common<Active_Bits, TElement>::Allocated_Bits;
//*************************************************************************
//*************************************************************************
class bit_reference
{
public:
friend class bitset;
//*******************************
//*******************************
ETL_CONSTEXPR14 bit_reference(const bit_reference& other) ETL_NOEXCEPT
: p_bitset(other.p_bitset)
, position(other.position)
{
}
//*******************************
//*******************************
ETL_CONSTEXPR14 operator bool() const ETL_NOEXCEPT
{
return p_bitset->test(position);
}
//*******************************
//*******************************
ETL_CONSTEXPR14 bit_reference& operator=(bool b) ETL_NOEXCEPT
{
p_bitset->set(position, b);
return *this;
}
//*******************************
//*******************************
ETL_CONSTEXPR14 bit_reference& operator=(const bit_reference& r) ETL_NOEXCEPT
{
p_bitset->set(position, bool(r));
return *this;
}
//*******************************
//*******************************
ETL_CONSTEXPR14 bit_reference& flip() ETL_NOEXCEPT
{
p_bitset->flip(position);
return *this;
}
//*******************************
//*******************************
ETL_CONSTEXPR14 bool operator~() const ETL_NOEXCEPT
{
return !p_bitset->test(position);
}
private:
//*******************************
//*******************************
ETL_CONSTEXPR14 bit_reference() ETL_NOEXCEPT
: p_bitset(ETL_NULLPTR)
, position(0)
{
}
//*******************************
//*******************************
ETL_CONSTEXPR14 bit_reference(bitset<Active_Bits, TElement>& r_bitset, size_t position_) ETL_NOEXCEPT
: p_bitset(&r_bitset)
, position(position_)
{
}
bitset<Active_Bits, TElement>* p_bitset;
size_t position;
};
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset() ETL_NOEXCEPT
: buffer()
{
implementation::reset_all(buffer, Number_Of_Elements);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset(const bitset<Active_Bits, TElement>& other) ETL_NOEXCEPT
: buffer()
{
implementation::operator_assignment(buffer, other.buffer, Number_Of_Elements);
}
//*************************************************************************
//*************************************************************************
template <typename TValue>
ETL_CONSTEXPR14 bitset(TValue value, typename etl::enable_if<is_integral<TValue>::value>::type* = 0) ETL_NOEXCEPT
: buffer()
{
implementation::template initialise<element_type>(buffer, Number_Of_Elements, static_cast<unsigned long long>(value));
}
//*************************************************************************
//*************************************************************************
template <typename TPString>
ETL_CONSTEXPR14 bitset(TPString text, typename etl::enable_if<is_same<TPString, const char*>::value>::type* = 0) ETL_NOEXCEPT
: buffer()
{
implementation::from_string(buffer, Number_Of_Elements, Active_Bits, text);
}
//*************************************************************************
//*************************************************************************
template <typename TPString>
ETL_CONSTEXPR14 bitset(TPString text, typename etl::enable_if<is_same<TPString, const wchar_t*>::value>::type* = 0) ETL_NOEXCEPT
: buffer()
{
implementation::from_string(buffer, Number_Of_Elements, Active_Bits, text);
}
//*************************************************************************
//*************************************************************************
template <typename TPString>
ETL_CONSTEXPR14 bitset(TPString text, typename etl::enable_if< is_same<TPString, const char16_t*>::value>::type* = 0) ETL_NOEXCEPT
: buffer()
{
implementation::from_string(buffer, Number_Of_Elements, Active_Bits, text);
}
//*************************************************************************
//*************************************************************************
template <typename TPString>
ETL_CONSTEXPR14 bitset(TPString text, typename etl::enable_if< is_same<TPString, const char32_t*>::value>::type* = 0) ETL_NOEXCEPT
: buffer()
{
implementation::from_string(buffer, Number_Of_Elements, Active_Bits, text);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset& operator=(const bitset<Active_Bits, TElement>& other) ETL_NOEXCEPT
{
implementation::operator_assignment(buffer, other.buffer, Number_Of_Elements);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset<Active_Bits, TElement>& set() ETL_NOEXCEPT
{
implementation::set_all(buffer, Number_Of_Elements, Top_Mask);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset<Active_Bits, TElement>& set(size_t position, bool value = true)
{
ETL_ASSERT_OR_RETURN_VALUE(position < Active_Bits, ETL_ERROR(bitset_overflow), *this);
implementation::set_position(buffer, position, value);
return *this;
}
//*************************************************************************
//*************************************************************************
template <size_t Position>
ETL_CONSTEXPR14 bitset<Active_Bits, TElement>& set(bool value = true)
{
ETL_STATIC_ASSERT(Position < Active_Bits, "Position out of bounds");
implementation::template set_position<Position>(buffer, value);
return *this;
}
//*************************************************************************
//*************************************************************************
template <size_t Position, bool Value>
ETL_CONSTEXPR14 bitset<Active_Bits, TElement>& set()
{
ETL_STATIC_ASSERT(Position < Active_Bits, "Position out of bounds");
implementation::template set_position<Position, Value>(buffer);
return *this;
}
//*************************************************************************
//*************************************************************************
template <typename TPString>
ETL_CONSTEXPR14 typename etl::enable_if<etl::is_same<TPString, const char*>::value, bitset<Active_Bits, TElement>&>::type set(TPString text)
ETL_NOEXCEPT
{
implementation::from_string(buffer, Number_Of_Elements, Active_Bits, text);
return *this;
}
//*************************************************************************
//*************************************************************************
template <typename TPString>
ETL_CONSTEXPR14 typename etl::enable_if<etl::is_same<TPString, const wchar_t*>::value, bitset<Active_Bits, TElement>&>::type set(TPString text)
ETL_NOEXCEPT
{
implementation::from_string(buffer, Number_Of_Elements, Active_Bits, text);
return *this;
}
//*************************************************************************
//*************************************************************************
template <typename TPString>
ETL_CONSTEXPR14 typename etl::enable_if<etl::is_same<TPString, const char16_t*>::value, bitset<Active_Bits, TElement>&>::type set(TPString text)
ETL_NOEXCEPT
{
implementation::from_string(buffer, Number_Of_Elements, Active_Bits, text);
return *this;
}
//*************************************************************************
//*************************************************************************
template <typename TPString>
ETL_CONSTEXPR14 typename etl::enable_if<etl::is_same<TPString, const char32_t*>::value, bitset<Active_Bits, TElement>&>::type set(TPString text)
ETL_NOEXCEPT
{
implementation::from_string(buffer, Number_Of_Elements, Active_Bits, text);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset<Active_Bits, TElement>& from_string(const char* text) ETL_NOEXCEPT
{
implementation::from_string(buffer, Number_Of_Elements, Active_Bits, text);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset<Active_Bits, TElement>& from_string(const wchar_t* text) ETL_NOEXCEPT
{
implementation::from_string(buffer, Number_Of_Elements, Active_Bits, text);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset<Active_Bits, TElement>& from_string(const char16_t* text) ETL_NOEXCEPT
{
implementation::from_string(buffer, Number_Of_Elements, Active_Bits, text);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset<Active_Bits, TElement>& from_string(const char32_t* text) ETL_NOEXCEPT
{
implementation::from_string(buffer, Number_Of_Elements, Active_Bits, text);
return *this;
}
//*************************************************************************
//*************************************************************************
template <typename T>
ETL_CONSTEXPR14 typename etl::enable_if<etl::is_integral<T>::value, T>::type value() const ETL_NOEXCEPT
{
ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Only integral types are supported");
ETL_STATIC_ASSERT(etl::integral_limits<T>::bits >= (Number_Of_Elements * Bits_Per_Element), "Type too small");
return implementation::template value<T>(buffer, Number_Of_Elements);
}
//*************************************************************************
//*************************************************************************
template <typename T>
ETL_CONSTEXPR14 T extract(size_t position, size_t length = etl::integral_limits<T>::bits) const
{
ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Only integral types are supported");
ETL_ASSERT_OR_RETURN_VALUE(length <= etl::integral_limits<T>::bits, ETL_ERROR(bitset_overflow), 0);
ETL_ASSERT_OR_RETURN_VALUE((position + length) <= Active_Bits, ETL_ERROR(bitset_overflow), 0);
return implementation::template extract<T>(buffer, position, length);
}
//*************************************************************************
//*************************************************************************
#if ETL_USING_CPP11
template <typename T, size_t Position, size_t Length = etl::integral_limits<T>::bits>
#else
template <typename T, size_t Position, size_t Length>
#endif
ETL_CONSTEXPR14 T extract() const
{
ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Only integral types are supported");
ETL_STATIC_ASSERT(Length <= etl::integral_limits<T>::bits, "Length is larger that the required type");
ETL_STATIC_ASSERT((Position + Length) <= Active_Bits, "Position/Length overflows bitset");
return implementation::template extract<T, Position, Length>(buffer);
}
//*************************************************************************
//*************************************************************************
unsigned long to_ulong() const
{
ETL_ASSERT(etl::integral_limits<unsigned long>::bits >= Active_Bits, ETL_ERROR(etl::bitset_overflow));
return implementation::template value<unsigned long>(buffer, Number_Of_Elements);
}
//*************************************************************************
//*************************************************************************
unsigned long long to_ullong() const
{
ETL_ASSERT(etl::integral_limits<unsigned long long>::bits >= Active_Bits, ETL_ERROR(etl::bitset_overflow));
return implementation::template value<unsigned long long>(buffer, Number_Of_Elements);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset<Active_Bits, TElement>& reset() ETL_NOEXCEPT
{
implementation::reset_all(buffer, Number_Of_Elements);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset<Active_Bits, TElement>& reset(size_t position)
{
ETL_ASSERT_OR_RETURN_VALUE(position < Active_Bits, ETL_ERROR(bitset_overflow), *this);
implementation::reset_position(buffer, position);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bool test(size_t position) const
{
ETL_ASSERT_OR_RETURN_VALUE(position < Active_Bits, ETL_ERROR(bitset_overflow), false);
return implementation::test(buffer, position);
}
//*************************************************************************
//*************************************************************************
template <size_t Position>
ETL_CONSTEXPR14 bool test() const
{
ETL_STATIC_ASSERT(Position < Active_Bits, "Position out of bounds");
return implementation::test(buffer, Position);
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR size_t size() ETL_NOEXCEPT
{
return Active_Bits;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR size_t number_of_elements() ETL_NOEXCEPT
{
return Number_Of_Elements;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR element_type all_set_element() ETL_NOEXCEPT
{
return All_Set_Element;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR element_type all_clear_element() ETL_NOEXCEPT
{
return All_Clear_Element;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR size_t bits_per_element() ETL_NOEXCEPT
{
return Bits_Per_Element;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR element_type top_mask() ETL_NOEXCEPT
{
return Top_Mask;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR size_t allocated_bits() ETL_NOEXCEPT
{
return Number_Of_Elements * Bits_Per_Element;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR etl::bitset_storage_model storage_model() ETL_NOEXCEPT
{
return Storage_Model;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 size_t count() const ETL_NOEXCEPT
{
return implementation::count(buffer, Number_Of_Elements);
}
//*************************************************************************
// Are all the bits sets?
//*************************************************************************
ETL_CONSTEXPR14 bool all() const ETL_NOEXCEPT
{
return implementation::all(buffer, Number_Of_Elements, Top_Mask);
}
//*************************************************************************
// Are all the mask bits sets?
//*************************************************************************
ETL_CONSTEXPR14 bool all(element_type mask) const ETL_NOEXCEPT
{
ETL_STATIC_ASSERT(Storage_Model == etl::bitset_storage_model::Single, "Not supported for 'Multi' bitset storage model");
return implementation::all(buffer, Number_Of_Elements, Top_Mask, mask);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bool none() const ETL_NOEXCEPT
{
return implementation::none(buffer, Number_Of_Elements);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bool none(element_type mask) const ETL_NOEXCEPT
{
ETL_STATIC_ASSERT(Storage_Model == etl::bitset_storage_model::Single, "Not supported for 'Multi' bitset storage model");
return implementation::none(buffer, Number_Of_Elements, mask);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bool any() const ETL_NOEXCEPT
{
return implementation::any(buffer, Number_Of_Elements);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bool any(element_type mask) const ETL_NOEXCEPT
{
ETL_STATIC_ASSERT(Storage_Model == etl::bitset_storage_model::Single, "Not supported for 'Multi' bitset storage model");
return implementation::any(buffer, Number_Of_Elements, mask);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset<Active_Bits, TElement>& flip() ETL_NOEXCEPT
{
implementation::flip_all(buffer, Number_Of_Elements);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset<Active_Bits, TElement>& flip(size_t position)
{
ETL_ASSERT_OR_RETURN_VALUE(position < Active_Bits, ETL_ERROR(bitset_overflow), *this);
implementation::flip_position(buffer, position);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bool operator[](size_t position) const ETL_NOEXCEPT
{
return implementation::test(buffer, position);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bit_reference operator[](size_t position) ETL_NOEXCEPT
{
return bit_reference(*this, position);
}
//*************************************************************************
//*************************************************************************
#if ETL_USING_CPP11
template <typename TString = etl::string<Active_Bits>>
#else
template <typename TString>
#endif
ETL_CONSTEXPR14 TString to_string(typename TString::value_type zero = typename TString::value_type('0'),
typename TString::value_type one = typename TString::value_type('1')) const
{
return implementation::template to_string<TString>(buffer, Active_Bits, zero, one);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 size_t find_first(bool state) const ETL_NOEXCEPT
{
return implementation::find_next(buffer, Number_Of_Elements, Active_Bits, state, 0);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 size_t find_next(bool state, size_t position) const ETL_NOEXCEPT
{
return implementation::find_next(buffer, Number_Of_Elements, Active_Bits, state, position);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset<Active_Bits, TElement> operator&(const bitset<Active_Bits, TElement>& other) const ETL_NOEXCEPT
{
etl::bitset<Active_Bits, TElement> temp(*this);
implementation::operator_and(temp.buffer, other.buffer, Number_Of_Elements);
return temp;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset<Active_Bits, TElement>& operator&=(const bitset<Active_Bits, TElement>& other) ETL_NOEXCEPT
{
implementation::operator_and(buffer, other.buffer, Number_Of_Elements);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset<Active_Bits, TElement> operator|(const bitset<Active_Bits, TElement>& other) const ETL_NOEXCEPT
{
etl::bitset<Active_Bits, TElement> temp(*this);
implementation::operator_or(temp.buffer, other.buffer, Number_Of_Elements);
return temp;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset<Active_Bits, TElement>& operator|=(const bitset<Active_Bits, TElement>& other) ETL_NOEXCEPT
{
implementation::operator_or(&buffer[0], &other.buffer[0], Number_Of_Elements);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset<Active_Bits, TElement> operator^(const bitset<Active_Bits, TElement>& other) const ETL_NOEXCEPT
{
etl::bitset<Active_Bits, TElement> temp(*this);
implementation::operator_xor(temp.buffer, other.buffer, Number_Of_Elements);
return temp;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset<Active_Bits, TElement>& operator^=(const bitset<Active_Bits, TElement>& other) ETL_NOEXCEPT
{
implementation::operator_xor(buffer, other.buffer, Number_Of_Elements);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset<Active_Bits, TElement> operator~() const ETL_NOEXCEPT
{
etl::bitset<Active_Bits, TElement> temp(*this);
implementation::flip_all(temp.buffer, Number_Of_Elements);
return temp;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset<Active_Bits, TElement> operator<<(size_t shift) const ETL_NOEXCEPT
{
etl::bitset<Active_Bits, TElement> temp(*this);
implementation::operator_shift_left(temp.buffer, Number_Of_Elements, Active_Bits, shift);
return temp;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset<Active_Bits, TElement>& operator<<=(size_t shift) ETL_NOEXCEPT
{
if (shift >= Active_Bits)
{
implementation::reset_all(buffer, Number_Of_Elements);
}
else
{
implementation::operator_shift_left(buffer, Number_Of_Elements, Active_Bits, shift);
}
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset<Active_Bits, TElement> operator>>(size_t shift) const ETL_NOEXCEPT
{
bitset<Active_Bits, TElement> temp(*this);
implementation::operator_shift_right(temp.buffer, Number_Of_Elements, Active_Bits, shift);
return temp;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset<Active_Bits, TElement>& operator>>=(size_t shift) ETL_NOEXCEPT
{
if (shift >= Active_Bits)
{
implementation::reset_all(buffer, Number_Of_Elements);
}
else
{
implementation::operator_shift_right(buffer, Number_Of_Elements, Active_Bits, shift);
}
return *this;
}
//*************************************************************************
//*************************************************************************
friend ETL_CONSTEXPR14 bool operator==(const bitset<Active_Bits, TElement>& lhs, const bitset<Active_Bits, TElement>& rhs) ETL_NOEXCEPT
{
return implementation::operator_equality(lhs.buffer, rhs.buffer, lhs.Number_Of_Elements);
}
//*************************************************************************
//*************************************************************************
friend ETL_CONSTEXPR14 bool operator!=(const bitset<Active_Bits, TElement>& lhs, const bitset<Active_Bits, TElement>& rhs) ETL_NOEXCEPT
{
return !(lhs == rhs);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 void swap(etl::bitset<Active_Bits, TElement>& other) ETL_NOEXCEPT
{
implementation::swap(buffer, other.buffer, Number_Of_Elements);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 span_type span() ETL_NOEXCEPT
{
return span_type(buffer, Number_Of_Elements);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 const_span_type span() const ETL_NOEXCEPT
{
return const_span_type(buffer, Number_Of_Elements);
}
private:
// The implementation of the bitset functionality.
typedef etl::bitset_impl<element_type, (Number_Of_Elements == 1U) ? etl::bitset_storage_model::Single : etl::bitset_storage_model::Multi>
implementation;
// The storage for the bitset.
element_type buffer[Number_Of_Elements];
};
//***************************************************************************
//***************************************************************************
template <size_t Active_Bits, typename TElement>
ETL_CONSTEXPR14 bitset<Active_Bits> operator&(const bitset<Active_Bits, TElement>& lhs, const bitset<Active_Bits, TElement>& rhs) ETL_NOEXCEPT
{
bitset<Active_Bits> temp(lhs);
temp &= rhs;
return temp;
}
//***************************************************************************
//***************************************************************************
template <size_t Active_Bits, typename TElement>
ETL_CONSTEXPR14 bitset<Active_Bits> operator|(const bitset<Active_Bits, TElement>& lhs, const bitset<Active_Bits, TElement>& rhs) ETL_NOEXCEPT
{
bitset<Active_Bits> temp(lhs);
temp |= rhs;
return temp;
}
//***************************************************************************
//***************************************************************************
template <size_t Active_Bits, typename TElement>
ETL_CONSTEXPR14 bitset<Active_Bits> operator^(const bitset<Active_Bits, TElement>& lhs, const bitset<Active_Bits, TElement>& rhs) ETL_NOEXCEPT
{
bitset<Active_Bits> temp(lhs);
temp ^= rhs;
return temp;
}
//***************************************************************************
//***************************************************************************
template <size_t Active_Bits, typename TElement>
ETL_CONSTEXPR14 bool operator!=(const etl::bitset<Active_Bits, TElement>& lhs, const etl::bitset<Active_Bits, TElement>& rhs) ETL_NOEXCEPT
{
return !(lhs == rhs);
}
//*************************************************************************
//*************************************************************************
template <size_t Active_Bits, typename TElement>
ETL_CONSTEXPR14 void swap(etl::bitset<Active_Bits, TElement>& lhs, etl::bitset<Active_Bits, TElement>& rhs) ETL_NOEXCEPT
{
lhs.swap(rhs);
}
//***************************************************************************
//***************************************************************************
//***************************************************************************
template <size_t Active_Bits = 0U, typename TElement = unsigned char>
class bitset_ext;
//***************************************************************************
//***************************************************************************
template <>
class bitset_ext<0U, unsigned char> : public etl::private_bitset::bitset_common<0U, unsigned char>
{
public:
typedef size_t size_type;
typedef etl::private_bitset::bitset_common<0U, unsigned char>::element_type element_type;
typedef etl::private_bitset::bitset_common<0U, unsigned char>::span_type span_type;
typedef etl::private_bitset::bitset_common< 0U, unsigned char>::const_span_type const_span_type;
using etl::private_bitset::bitset_common<0U, unsigned char>::Bits_Per_Element;
using etl::private_bitset::bitset_common<0U, unsigned char>::All_Set_Element;
using etl::private_bitset::bitset_common<0U, unsigned char>::All_Clear_Element;
using etl::private_bitset::bitset_common<0U, unsigned char>::Number_Of_Elements;
using etl::private_bitset::bitset_common<0U, unsigned char>::Size;
using etl::private_bitset::bitset_common<0U, unsigned char>::Storage_Model;
using etl::private_bitset::bitset_common<0U, unsigned char>::Top_Mask;
using etl::private_bitset::bitset_common<0U, unsigned char>::Allocated_Bits;
};
//*************************************************************************
//*************************************************************************
template <size_t Active_Bits, typename TElement>
class bitset_ext : public etl::private_bitset::bitset_common<Active_Bits, TElement>
{
public:
ETL_STATIC_ASSERT(etl::is_unsigned<TElement>::value, "The element type must be unsigned");
typedef size_t size_type;
typedef typename etl::private_bitset::bitset_common< Active_Bits, TElement>::element_type element_type;
typedef typename etl::private_bitset::bitset_common< Active_Bits, TElement>::span_type span_type;
typedef typename etl::private_bitset::bitset_common< Active_Bits, TElement>::const_span_type const_span_type;
using etl::private_bitset::bitset_common<Active_Bits, TElement>::Bits_Per_Element;
using etl::private_bitset::bitset_common<Active_Bits, TElement>::All_Set_Element;
using etl::private_bitset::bitset_common<Active_Bits, TElement>::All_Clear_Element;
using etl::private_bitset::bitset_common<Active_Bits, TElement>::Number_Of_Elements;
using etl::private_bitset::bitset_common<Active_Bits, TElement>::Size;
using etl::private_bitset::bitset_common<Active_Bits, TElement>::Storage_Model;
using etl::private_bitset::bitset_common<Active_Bits, TElement>::Top_Mask;
using etl::private_bitset::bitset_common<Active_Bits, TElement>::Allocated_Bits;
typedef etl::array<TElement, Number_Of_Elements> buffer_type;
//*************************************************************************
//*************************************************************************
class bit_reference
{
public:
friend class bitset_ext;
//*******************************
//*******************************
ETL_CONSTEXPR14 bit_reference(const bit_reference& other) ETL_NOEXCEPT
: p_bitset(other.p_bitset)
, position(other.position)
{
}
//*******************************
//*******************************
ETL_CONSTEXPR14 operator bool() const ETL_NOEXCEPT
{
return p_bitset->test(position);
}
//*******************************
//*******************************
ETL_CONSTEXPR14 bit_reference& operator=(bool b) ETL_NOEXCEPT
{
p_bitset->set(position, b);
return *this;
}
//*******************************
//*******************************
ETL_CONSTEXPR14 bit_reference& operator=(const bit_reference& r) ETL_NOEXCEPT
{
p_bitset->set(position, bool(r));
return *this;
}
//*******************************
//*******************************
ETL_CONSTEXPR14 bit_reference& flip() ETL_NOEXCEPT
{
p_bitset->flip(position);
return *this;
}
//*******************************
//*******************************
ETL_CONSTEXPR14 bool operator~() const ETL_NOEXCEPT
{
return !p_bitset->test(position);
}
private:
//*******************************
//*******************************
ETL_CONSTEXPR14 bit_reference() ETL_NOEXCEPT
: p_bitset(ETL_NULLPTR)
, position(0)
{
}
//*******************************
//*******************************
ETL_CONSTEXPR14 bit_reference(bitset_ext<Active_Bits, TElement>& r_bitset, size_t position_) ETL_NOEXCEPT
: p_bitset(&r_bitset)
, position(position_)
{
}
bitset_ext<Active_Bits, TElement>* p_bitset;
size_t position;
};
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 explicit bitset_ext(element_type* pbuffer_)
: pbuffer(pbuffer_)
{
ETL_ASSERT(pbuffer != ETL_NULLPTR, ETL_ERROR(etl::bitset_invalid_buffer));
implementation::reset_all(pbuffer, Number_Of_Elements);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 explicit bitset_ext(buffer_type& buffer)
: pbuffer(buffer.data())
{
ETL_ASSERT(pbuffer != ETL_NULLPTR, ETL_ERROR(etl::bitset_invalid_buffer));
implementation::reset_all(pbuffer, Number_Of_Elements);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset_ext(const bitset_ext<Active_Bits, TElement>& other, element_type* pbuffer_)
: pbuffer(pbuffer_)
{
ETL_ASSERT(pbuffer != ETL_NULLPTR, ETL_ERROR(etl::bitset_invalid_buffer));
implementation::operator_assignment(pbuffer, other.pbuffer, Number_Of_Elements);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset_ext(const bitset_ext<Active_Bits, TElement>& other, buffer_type& buffer) ETL_NOEXCEPT
: pbuffer(buffer.data())
{
implementation::operator_assignment(pbuffer, other.pbuffer, Number_Of_Elements);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset_ext(const bitset_ext<Active_Bits, TElement>& other) ETL_NOEXCEPT ETL_DELETE;
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset_ext(unsigned long long value, element_type* pbuffer_)
: pbuffer(pbuffer_)
{
ETL_ASSERT(pbuffer != ETL_NULLPTR, ETL_ERROR(etl::bitset_invalid_buffer));
implementation::template initialise<element_type>(pbuffer, Number_Of_Elements, value);
}
//*************************************************************************
//*************************************************************************
template <typename TValue>
ETL_CONSTEXPR14 bitset_ext(TValue value, buffer_type& buffer, typename etl::enable_if<is_integral<TValue>::value>::type* = 0) ETL_NOEXCEPT
: pbuffer(buffer.data())
{
implementation::template initialise<element_type>(pbuffer, Number_Of_Elements, static_cast<unsigned long long>(value));
}
//*************************************************************************
//*************************************************************************
template <typename TPString>
ETL_CONSTEXPR14 bitset_ext(TPString text, element_type* pbuffer_, typename etl::enable_if<is_same<TPString, const char*>::value>::type* = 0)
: pbuffer(pbuffer_)
{
ETL_ASSERT(pbuffer != ETL_NULLPTR, ETL_ERROR(etl::bitset_invalid_buffer));
implementation::from_string(pbuffer, Number_Of_Elements, Active_Bits, text);
}
//*************************************************************************
//*************************************************************************
template <typename TPString>
ETL_CONSTEXPR14 bitset_ext(TPString text, buffer_type& buffer, typename etl::enable_if<is_same<TPString, const char*>::value>::type* = 0)
ETL_NOEXCEPT
: pbuffer(buffer.data())
{
implementation::from_string(pbuffer, Number_Of_Elements, Active_Bits, text);
}
//*************************************************************************
//*************************************************************************
template <typename TPString>
ETL_CONSTEXPR14 bitset_ext(TPString text, element_type* pbuffer_, typename etl::enable_if<is_same<TPString, const wchar_t*>::value>::type* = 0)
: pbuffer(pbuffer_)
{
ETL_ASSERT(pbuffer != ETL_NULLPTR, ETL_ERROR(etl::bitset_invalid_buffer));
implementation::from_string(pbuffer, Number_Of_Elements, Active_Bits, text);
}
//*************************************************************************
//*************************************************************************
template <typename TPString>
ETL_CONSTEXPR14 bitset_ext(TPString text, buffer_type& buffer, typename etl::enable_if<is_same<TPString, const wchar_t*>::value>::type* = 0)
ETL_NOEXCEPT
: pbuffer(buffer.data())
{
implementation::from_string(pbuffer, Number_Of_Elements, Active_Bits, text);
}
//*************************************************************************
//*************************************************************************
template <typename TPString>
ETL_CONSTEXPR14 bitset_ext(TPString text, element_type* pbuffer_, typename etl::enable_if< is_same<TPString, const char16_t*>::value>::type* = 0)
: pbuffer(pbuffer_)
{
ETL_ASSERT(pbuffer != ETL_NULLPTR, ETL_ERROR(etl::bitset_invalid_buffer));
implementation::from_string(pbuffer, Number_Of_Elements, Active_Bits, text);
}
//*************************************************************************
//*************************************************************************
template <typename TPString>
ETL_CONSTEXPR14 bitset_ext(TPString text, buffer_type& buffer, typename etl::enable_if< is_same<TPString, const char16_t*>::value>::type* = 0)
ETL_NOEXCEPT
: pbuffer(buffer.data())
{
implementation::from_string(pbuffer, Number_Of_Elements, Active_Bits, text);
}
//*************************************************************************
//*************************************************************************
template <typename TPString>
ETL_CONSTEXPR14 bitset_ext(TPString text, element_type* pbuffer_, typename etl::enable_if< is_same<TPString, const char32_t*>::value>::type* = 0)
: pbuffer(pbuffer_)
{
ETL_ASSERT(pbuffer != ETL_NULLPTR, ETL_ERROR(etl::bitset_invalid_buffer));
implementation::from_string(pbuffer, Number_Of_Elements, Active_Bits, text);
}
//*************************************************************************
//*************************************************************************
template <typename TPString>
ETL_CONSTEXPR14 bitset_ext(TPString text, buffer_type& buffer, typename etl::enable_if< is_same<TPString, const char32_t*>::value>::type* = 0)
ETL_NOEXCEPT
: pbuffer(buffer.data())
{
implementation::from_string(pbuffer, Number_Of_Elements, Active_Bits, text);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset_ext& operator=(const bitset_ext<Active_Bits, TElement>& other) ETL_NOEXCEPT
{
implementation::operator_assignment(pbuffer, other.pbuffer, Number_Of_Elements);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset_ext<Active_Bits, TElement>& set() ETL_NOEXCEPT
{
implementation::set_all(pbuffer, Number_Of_Elements, Top_Mask);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset_ext<Active_Bits, TElement>& set(size_t position, bool value = true)
{
ETL_ASSERT_OR_RETURN_VALUE(position < Active_Bits, ETL_ERROR(bitset_overflow), *this);
implementation::set_position(pbuffer, position, value);
return *this;
}
//*************************************************************************
//*************************************************************************
template <size_t Position>
ETL_CONSTEXPR14 bitset_ext<Active_Bits, TElement>& set(bool value = true)
{
ETL_STATIC_ASSERT(Position < Active_Bits, "Position out of bounds");
implementation::template set_position<Position>(pbuffer, value);
return *this;
}
//*************************************************************************
//*************************************************************************
template <size_t Position, bool Value>
ETL_CONSTEXPR14 bitset_ext<Active_Bits, TElement>& set()
{
ETL_STATIC_ASSERT(Position < Active_Bits, "Position out of bounds");
implementation::template set_position<Position, Value>(pbuffer);
return *this;
}
//*************************************************************************
//*************************************************************************
template <typename TPString>
ETL_CONSTEXPR14 typename etl::enable_if<etl::is_same<TPString, const char*>::value, bitset_ext<Active_Bits, TElement>&>::type set(TPString text)
ETL_NOEXCEPT
{
implementation::from_string(pbuffer, Number_Of_Elements, Active_Bits, text);
return *this;
}
//*************************************************************************
//*************************************************************************
template <typename TPString>
ETL_CONSTEXPR14 typename etl::enable_if<etl::is_same<TPString, const wchar_t*>::value, bitset_ext<Active_Bits, TElement>&>::type
set(TPString text) ETL_NOEXCEPT
{
implementation::from_string(pbuffer, Number_Of_Elements, Active_Bits, text);
return *this;
}
//*************************************************************************
//*************************************************************************
template <typename TPString>
ETL_CONSTEXPR14 typename etl::enable_if<etl::is_same<TPString, const char16_t*>::value, bitset_ext<Active_Bits, TElement>&>::type
set(TPString text) ETL_NOEXCEPT
{
implementation::from_string(pbuffer, Number_Of_Elements, Active_Bits, text);
return *this;
}
//*************************************************************************
//*************************************************************************
template <typename TPString>
ETL_CONSTEXPR14 typename etl::enable_if<etl::is_same<TPString, const char32_t*>::value, bitset_ext<Active_Bits, TElement>&>::type
set(TPString text) ETL_NOEXCEPT
{
implementation::from_string(pbuffer, Number_Of_Elements, Active_Bits, text);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset_ext<Active_Bits, TElement>& from_string(const char* text) ETL_NOEXCEPT
{
implementation::from_string(pbuffer, Number_Of_Elements, Active_Bits, text);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset_ext<Active_Bits, TElement>& from_string(const wchar_t* text) ETL_NOEXCEPT
{
implementation::from_string(pbuffer, Number_Of_Elements, Active_Bits, text);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset_ext<Active_Bits, TElement>& from_string(const char16_t* text) ETL_NOEXCEPT
{
implementation::from_string(pbuffer, Number_Of_Elements, Active_Bits, text);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset_ext<Active_Bits, TElement>& from_string(const char32_t* text) ETL_NOEXCEPT
{
implementation::from_string(pbuffer, Number_Of_Elements, Active_Bits, text);
return *this;
}
//*************************************************************************
//*************************************************************************
template <typename T>
ETL_CONSTEXPR14 T value() const ETL_NOEXCEPT
{
ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Only integral types are supported");
ETL_STATIC_ASSERT(etl::integral_limits<T>::bits >= (Number_Of_Elements * Bits_Per_Element), "Type too small");
return implementation::template value<T>(pbuffer, Number_Of_Elements);
}
//*************************************************************************
//*************************************************************************
template <typename T>
ETL_CONSTEXPR14 T extract(size_t position, size_t length = etl::integral_limits<T>::bits)
{
ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Only integral types are supported");
ETL_ASSERT_OR_RETURN_VALUE(length <= etl::integral_limits<T>::bits, ETL_ERROR(bitset_overflow), 0);
ETL_ASSERT_OR_RETURN_VALUE((position + length) <= Active_Bits, ETL_ERROR(bitset_overflow), 0);
return implementation::template extract<T>(pbuffer, position, length);
}
//*************************************************************************
//*************************************************************************
#if ETL_USING_CPP11
template <typename T, size_t Position, size_t Length = etl::integral_limits<T>::bits>
#else
template <typename T, size_t Position, size_t Length>
#endif
ETL_CONSTEXPR14 T extract() const
{
ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Only integral types are supported");
ETL_STATIC_ASSERT(Length <= etl::integral_limits<T>::bits, "Length is larger that the required type");
ETL_STATIC_ASSERT((Position + Length) <= Active_Bits, "Position/Length overflows bitset");
return implementation::template extract<T, Position, Length>(pbuffer);
}
//*************************************************************************
//*************************************************************************
unsigned long to_ulong() const
{
ETL_ASSERT(etl::integral_limits<unsigned long>::bits >= Active_Bits, ETL_ERROR(etl::bitset_overflow));
return implementation::template value<unsigned long>(pbuffer, Number_Of_Elements);
}
//*************************************************************************
//*************************************************************************
unsigned long long to_ullong() const
{
ETL_ASSERT(etl::integral_limits<unsigned long long>::bits >= Active_Bits, ETL_ERROR(etl::bitset_overflow));
return implementation::template value<unsigned long long>(pbuffer, Number_Of_Elements);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset_ext<Active_Bits, TElement>& reset() ETL_NOEXCEPT
{
implementation::reset_all(pbuffer, Number_Of_Elements);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset_ext<Active_Bits, TElement>& reset(size_t position)
{
ETL_ASSERT_OR_RETURN_VALUE(position < Active_Bits, ETL_ERROR(bitset_overflow), *this);
implementation::reset_position(pbuffer, position);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bool test(size_t position) const
{
ETL_ASSERT_OR_RETURN_VALUE(position < Active_Bits, ETL_ERROR(bitset_overflow), false);
return implementation::test(pbuffer, position);
}
//*************************************************************************
//*************************************************************************
template <size_t Position>
ETL_CONSTEXPR14 bool test() const
{
ETL_STATIC_ASSERT(Position < Active_Bits, "Position out of bounds");
return implementation::test(pbuffer, Position);
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR size_t size() ETL_NOEXCEPT
{
return Active_Bits;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR size_t number_of_elements() ETL_NOEXCEPT
{
return Number_Of_Elements;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR element_type all_set_element() ETL_NOEXCEPT
{
return All_Set_Element;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR element_type all_clear_element() ETL_NOEXCEPT
{
return All_Clear_Element;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR element_type top_mask() ETL_NOEXCEPT
{
return Top_Mask;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR size_t bits_per_element() ETL_NOEXCEPT
{
return Bits_Per_Element;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR size_t allocated_bits() ETL_NOEXCEPT
{
return Number_Of_Elements * Bits_Per_Element;
}
//*************************************************************************
//*************************************************************************
static ETL_CONSTEXPR etl::bitset_storage_model storage_model() ETL_NOEXCEPT
{
return Storage_Model;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 size_t count() const ETL_NOEXCEPT
{
return implementation::count(pbuffer, Number_Of_Elements);
}
//*************************************************************************
// Are all the bits sets?
//*************************************************************************
ETL_CONSTEXPR14 bool all() const ETL_NOEXCEPT
{
return implementation::all(pbuffer, Number_Of_Elements, Top_Mask);
}
//*************************************************************************
// Are all the mask bits sets?
//*************************************************************************
ETL_CONSTEXPR14 bool all(element_type mask) const ETL_NOEXCEPT
{
ETL_STATIC_ASSERT(Storage_Model == etl::bitset_storage_model::Single, "Not supported for 'Multi' bitset storage model");
return implementation::all(pbuffer, Number_Of_Elements, Top_Mask, mask);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bool none() const ETL_NOEXCEPT
{
return implementation::none(pbuffer, Number_Of_Elements);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bool none(element_type mask) const ETL_NOEXCEPT
{
ETL_STATIC_ASSERT(Storage_Model == etl::bitset_storage_model::Single, "Not supported for 'Multi' bitset storage model");
return implementation::none(pbuffer, Number_Of_Elements, mask);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bool any() const ETL_NOEXCEPT
{
return implementation::any(pbuffer, Number_Of_Elements);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bool any(element_type mask) const ETL_NOEXCEPT
{
ETL_STATIC_ASSERT(Storage_Model == etl::bitset_storage_model::Single, "Not supported for 'Multi' bitset storage model");
return implementation::any(pbuffer, Number_Of_Elements, mask);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset_ext<Active_Bits, TElement>& flip() ETL_NOEXCEPT
{
implementation::flip_all(pbuffer, Number_Of_Elements);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset_ext<Active_Bits, TElement>& flip(size_t position)
{
ETL_ASSERT_OR_RETURN_VALUE(position < Active_Bits, ETL_ERROR(bitset_overflow), *this);
implementation::flip_position(pbuffer, position);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bool operator[](size_t position) const ETL_NOEXCEPT
{
return implementation::test(pbuffer, position);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bit_reference operator[](size_t position) ETL_NOEXCEPT
{
return bit_reference(*this, position);
}
//*************************************************************************
//*************************************************************************
#if ETL_USING_CPP11
template <typename TString = etl::string<Active_Bits>>
#else
template <typename TString>
#endif
ETL_CONSTEXPR14 TString to_string(typename TString::value_type zero = typename TString::value_type('0'),
typename TString::value_type one = typename TString::value_type('1')) const
{
return implementation::template to_string<TString>(pbuffer, Active_Bits, zero, one);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 size_t find_first(bool state) const ETL_NOEXCEPT
{
return implementation::find_next(pbuffer, Number_Of_Elements, Active_Bits, state, 0);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 size_t find_next(bool state, size_t position) const ETL_NOEXCEPT
{
return implementation::find_next(pbuffer, Number_Of_Elements, Active_Bits, state, position);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset_ext<Active_Bits, TElement>& operator&=(const bitset_ext<Active_Bits, TElement>& other) ETL_NOEXCEPT
{
implementation::operator_and(&pbuffer[0], &other.pbuffer[0], Number_Of_Elements);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset_ext<Active_Bits, TElement>& operator|=(const bitset_ext<Active_Bits, TElement>& other) ETL_NOEXCEPT
{
implementation::operator_or(&pbuffer[0], &other.pbuffer[0], Number_Of_Elements);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset_ext<Active_Bits, TElement>& operator^=(const bitset_ext<Active_Bits, TElement>& other) ETL_NOEXCEPT
{
implementation::operator_xor(&pbuffer[0], &other.pbuffer[0], Number_Of_Elements);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset_ext<Active_Bits, TElement>& operator<<=(size_t shift) ETL_NOEXCEPT
{
implementation::operator_shift_left(pbuffer, Number_Of_Elements, Active_Bits, shift);
return *this;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bitset_ext<Active_Bits, TElement>& operator>>=(size_t shift) ETL_NOEXCEPT
{
implementation::operator_shift_right(pbuffer, Number_Of_Elements, Active_Bits, shift);
return *this;
}
//*************************************************************************
//*************************************************************************
friend ETL_CONSTEXPR14 bool operator==(const bitset_ext<Active_Bits, TElement>& lhs, const bitset_ext<Active_Bits, TElement>& rhs) ETL_NOEXCEPT
{
return implementation::operator_equality(lhs.pbuffer, rhs.pbuffer, lhs.Number_Of_Elements);
}
//*************************************************************************
//*************************************************************************
friend ETL_CONSTEXPR14 bool operator!=(const bitset_ext<Active_Bits, TElement>& lhs, const bitset_ext<Active_Bits, TElement>& rhs) ETL_NOEXCEPT
{
return !(lhs == rhs);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 void swap(etl::bitset_ext<Active_Bits, TElement>& other) ETL_NOEXCEPT
{
implementation::swap(pbuffer, other.pbuffer, Number_Of_Elements);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 span_type span() ETL_NOEXCEPT
{
return span_type(pbuffer, Number_Of_Elements);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 const_span_type span() const ETL_NOEXCEPT
{
return const_span_type(pbuffer, Number_Of_Elements);
}
private:
// The implementation of the bitset functionality.
typedef etl::bitset_impl<element_type, (Number_Of_Elements == 1U) ? etl::bitset_storage_model::Single : etl::bitset_storage_model::Multi>
implementation;
// Pointer to the storage for the bitset.
element_type* pbuffer;
};
//***************************************************************************
//***************************************************************************
template <size_t Active_Bits, typename TElement>
ETL_CONSTEXPR14 bool operator!=(const etl::bitset_ext<Active_Bits, TElement>& lhs, const etl::bitset_ext<Active_Bits, TElement>& rhs) ETL_NOEXCEPT
{
return !(lhs == rhs);
}
//*************************************************************************
//*************************************************************************
template <size_t Active_Bits, typename TElement>
ETL_CONSTEXPR14 void swap(etl::bitset_ext<Active_Bits, TElement>& lhs, etl::bitset_ext<Active_Bits, TElement>& rhs) ETL_NOEXCEPT
{
lhs.swap(rhs);
}
namespace private_bitset
{
//*************************************************************************
//*************************************************************************
template <typename TLhsSpan, typename TRhsSpan>
bool compare_bitset_spans(const TLhsSpan& lhs_span, const TRhsSpan& rhs_span)
{
typedef typename TLhsSpan::value_type lhs_element_t;
typedef typename TRhsSpan::value_type rhs_element_t;
const int steps = static_cast<int>(sizeof(lhs_element_t) / sizeof(rhs_element_t));
typename TLhsSpan::iterator lhs_itr = lhs_span.begin();
typename TRhsSpan::iterator rhs_itr = rhs_span.begin();
while (lhs_itr != lhs_span.end())
{
const lhs_element_t& lhs_value = *lhs_itr;
// Build the rhs element in terms of the lhs element type.
lhs_element_t rhs_value = 0;
const int shift_step = etl::integral_limits<rhs_element_t>::bits;
int shift = 0;
for (int i = 0; i < steps; ++i)
{
rhs_value |= (static_cast<lhs_element_t>(*rhs_itr) << shift);
++rhs_itr;
shift += shift_step;
}
if (lhs_value != rhs_value)
{
return false;
}
++lhs_itr;
}
return true;
}
} // namespace private_bitset
//***************************************************************************
//***************************************************************************
template <size_t Active_Bits, typename TLhsElement, typename TRhsElement>
ETL_CONSTEXPR14 typename etl::enable_if<!etl::is_same<TLhsElement, TRhsElement>::value, bool>::type
operator==(const etl::bitset<Active_Bits, TLhsElement>& lhs, const etl::bitset<Active_Bits, TRhsElement>& rhs) ETL_NOEXCEPT
{
// Get a span of each type.
typename etl::bitset<Active_Bits, TLhsElement>::const_span_type lhs_span = lhs.span();
typename etl::bitset<Active_Bits, TRhsElement>::const_span_type rhs_span = rhs.span();
// Put the bitset with the largest element type as the first argument.
if ETL_IF_CONSTEXPR (sizeof(TLhsElement) > sizeof(TRhsElement))
{
return etl::private_bitset::compare_bitset_spans(lhs_span, rhs_span);
}
else
{
return etl::private_bitset::compare_bitset_spans(rhs_span, lhs_span);
}
}
//***************************************************************************
//***************************************************************************
template <size_t Active_Bits, typename TLhsElement, typename TRhsElement>
ETL_CONSTEXPR14 typename etl::enable_if<!etl::is_same<TLhsElement, TRhsElement>::value, bool>::type
operator!=(const etl::bitset<Active_Bits, TLhsElement>& lhs, const etl::bitset<Active_Bits, TRhsElement>& rhs) ETL_NOEXCEPT
{
return !(lhs == rhs);
}
//***************************************************************************
//***************************************************************************
template <size_t Active_Bits, typename TLhsElement, typename TRhsElement>
ETL_CONSTEXPR14 typename etl::enable_if<!etl::is_same<TLhsElement, TRhsElement>::value, bool>::type
operator==(const etl::bitset_ext<Active_Bits, TLhsElement>& lhs, const etl::bitset_ext<Active_Bits, TRhsElement>& rhs) ETL_NOEXCEPT
{
// Get a span of each type.
typename etl::bitset_ext<Active_Bits, TLhsElement>::const_span_type lhs_span = lhs.span();
typename etl::bitset_ext<Active_Bits, TRhsElement>::const_span_type rhs_span = rhs.span();
// Put the bitset with the largest element type as the first argument.
if ETL_IF_CONSTEXPR (sizeof(TLhsElement) > sizeof(TRhsElement))
{
return etl::private_bitset::compare_bitset_spans(lhs_span, rhs_span);
}
else
{
return etl::private_bitset::compare_bitset_spans(rhs_span, lhs_span);
}
}
//***************************************************************************
//***************************************************************************
template <size_t Active_Bits, typename TLhsElement, typename TRhsElement>
ETL_CONSTEXPR14 typename etl::enable_if<!etl::is_same<TLhsElement, TRhsElement>::value, bool>::type
operator!=(const etl::bitset_ext<Active_Bits, TLhsElement>& lhs, const etl::bitset_ext<Active_Bits, TRhsElement>& rhs) ETL_NOEXCEPT
{
return !(lhs == rhs);
}
//***************************************************************************
//***************************************************************************
template <size_t Active_Bits, typename TElement>
ETL_CONSTEXPR14 bool operator==(const etl::bitset<Active_Bits, TElement>& lhs, const etl::bitset_ext<Active_Bits, TElement>& rhs) ETL_NOEXCEPT
{
const char Storage_Model = etl::bitset<Active_Bits, TElement>::Storage_Model;
const size_t Number_Of_Elements = etl::bitset<Active_Bits, TElement>::Number_Of_Elements;
typename etl::bitset<Active_Bits, TElement>::const_span_type lhs_span = lhs.span();
typename etl::bitset_ext<Active_Bits, TElement>::const_span_type rhs_span = rhs.span();
typedef etl::bitset_impl<TElement, Storage_Model> implementation;
return implementation::operator_equality(lhs_span.begin(), rhs_span.begin(), Number_Of_Elements);
}
//***************************************************************************
//***************************************************************************
template <size_t Active_Bits, typename TElement>
ETL_CONSTEXPR14 bool operator!=(const etl::bitset<Active_Bits, TElement>& lhs, const etl::bitset_ext<Active_Bits, TElement>& rhs) ETL_NOEXCEPT
{
return !(lhs == rhs);
}
//***************************************************************************
//***************************************************************************
template <size_t Active_Bits, typename TElement>
ETL_CONSTEXPR14 bool operator==(const etl::bitset_ext<Active_Bits, TElement>& lhs, const etl::bitset<Active_Bits, TElement>& rhs) ETL_NOEXCEPT
{
const char Storage_Model = etl::bitset<Active_Bits, TElement>::Storage_Model;
const size_t Number_Of_Elements = etl::bitset<Active_Bits, TElement>::Number_Of_Elements;
typename etl::bitset_ext<Active_Bits, TElement>::const_span_type lhs_span = lhs.span();
typename etl::bitset<Active_Bits, TElement>::const_span_type rhs_span = rhs.span();
typedef etl::bitset_impl<TElement, Storage_Model> implementation;
return implementation::operator_equality(lhs_span.begin(), rhs_span.begin(), Number_Of_Elements);
}
//***************************************************************************
//***************************************************************************
template <size_t Active_Bits, typename TElement>
ETL_CONSTEXPR14 bool operator!=(const etl::bitset_ext<Active_Bits, TElement>& lhs, const etl::bitset<Active_Bits, TElement>& rhs) ETL_NOEXCEPT
{
return !(lhs == rhs);
}
//***************************************************************************
//***************************************************************************
template <size_t Active_Bits, typename TLhsElement, typename TRhsElement>
ETL_CONSTEXPR14 typename etl::enable_if<!etl::is_same<TLhsElement, TRhsElement>::value, bool>::type
operator==(const etl::bitset<Active_Bits, TLhsElement>& lhs, const etl::bitset_ext<Active_Bits, TRhsElement>& rhs) ETL_NOEXCEPT
{
// Get a span of each type.
typename etl::bitset<Active_Bits, TLhsElement>::const_span_type lhs_span = lhs.span();
typename etl::bitset_ext<Active_Bits, TRhsElement>::const_span_type rhs_span = rhs.span();
// Put the bitset with the largest element type as the first argument.
if ETL_IF_CONSTEXPR (sizeof(TLhsElement) > sizeof(TRhsElement))
{
return etl::private_bitset::compare_bitset_spans(lhs_span, rhs_span);
}
else
{
return etl::private_bitset::compare_bitset_spans(rhs_span, lhs_span);
}
}
//***************************************************************************
//***************************************************************************
template <size_t Active_Bits, typename TLhsElement, typename TRhsElement>
ETL_CONSTEXPR14 typename etl::enable_if<!etl::is_same<TLhsElement, TRhsElement>::value, bool>::type
operator!=(const etl::bitset<Active_Bits, TLhsElement>& lhs, const etl::bitset_ext<Active_Bits, TRhsElement>& rhs) ETL_NOEXCEPT
{
return !(lhs == rhs);
}
//***************************************************************************
//***************************************************************************
template <size_t Active_Bits, typename TLhsElement, typename TRhsElement>
ETL_CONSTEXPR14 typename etl::enable_if<!etl::is_same<TLhsElement, TRhsElement>::value, bool>::type
operator==(const etl::bitset_ext<Active_Bits, TLhsElement>& lhs, const etl::bitset<Active_Bits, TRhsElement>& rhs) ETL_NOEXCEPT
{
// Get a span of each type.
typename etl::bitset_ext<Active_Bits, TLhsElement>::const_span_type lhs_span = lhs.span();
typename etl::bitset<Active_Bits, TRhsElement>::const_span_type rhs_span = rhs.span();
// Put the bitset with the largest element type as the first argument.
if ETL_IF_CONSTEXPR (sizeof(TLhsElement) > sizeof(TRhsElement))
{
return etl::private_bitset::compare_bitset_spans(lhs_span, rhs_span);
}
else
{
return etl::private_bitset::compare_bitset_spans(rhs_span, lhs_span);
}
}
//***************************************************************************
//***************************************************************************
template <size_t Active_Bits, typename TLhsElement, typename TRhsElement>
ETL_CONSTEXPR14 typename etl::enable_if<!etl::is_same<TLhsElement, TRhsElement>::value, bool>::type
operator!=(const etl::bitset_ext<Active_Bits, TLhsElement>& lhs, const etl::bitset<Active_Bits, TRhsElement>& rhs) ETL_NOEXCEPT
{
return !(lhs == rhs);
}
} // namespace etl
#include "minmax_pop.h"
#endif
algorithm.h
binary.h
etl::private_bitset::compare_bitset_spans
bool compare_bitset_spans(const TLhsSpan &lhs_span, const TRhsSpan &rhs_span)
Definition bitset_new.h:3444
char_traits.h
etl::bitset::bit_reference
The reference type returned.
Definition bitset_new.h:1712
etl::bitset::bit_reference::bit_reference
ETL_CONSTEXPR14 bit_reference(const bit_reference &other) ETL_NOEXCEPT
Copy constructor.
Definition bitset_new.h:1720
etl::bitset::bit_reference::operator=
ETL_CONSTEXPR14 bit_reference & operator=(const bit_reference &r) ETL_NOEXCEPT
Assignment operator.
Definition bitset_new.h:1746
etl::bitset::bit_reference::operator=
ETL_CONSTEXPR14 bit_reference & operator=(bool b) ETL_NOEXCEPT
Assignment operator.
Definition bitset_new.h:1737
etl::bitset::bit_reference::flip
ETL_CONSTEXPR14 bit_reference & flip() ETL_NOEXCEPT
Flip the bit.
Definition bitset_new.h:1755
etl::bitset::bit_reference::operator~
ETL_CONSTEXPR14 bool operator~() const ETL_NOEXCEPT
Return the logical inverse of the bit.
Definition bitset_new.h:1764
etl::bitset_ext::bit_reference
The reference type returned.
Definition bitset_new.h:2625
etl::bitset_ext::bit_reference::operator=
ETL_CONSTEXPR14 bit_reference & operator=(bool b) ETL_NOEXCEPT
Assignment operator.
Definition bitset_new.h:2650
etl::bitset_ext::bit_reference::operator=
ETL_CONSTEXPR14 bit_reference & operator=(const bit_reference &r) ETL_NOEXCEPT
Assignment operator.
Definition bitset_new.h:2659
etl::bitset_ext::bit_reference::flip
ETL_CONSTEXPR14 bit_reference & flip() ETL_NOEXCEPT
Flip the bit.
Definition bitset_new.h:2668
etl::bitset_ext::bit_reference::operator~
ETL_CONSTEXPR14 bool operator~() const ETL_NOEXCEPT
Return the logical inverse of the bit.
Definition bitset_new.h:2677
etl::bitset_ext::bit_reference::bit_reference
ETL_CONSTEXPR14 bit_reference(const bit_reference &other) ETL_NOEXCEPT
Copy constructor.
Definition bitset_new.h:2633
etl::bitset_ext
bitset_ext
Definition bitset_new.h:2599
etl::bitset_ext::set
ETL_CONSTEXPR14 etl::enable_if< etl::is_same< TPString, constchar32_t * >::value, bitset_ext< Active_Bits, TElement > & >::type set(TPString text) ETL_NOEXCEPT
Set from a char32 string.
Definition bitset_new.h:2957
etl::bitset_ext::extract
ETL_CONSTEXPR14 T extract() const
Definition bitset_new.h:3040
etl::bitset_ext::set
ETL_CONSTEXPR14 etl::enable_if< etl::is_same< TPString, constwchar_t * >::value, bitset_ext< Active_Bits, TElement > & >::type set(TPString text) ETL_NOEXCEPT
Set from a wide string.
Definition bitset_new.h:2933
etl::bitset_ext::from_string
ETL_CONSTEXPR14 bitset_ext< Active_Bits, TElement > & from_string(const char32_t *text) ETL_NOEXCEPT
Set from a u32 string.
Definition bitset_new.h:2997
etl::bitset_ext::operator=
ETL_CONSTEXPR14 bitset_ext & operator=(const bitset_ext< Active_Bits, TElement > &other) ETL_NOEXCEPT
Assignment operator.
Definition bitset_new.h:2861
etl::bitset_ext::any
ETL_CONSTEXPR14 bool any() const ETL_NOEXCEPT
Are any of the bits set?
Definition bitset_new.h:3228
etl::bitset_ext::bitset_ext
ETL_CONSTEXPR14 bitset_ext(TPString text, buffer_type &buffer, typename etl::enable_if< is_same< TPString, const char16_t * >::value >::type *=0) ETL_NOEXCEPT
Construct from a string.
Definition bitset_new.h:2829
etl::bitset_ext::all_set_element
static ETL_CONSTEXPR element_type all_set_element() ETL_NOEXCEPT
The value of a set element.
Definition bitset_new.h:3134
etl::bitset_ext::swap
ETL_CONSTEXPR14 void swap(etl::bitset_ext< Active_Bits, TElement > &other) ETL_NOEXCEPT
swap
Definition bitset_new.h:3385
etl::bitset_ext::operator==
friend ETL_CONSTEXPR14 bool operator==(const bitset_ext< Active_Bits, TElement > &lhs, const bitset_ext< Active_Bits, TElement > &rhs) ETL_NOEXCEPT
operator ==
Definition bitset_new.h:3369
etl::bitset_ext::flip
ETL_CONSTEXPR14 bitset_ext< Active_Bits, TElement > & flip(size_t position)
Flip the bit at the position.
Definition bitset_new.h:3256
etl::bitset_ext::from_string
ETL_CONSTEXPR14 bitset_ext< Active_Bits, TElement > & from_string(const char *text) ETL_NOEXCEPT
Set from a string.
Definition bitset_new.h:2967
etl::bitset_ext::find_next
ETL_CONSTEXPR14 size_t find_next(bool state, size_t position) const ETL_NOEXCEPT
Definition bitset_new.h:3311
etl::bitset_ext::top_mask
static ETL_CONSTEXPR element_type top_mask() ETL_NOEXCEPT
The mask for the msb element.
Definition bitset_new.h:3150
etl::bitset_ext::bitset_ext
ETL_CONSTEXPR14 bitset_ext(TPString text, element_type *pbuffer_, typename etl::enable_if< is_same< TPString, const char * >::value >::type *=0)
Construct from a string.
Definition bitset_new.h:2774
etl::bitset_ext::bitset_ext
ETL_CONSTEXPR14 bitset_ext(TValue value, buffer_type &buffer, typename etl::enable_if< is_integral< TValue >::value >::type *=0) ETL_NOEXCEPT
Construct from a value.
Definition bitset_new.h:2764
etl::bitset_ext::bitset_ext
ETL_CONSTEXPR14 bitset_ext(TPString text, element_type *pbuffer_, typename etl::enable_if< is_same< TPString, const char16_t * >::value >::type *=0)
Construct from a string.
Definition bitset_new.h:2818
etl::bitset_ext::to_ullong
unsigned long long to_ullong() const
Get as an unsigned long long.
Definition bitset_new.h:3062
etl::bitset_ext::operator<<=
ETL_CONSTEXPR14 bitset_ext< Active_Bits, TElement > & operator<<=(size_t shift) ETL_NOEXCEPT
operator <<=
Definition bitset_new.h:3349
etl::bitset_ext::operator|=
ETL_CONSTEXPR14 bitset_ext< Active_Bits, TElement > & operator|=(const bitset_ext< Active_Bits, TElement > &other) ETL_NOEXCEPT
operator |=
Definition bitset_new.h:3329
etl::bitset_ext::operator^=
ETL_CONSTEXPR14 bitset_ext< Active_Bits, TElement > & operator^=(const bitset_ext< Active_Bits, TElement > &other) ETL_NOEXCEPT
operator ^=
Definition bitset_new.h:3339
etl::bitset_ext::any
ETL_CONSTEXPR14 bool any(element_type mask) const ETL_NOEXCEPT
Are any of the mask bits set?
Definition bitset_new.h:3236
etl::bitset_ext::reset
ETL_CONSTEXPR14 bitset_ext< Active_Bits, TElement > & reset() ETL_NOEXCEPT
Reset all of the bits.
Definition bitset_new.h:3072
etl::bitset_ext::none
ETL_CONSTEXPR14 bool none() const ETL_NOEXCEPT
Are none of the bits set?
Definition bitset_new.h:3210
etl::bitset_ext::set
ETL_CONSTEXPR14 bitset_ext< Active_Bits, TElement > & set() ETL_NOEXCEPT
Set all of the bits.
Definition bitset_new.h:2871
etl::bitset_ext::reset
ETL_CONSTEXPR14 bitset_ext< Active_Bits, TElement > & reset(size_t position)
Reset the bit at the position.
Definition bitset_new.h:3082
etl::bitset_ext::bitset_ext
ETL_CONSTEXPR14 bitset_ext(TPString text, buffer_type &buffer, typename etl::enable_if< is_same< TPString, const wchar_t * >::value >::type *=0) ETL_NOEXCEPT
Construct from a string.
Definition bitset_new.h:2807
etl::bitset_ext< 0U, unsigned char >::bitset_ext
ETL_CONSTEXPR14 bitset_ext(element_type *pbuffer_)
Definition bitset_new.h:2709
etl::bitset_ext::value
ETL_CONSTEXPR14 T value() const ETL_NOEXCEPT
Get as an integral value.
Definition bitset_new.h:3008
etl::bitset_ext::bitset_ext
ETL_CONSTEXPR14 bitset_ext(unsigned long long value, element_type *pbuffer_)
Construct from a value.
Definition bitset_new.h:2753
etl::bitset_ext::bits_per_element
static ETL_CONSTEXPR size_t bits_per_element() ETL_NOEXCEPT
The number of bits in an element.
Definition bitset_new.h:3158
etl::bitset_ext::bitset_ext
ETL_CONSTEXPR14 bitset_ext(TPString text, element_type *pbuffer_, typename etl::enable_if< is_same< TPString, const char32_t * >::value >::type *=0)
Construct from a string.
Definition bitset_new.h:2840
etl::bitset_ext::set
ETL_CONSTEXPR14 etl::enable_if< etl::is_same< TPString, constchar * >::value, bitset_ext< Active_Bits, TElement > & >::type set(TPString text) ETL_NOEXCEPT
Set from a string.
Definition bitset_new.h:2920
etl::bitset_ext::operator[]
ETL_CONSTEXPR14 bool operator[](size_t position) const ETL_NOEXCEPT
Read [] operator.
Definition bitset_new.h:3268
etl::bitset_ext::operator&=
ETL_CONSTEXPR14 bitset_ext< Active_Bits, TElement > & operator&=(const bitset_ext< Active_Bits, TElement > &other) ETL_NOEXCEPT
operator &=
Definition bitset_new.h:3319
etl::bitset_ext::size
static ETL_CONSTEXPR size_t size() ETL_NOEXCEPT
The number of bits in the bitset.
Definition bitset_new.h:3118
etl::bitset_ext::number_of_elements
static ETL_CONSTEXPR size_t number_of_elements() ETL_NOEXCEPT
The number of storage elements in the bitset.
Definition bitset_new.h:3126
etl::bitset_ext::test
ETL_CONSTEXPR14 bool test(size_t position) const
Definition bitset_new.h:3096
etl::bitset_ext::flip
ETL_CONSTEXPR14 bitset_ext< Active_Bits, TElement > & flip() ETL_NOEXCEPT
Flip all of the bits.
Definition bitset_new.h:3246
etl::bitset_ext::allocated_bits
static ETL_CONSTEXPR size_t allocated_bits() ETL_NOEXCEPT
The total number of bits of storage, including unused.
Definition bitset_new.h:3166
etl::bitset_ext::set
ETL_CONSTEXPR14 bitset_ext< Active_Bits, TElement > & set(size_t position, bool value=true)
Set the bit at the position.
Definition bitset_new.h:2881
etl::bitset_ext::bitset_ext
ETL_CONSTEXPR14 bitset_ext(TPString text, element_type *pbuffer_, typename etl::enable_if< is_same< TPString, const wchar_t * >::value >::type *=0)
Construct from a string.
Definition bitset_new.h:2796
etl::bitset_ext::to_ulong
unsigned long to_ulong() const
Get as an unsigned long.
Definition bitset_new.h:3052
etl::bitset_ext::test
ETL_CONSTEXPR14 bool test() const
Definition bitset_new.h:3108
etl::bitset_ext::bitset_ext
ETL_CONSTEXPR14 bitset_ext(TPString text, buffer_type &buffer, typename etl::enable_if< is_same< TPString, const char32_t * >::value >::type *=0) ETL_NOEXCEPT
Construct from a string.
Definition bitset_new.h:2851
etl::bitset_ext::set
ETL_CONSTEXPR14 etl::enable_if< etl::is_same< TPString, constchar16_t * >::value, bitset_ext< Active_Bits, TElement > & >::type set(TPString text) ETL_NOEXCEPT
Set from a char16 string.
Definition bitset_new.h:2945
etl::bitset_ext::operator[]
ETL_CONSTEXPR14 bit_reference operator[](size_t position) ETL_NOEXCEPT
Write [] operator.
Definition bitset_new.h:3276
etl::bitset_ext::from_string
ETL_CONSTEXPR14 bitset_ext< Active_Bits, TElement > & from_string(const wchar_t *text) ETL_NOEXCEPT
Set from a wide string.
Definition bitset_new.h:2977
etl::bitset_ext::none
ETL_CONSTEXPR14 bool none(element_type mask) const ETL_NOEXCEPT
Are none of the mask bits set?
Definition bitset_new.h:3218
etl::bitset_ext::count
ETL_CONSTEXPR14 size_t count() const ETL_NOEXCEPT
Count the number of bits set.
Definition bitset_new.h:3184
etl::bitset_ext::bitset_ext
ETL_CONSTEXPR14 bitset_ext(const bitset_ext< Active_Bits, TElement > &other, buffer_type &buffer) ETL_NOEXCEPT
Construct copy.
Definition bitset_new.h:2739
etl::bitset_ext::set
ETL_CONSTEXPR14 bitset_ext< Active_Bits, TElement > & set()
Set the bit at the position.
Definition bitset_new.h:2907
etl::bitset_ext::bitset_ext
ETL_CONSTEXPR14 bitset_ext(const bitset_ext< Active_Bits, TElement > &other, element_type *pbuffer_)
Construct copy.
Definition bitset_new.h:2729
etl::bitset_ext::storage_model
static ETL_CONSTEXPR etl::bitset_storage_model storage_model() ETL_NOEXCEPT
Definition bitset_new.h:3176
etl::bitset_ext::operator>>=
ETL_CONSTEXPR14 bitset_ext< Active_Bits, TElement > & operator>>=(size_t shift) ETL_NOEXCEPT
operator >>=
Definition bitset_new.h:3359
etl::bitset_ext::operator!=
friend ETL_CONSTEXPR14 bool operator!=(const bitset_ext< Active_Bits, TElement > &lhs, const bitset_ext< Active_Bits, TElement > &rhs) ETL_NOEXCEPT
operator !=
Definition bitset_new.h:3377
etl::bitset_ext::find_first
ETL_CONSTEXPR14 size_t find_first(bool state) const ETL_NOEXCEPT
Definition bitset_new.h:3300
etl::bitset_ext::all_clear_element
static ETL_CONSTEXPR element_type all_clear_element() ETL_NOEXCEPT
The value of a clear element.
Definition bitset_new.h:3142
etl::bitset_ext::span
ETL_CONSTEXPR14 const_span_type span() const ETL_NOEXCEPT
Definition bitset_new.h:3403
etl::bitset_ext::set
ETL_CONSTEXPR14 bitset_ext< Active_Bits, TElement > & set(bool value=true)
Set the bit at the position.
Definition bitset_new.h:2894
etl::bitset_ext::bitset_ext
ETL_CONSTEXPR14 bitset_ext(TPString text, buffer_type &buffer, typename etl::enable_if< is_same< TPString, const char * >::value >::type *=0) ETL_NOEXCEPT
Construct from a string.
Definition bitset_new.h:2785
etl::bitset_ext::to_string
ETL_CONSTEXPR14 TString to_string(typename TString::value_type zero=typename TString::value_type('0'), typename TString::value_type one=typename TString::value_type('1')) const
Returns a string representing the bitset.
Definition bitset_new.h:3289
etl::bitset_ext::bitset_ext
ETL_CONSTEXPR14 bitset_ext(const bitset_ext< Active_Bits, TElement > &other) ETL_NOEXCEPT ETL_DELETE
Copy Constructor (Deleted).
etl::bitset_ext::from_string
ETL_CONSTEXPR14 bitset_ext< Active_Bits, TElement > & from_string(const char16_t *text) ETL_NOEXCEPT
Set from a u16 string.
Definition bitset_new.h:2987
etl::bitset_ext::bitset_ext
ETL_CONSTEXPR14 bitset_ext(buffer_type &buffer)
Default constructor.
Definition bitset_new.h:2719
etl::bitset_ext::span
ETL_CONSTEXPR14 span_type span() ETL_NOEXCEPT
Definition bitset_new.h:3394
etl::bitset_ext::extract
ETL_CONSTEXPR14 T extract(size_t position, size_t length=etl::integral_limits< T >::bits)
Definition bitset_new.h:3021
etl::lsb_mask
Definition binary.h:2196
etl::msb_mask
Definition binary.h:2228
etl::private_bitset::bitset_common
Definition bitset_new.h:1602
etl::private_bitset::bitset_impl_common
Definition bitset_new.h:166
etl::span
Span - Fixed Extent.
Definition span.h:208
etl::span::begin
ETL_NODISCARD ETL_CONSTEXPR iterator begin() const ETL_NOEXCEPT
Returns an iterator to the beginning of the span.
Definition span.h:484
enum_type.h
error_handler.h
exception.h
etl::array
Definition array.h:85
etl::count_bits
ETL_CONSTEXPR14 etl::enable_if< etl::is_integral< T >::value &&etl::is_unsigned< T >::value &&(etl::integral_limits< T >::bits==16U), uint_least8_t >::type count_bits(T value)
Definition binary.h:918
etl::sign_extend
ETL_CONSTEXPR14 TReturn sign_extend(TValue value)
Definition binary.h:273
etl::bit
Definition binary.h:356
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::operator_equality
static ETL_CONSTEXPR14 bool operator_equality(const_pointer lhs_pbuffer, const_pointer rhs_pbuffer, size_t number_of_elements) ETL_NOEXCEPT
operator_equality
Definition bitset_new.h:1533
etl::bitset::none
ETL_CONSTEXPR14 bool none(element_type mask) const ETL_NOEXCEPT
Are none of the mask bits set?
Definition bitset_new.h:2221
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::extract
static ETL_CONSTEXPR14 T extract(const_pointer pbuffer)
Extract an integral value from an arbitrary position and length.
Definition bitset_new.h:1239
etl::bitset::find_next
ETL_CONSTEXPR14 size_t find_next(bool state, size_t position) const ETL_NOEXCEPT
Definition bitset_new.h:2314
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::find_next
static ETL_CONSTEXPR14 size_t find_next(const_pointer pbuffer, size_t number_of_elements, size_t total_bits, bool state, size_t position) ETL_NOEXCEPT
Definition bitset_new.h:1278
etl::bitset::extract
ETL_CONSTEXPR14 T extract(size_t position, size_t length=etl::integral_limits< T >::bits) const
Definition bitset_new.h:2024
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::extract_from_multiple_elements
static ETL_CONSTEXPR14 etl::make_unsigned< T >::type extract_from_multiple_elements(const element_type *pbuffer, size_t element_index, size_t active_bits_in_msb, size_t length) ETL_NOEXCEPT
Extract an value from multiple elements.
Definition bitset_new.h:1101
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::set_all
static ETL_CONSTEXPR14 void set_all(pointer pbuffer, size_t number_of_elements, element_type top_mask) ETL_NOEXCEPT
Set all bits.
Definition bitset_new.h:865
etl::bitset::set
ETL_CONSTEXPR14 bitset< Active_Bits, TElement > & set(size_t position, bool value=true)
Set the bit at the position.
Definition bitset_new.h:1884
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::extract_from_buffer
static ETL_CONSTEXPR14 etl::enable_if< value_is_in_one_element< Position, Length, Bits_Per_Element >::value, typenameetl::make_unsigned< T >::type >::type extract_from_buffer(const_pointer pbuffer)
Definition bitset_new.h:1188
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::extract_from_buffer
static ETL_CONSTEXPR14 etl::make_unsigned< T >::type extract_from_buffer(const_pointer pbuffer, size_t position, size_t length) ETL_NOEXCEPT
Definition bitset_new.h:1149
etl::bitset::bitset
ETL_CONSTEXPR14 bitset(const bitset< Active_Bits, TElement > &other) ETL_NOEXCEPT
Copy constructor.
Definition bitset_new.h:1805
etl::ibitset::initialise
ibitset & initialise(unsigned long long value)
Initialise from an unsigned long long.
Definition bitset_legacy.h:1006
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::swap
static ETL_CONSTEXPR14 void swap(pointer lhs_pbuffer, pointer rhs_pbuffer, size_t) ETL_NOEXCEPT
swap
Definition bitset_new.h:735
etl::bitset::set
ETL_CONSTEXPR14 etl::enable_if< etl::is_same< TPString, constchar16_t * >::value, bitset< Active_Bits, TElement > & >::type set(TPString text) ETL_NOEXCEPT
Set from a char16 string.
Definition bitset_new.h:1947
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::reset_position
static ETL_CONSTEXPR14 void reset_position(pointer pbuffer, size_t position)
Reset the bit at the position.
Definition bitset_new.h:294
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::flip_all
static ETL_CONSTEXPR14 void flip_all(pointer pbuffer, size_t) ETL_NOEXCEPT
Flip all of the bits.
Definition bitset_new.h:557
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::extract_from_buffer
static ETL_CONSTEXPR14 etl::enable_if<!value_is_in_one_element< Position, Length, Bits_Per_Element >::value, typenameetl::make_unsigned< T >::type >::type extract_from_buffer(const_pointer pbuffer)
Definition bitset_new.h:1206
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::any
static ETL_CONSTEXPR14 bool any(const_pointer pbuffer, size_t, element_type mask) ETL_NOEXCEPT
Are any of the mask bits set?
Definition bitset_new.h:549
etl::bitset::all_set_element
static ETL_CONSTEXPR element_type all_set_element() ETL_NOEXCEPT
The value of a set element.
Definition bitset_new.h:2137
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::set_position
static ETL_CONSTEXPR14 void set_position(pointer pbuffer, size_t position, bool value=true)
Set the bit at the position.
Definition bitset_new.h:230
etl::bitset::from_string
ETL_CONSTEXPR14 bitset< Active_Bits, TElement > & from_string(const char32_t *text) ETL_NOEXCEPT
Set from a u32 string.
Definition bitset_new.h:2000
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::from_string
static ETL_CONSTEXPR14 void from_string(pointer pbuffer, size_t number_of_elements, size_t total_bits, const char *text) ETL_NOEXCEPT
Set from a string.
Definition bitset_new.h:934
etl::bitset::operator&=
ETL_CONSTEXPR14 bitset< Active_Bits, TElement > & operator&=(const bitset< Active_Bits, TElement > &other) ETL_NOEXCEPT
operator &=
Definition bitset_new.h:2334
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::extract
static ETL_CONSTEXPR14 T extract(const_pointer pbuffer)
Extract an integral value from an arbitrary position and length.
Definition bitset_new.h:470
etl::bitset::operator>>=
ETL_CONSTEXPR14 bitset< Active_Bits, TElement > & operator>>=(size_t shift) ETL_NOEXCEPT
operator >>=
Definition bitset_new.h:2441
etl::bitset::from_string
ETL_CONSTEXPR14 bitset< Active_Bits, TElement > & from_string(const char16_t *text) ETL_NOEXCEPT
Set from a u16 string.
Definition bitset_new.h:1990
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::flip_all
static ETL_CONSTEXPR14 void flip_all(pointer pbuffer, size_t number_of_elements) ETL_NOEXCEPT
Flip all of the bits.
Definition bitset_new.h:1256
etl::bitset::set
ETL_CONSTEXPR14 bitset< Active_Bits, TElement > & set() ETL_NOEXCEPT
Set all of the bits.
Definition bitset_new.h:1874
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::find_next
static ETL_CONSTEXPR14 size_t find_next(const_pointer pbuffer, size_t, size_t active_bits, bool state, size_t position) ETL_NOEXCEPT
Definition bitset_new.h:608
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::initialise
static ETL_CONSTEXPR14 void initialise(pointer pbuffer, size_t, unsigned long long value) ETL_NOEXCEPT
Initialise from an unsigned long long.
Definition bitset_new.h:727
etl::bitset::operator>>
ETL_CONSTEXPR14 bitset< Active_Bits, TElement > operator>>(size_t shift) const ETL_NOEXCEPT
operator >>
Definition bitset_new.h:2429
etl::bitset::operator<<
ETL_CONSTEXPR14 bitset< Active_Bits, TElement > operator<<(size_t shift) const ETL_NOEXCEPT
operator <<
Definition bitset_new.h:2400
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::to_string
static ETL_CONSTEXPR14 TString to_string(const_pointer pbuffer, size_t active_bits, typename TString::value_type zero, typename TString::value_type one)
Returns a string representing the bitset.
Definition bitset_new.h:1329
etl::bitset::operator~
ETL_CONSTEXPR14 bitset< Active_Bits, TElement > operator~() const ETL_NOEXCEPT
operator ~
Definition bitset_new.h:2388
etl::bitset::flip
ETL_CONSTEXPR14 bitset< Active_Bits, TElement > & flip() ETL_NOEXCEPT
Flip all of the bits.
Definition bitset_new.h:2249
etl::bitset::from_string
ETL_CONSTEXPR14 bitset< Active_Bits, TElement > & from_string(const char *text) ETL_NOEXCEPT
Set from a string.
Definition bitset_new.h:1970
etl::bitset::span
ETL_CONSTEXPR14 const_span_type span() const ETL_NOEXCEPT
Definition bitset_new.h:2492
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::from_string
static ETL_CONSTEXPR14 void from_string(pointer pbuffer, size_t number_of_elements, size_t total_bits, const wchar_t *text) ETL_NOEXCEPT
Set from a wide string.
Definition bitset_new.h:964
etl::bitset::none
ETL_CONSTEXPR14 bool none() const ETL_NOEXCEPT
Are none of the bits set?
Definition bitset_new.h:2213
etl::bitset::bitset
ETL_CONSTEXPR14 bitset(TPString text, typename etl::enable_if< is_same< TPString, const char16_t * >::value >::type *=0) ETL_NOEXCEPT
Construct from a string.
Definition bitset_new.h:1845
etl::bitset::operator<<=
ETL_CONSTEXPR14 bitset< Active_Bits, TElement > & operator<<=(size_t shift) ETL_NOEXCEPT
operator <<=
Definition bitset_new.h:2412
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::flip_position
static ETL_CONSTEXPR14 void flip_position(pointer pbuffer, size_t position)
Flip the bit at the position.
Definition bitset_new.h:573
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::from_string
static ETL_CONSTEXPR14 void from_string(pointer pbuffer, size_t number_of_elements, size_t total_bits, const char16_t *text) ETL_NOEXCEPT
Set from a u16 string.
Definition bitset_new.h:994
etl::bitset::operator&
ETL_CONSTEXPR14 bitset< Active_Bits, TElement > operator&(const bitset< Active_Bits, TElement > &other) const ETL_NOEXCEPT
operator &
Definition bitset_new.h:2322
etl::bitset::operator[]
ETL_CONSTEXPR14 bit_reference operator[](size_t position) ETL_NOEXCEPT
Write [] operator.
Definition bitset_new.h:2279
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::set_position
static ETL_CONSTEXPR14 void set_position(pointer pbuffer, bool value=true)
Set the bit at the position.
Definition bitset_new.h:897
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::operator_assignment
static ETL_CONSTEXPR14 void operator_assignment(pointer lhs_pbuffer, const_pointer rhs_pbuffer, size_t number_of_elements) ETL_NOEXCEPT
operator assignment
Definition bitset_new.h:1349
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::none
static ETL_CONSTEXPR14 bool none(const_pointer pbuffer, size_t, element_type mask) ETL_NOEXCEPT
Are none of the mask bits set?
Definition bitset_new.h:533
etl::bitset::find_first
ETL_CONSTEXPR14 size_t find_first(bool state) const ETL_NOEXCEPT
Definition bitset_new.h:2303
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::set_position
static ETL_CONSTEXPR14 void set_position(pointer pbuffer)
Set the bit at the position.
Definition bitset_new.h:916
etl::bitset::bitset
ETL_CONSTEXPR14 bitset(TValue value, typename etl::enable_if< is_integral< TValue >::value >::type *=0) ETL_NOEXCEPT
Construct from a value.
Definition bitset_new.h:1815
etl::bitset::from_string
ETL_CONSTEXPR14 bitset< Active_Bits, TElement > & from_string(const wchar_t *text) ETL_NOEXCEPT
Set from a wide string.
Definition bitset_new.h:1980
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::operator_and
static ETL_CONSTEXPR14 void operator_and(pointer lhs_pbuffer, const_pointer rhs_pbuffer, size_t number_of_elements) ETL_NOEXCEPT
operator and
Definition bitset_new.h:1362
etl::bitset::flip
ETL_CONSTEXPR14 bitset< Active_Bits, TElement > & flip(size_t position)
Flip the bit at the position.
Definition bitset_new.h:2259
etl::bitset::value
etl::enable_if< etl::is_integral< T >::value, T >::type value() const
Put to a value.
Definition bitset_legacy.h:1299
etl::bitset::number_of_elements
static ETL_CONSTEXPR size_t number_of_elements() ETL_NOEXCEPT
The number of storage elements in the bitset.
Definition bitset_new.h:2129
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::count
static ETL_CONSTEXPR14 size_t count(const_pointer pbuffer, size_t number_of_elements) ETL_NOEXCEPT
Count the number of bits set.
Definition bitset_new.h:792
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::operator_or
static ETL_CONSTEXPR14 void operator_or(pointer lhs_pbuffer, const_pointer rhs_pbuffer, size_t) ETL_NOEXCEPT
Definition bitset_new.h:662
etl::bitset::swap
ETL_CONSTEXPR14 void swap(etl::bitset< Active_Bits, TElement > &other) ETL_NOEXCEPT
swap
Definition bitset_new.h:2474
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::extract
static ETL_CONSTEXPR14 T extract(const_pointer pbuffer, size_t position, size_t length=etl::integral_limits< T >::bits)
Extract an integral value from an arbitrary position and length.
Definition bitset_new.h:1221
etl::bitset::to_string
ETL_CONSTEXPR14 TString to_string(typename TString::value_type zero=typename TString::value_type('0'), typename TString::value_type one=typename TString::value_type('1')) const
Returns a string representing the bitset.
Definition bitset_new.h:2292
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::from_string
static ETL_CONSTEXPR14 void from_string(pointer pbuffer, size_t, size_t active_bits, const wchar_t *text) ETL_NOEXCEPT
Set from a wide string.
Definition bitset_new.h:336
etl::bitset::allocated_bits
static ETL_CONSTEXPR size_t allocated_bits() ETL_NOEXCEPT
The total number of bits of storage, including unused.
Definition bitset_new.h:2169
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::operator_shift_left
static ETL_CONSTEXPR14 void operator_shift_left(pointer pbuffer, size_t number_of_elements, size_t active_bits, size_t shift) ETL_NOEXCEPT
operator_shift_left
Definition bitset_new.h:1413
etl::bitset::top_mask
static ETL_CONSTEXPR element_type top_mask() ETL_NOEXCEPT
The mask for the msb element.
Definition bitset_new.h:2161
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::operator_or
static ETL_CONSTEXPR14 void operator_or(pointer lhs_pbuffer, const_pointer rhs_pbuffer, size_t number_of_elements) ETL_NOEXCEPT
operator or
Definition bitset_new.h:1375
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::operator_shift_right
static ETL_CONSTEXPR14 void operator_shift_right(pointer pbuffer, size_t, size_t active_bits, size_t shift) ETL_NOEXCEPT
operator_shift_right
Definition bitset_new.h:703
etl::bitset::test
ETL_CONSTEXPR14 bool test(size_t position) const
Definition bitset_new.h:2099
etl::bitset::to_string
TString to_string(typename TString::value_type zero=typename TString::value_type('0'), typename TString::value_type one=typename TString::value_type('1')) const
Returns a string representing the bitset.
Definition bitset_legacy.h:1351
etl::bitset::value
ETL_CONSTEXPR14 etl::enable_if< etl::is_integral< T >::value, T >::type value() const ETL_NOEXCEPT
Get as an integral value.
Definition bitset_new.h:2011
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::any
static ETL_CONSTEXPR14 bool any(const_pointer pbuffer, size_t) ETL_NOEXCEPT
Are any of the bits set?
Definition bitset_new.h:541
etl::bitset::any
ETL_CONSTEXPR14 bool any(element_type mask) const ETL_NOEXCEPT
Are any of the mask bits set?
Definition bitset_new.h:2239
etl::bitset::operator^=
ETL_CONSTEXPR14 bitset< Active_Bits, TElement > & operator^=(const bitset< Active_Bits, TElement > &other) ETL_NOEXCEPT
operator ^=
Definition bitset_new.h:2378
etl::bitset::bitset
ETL_CONSTEXPR14 bitset(TPString text, typename etl::enable_if< is_same< TPString, const char32_t * >::value >::type *=0) ETL_NOEXCEPT
Construct from a string.
Definition bitset_new.h:1855
etl::bitset::all_clear_element
static ETL_CONSTEXPR element_type all_clear_element() ETL_NOEXCEPT
The value of a clear element.
Definition bitset_new.h:2145
etl::bitset::reset
ETL_CONSTEXPR14 bitset< Active_Bits, TElement > & reset() ETL_NOEXCEPT
Reset all of the bits.
Definition bitset_new.h:2075
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::reset_all
static ETL_CONSTEXPR14 void reset_all(pointer pbuffer, size_t number_of_elements) ETL_NOEXCEPT
Reset all of the bits.
Definition bitset_new.h:1054
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::from_string
static ETL_CONSTEXPR14 void from_string(pointer pbuffer, size_t, size_t active_bits, const char *text) ETL_NOEXCEPT
Set from a string.
Definition bitset_new.h:303
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::operator_shift_left
static ETL_CONSTEXPR14 void operator_shift_left(pointer pbuffer, size_t, size_t active_bits, size_t shift) ETL_NOEXCEPT
operator_shift_left
Definition bitset_new.h:688
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::operator_xor
static ETL_CONSTEXPR14 void operator_xor(pointer lhs_pbuffer, const_pointer rhs_pbuffer, size_t) ETL_NOEXCEPT
Definition bitset_new.h:671
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::value
static ETL_CONSTEXPR14 T value(const_pointer pbuffer, size_t number_of_elements) ETL_NOEXCEPT
Get as a value.
Definition bitset_new.h:1077
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::flip_bits
static ETL_CONSTEXPR14 void flip_bits(pointer pbuffer, element_type mask=etl::integral_limits< element_type >::max) ETL_NOEXCEPT
Flip some of the bits.
Definition bitset_new.h:565
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::none
static ETL_CONSTEXPR14 bool none(const_pointer pbuffer, size_t number_of_elements) ETL_NOEXCEPT
Are none of the bits set?
Definition bitset_new.h:830
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::flip_position
static ETL_CONSTEXPR14 void flip_position(pointer pbuffer, size_t position) ETL_NOEXCEPT
Flip the bit at the position.
Definition bitset_new.h:1264
etl::bitset::operator|
ETL_CONSTEXPR14 bitset< Active_Bits, TElement > operator|(const bitset< Active_Bits, TElement > &other) const ETL_NOEXCEPT
operator |
Definition bitset_new.h:2344
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::set_position
static ETL_CONSTEXPR14 void set_position(pointer pbuffer, size_t position, bool value=true) ETL_NOEXCEPT
Set the bit at the position.
Definition bitset_new.h:878
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::swap
static ETL_CONSTEXPR14 void swap(pointer pbuffer1, pointer pbuffer2, size_t number_of_elements)
Swap bitset buffers.
Definition bitset_new.h:1591
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::operator_not
static ETL_CONSTEXPR14 void operator_not(pointer pbuffer, size_t number_of_elements) ETL_NOEXCEPT
operator not
Definition bitset_new.h:1401
etl::bitset::operator=
ETL_CONSTEXPR14 bitset & operator=(const bitset< Active_Bits, TElement > &other) ETL_NOEXCEPT
Assignment operator.
Definition bitset_new.h:1864
etl::bitset::bits_per_element
static ETL_CONSTEXPR size_t bits_per_element() ETL_NOEXCEPT
The number of bits in an element.
Definition bitset_new.h:2153
etl::bitset::count
ETL_CONSTEXPR14 size_t count() const ETL_NOEXCEPT
Count the number of bits set.
Definition bitset_new.h:2187
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::initialise
static ETL_CONSTEXPR14 etl::enable_if< etl::integral_limits< TElementType >::bits==etl::integral_limits< unsignedlonglong >::bits, void >::type initialise(pointer pbuffer, size_t number_of_elements, unsigned long long value) ETL_NOEXCEPT
Definition bitset_new.h:1546
etl::bitset< 0U, unsigned char >::bitset
bitset()
Definition bitset_legacy.h:1137
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::value
static ETL_CONSTEXPR14 T value(const_pointer pbuffer, size_t) ETL_NOEXCEPT
Get as an integral value.
Definition bitset_new.h:436
etl::bitset::set
ETL_CONSTEXPR14 bitset< Active_Bits, TElement > & set(bool value=true)
Set the bit at the position.
Definition bitset_new.h:1897
etl::bitset::operator[]
ETL_CONSTEXPR14 bool operator[](size_t position) const ETL_NOEXCEPT
Read [] operator.
Definition bitset_new.h:2271
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::reset_all
static ETL_CONSTEXPR14 void reset_all(pointer pbuffer, size_t) ETL_NOEXCEPT
Reset all of the bits.
Definition bitset_new.h:283
etl::bitset::bitset
ETL_CONSTEXPR14 bitset(TPString text, typename etl::enable_if< is_same< TPString, const wchar_t * >::value >::type *=0) ETL_NOEXCEPT
Construct from a string.
Definition bitset_new.h:1835
etl::bitset::set
ETL_CONSTEXPR14 etl::enable_if< etl::is_same< TPString, constchar * >::value, bitset< Active_Bits, TElement > & >::type set(TPString text) ETL_NOEXCEPT
Set from a string.
Definition bitset_new.h:1923
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::any
static ETL_CONSTEXPR14 bool any(const_pointer pbuffer, size_t number_of_elements) ETL_NOEXCEPT
Are any of the bits set?
Definition bitset_new.h:846
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::test
static ETL_CONSTEXPR14 bool test(const_pointer pbuffer, size_t position)
Definition bitset_new.h:492
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::reset_position
static ETL_CONSTEXPR14 void reset_position(pointer pbuffer, size_t position) ETL_NOEXCEPT
Reset the bit at the position.
Definition bitset_new.h:1065
etl::bitset::operator^
ETL_CONSTEXPR14 bitset< Active_Bits, TElement > operator^(const bitset< Active_Bits, TElement > &other) const ETL_NOEXCEPT
operator ^
Definition bitset_new.h:2366
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::set_all
static ETL_CONSTEXPR14 void set_all(pointer pbuffer, size_t, element_type top_mask) ETL_NOEXCEPT
Set all of the bits.
Definition bitset_new.h:222
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::none
static ETL_CONSTEXPR14 bool none(const_pointer pbuffer, size_t) ETL_NOEXCEPT
Are none of the bits set?
Definition bitset_new.h:525
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::from_string
static ETL_CONSTEXPR14 void from_string(pointer pbuffer, size_t number_of_elements, size_t total_bits, const char32_t *text) ETL_NOEXCEPT
Set from a u32 string.
Definition bitset_new.h:1024
etl::bitset::reset
ETL_CONSTEXPR14 bitset< Active_Bits, TElement > & reset(size_t position)
Reset the bit at the position.
Definition bitset_new.h:2085
etl::bitset::set
ETL_CONSTEXPR14 etl::enable_if< etl::is_same< TPString, constwchar_t * >::value, bitset< Active_Bits, TElement > & >::type set(TPString text) ETL_NOEXCEPT
Set from a wide string.
Definition bitset_new.h:1935
etl::bitset::size
static ETL_CONSTEXPR size_t size() ETL_NOEXCEPT
The number of bits in the bitset.
Definition bitset_new.h:2121
etl::bitset::bitset
ETL_CONSTEXPR14 bitset(TPString text, typename etl::enable_if< is_same< TPString, const char * >::value >::type *=0) ETL_NOEXCEPT
Construct from a string.
Definition bitset_new.h:1825
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::from_string
static ETL_CONSTEXPR14 void from_string(pointer pbuffer, size_t, size_t active_bits, const char32_t *text) ETL_NOEXCEPT
Set from a u32 string.
Definition bitset_new.h:402
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::operator_shift_right
static ETL_CONSTEXPR14 void operator_shift_right(pointer pbuffer, size_t number_of_elements, size_t active_bits, size_t shift) ETL_NOEXCEPT
operator_shift_right
Definition bitset_new.h:1472
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::operator_and
static ETL_CONSTEXPR14 void operator_and(pointer lhs_pbuffer, const_pointer rhs_pbuffer, size_t) ETL_NOEXCEPT
Definition bitset_new.h:653
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::set_position
static ETL_CONSTEXPR14 void set_position(pointer pbuffer)
Set the bit at the position.
Definition bitset_new.h:266
etl::bitset::set
ETL_CONSTEXPR14 bitset< Active_Bits, TElement > & set()
Set the bit at the position.
Definition bitset_new.h:1910
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::extract
static ETL_CONSTEXPR14 T extract(const_pointer pbuffer, size_t position, size_t length=etl::integral_limits< T >::bits)
Extract an integral value from an arbitrary position and length.
Definition bitset_new.h:445
etl::bitset::to_ullong
unsigned long long to_ullong() const
Get as an unsigned long long.
Definition bitset_new.h:2065
etl::bitset::any
ETL_CONSTEXPR14 bool any() const ETL_NOEXCEPT
Are any of the bits set?
Definition bitset_new.h:2231
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::operator_equality
static ETL_CONSTEXPR14 bool operator_equality(const_pointer lhs_pbuffer, const_pointer rhs_pbuffer, size_t) ETL_NOEXCEPT
operator_equality
Definition bitset_new.h:718
etl::bitset::test
ETL_CONSTEXPR14 bool test() const
Definition bitset_new.h:2111
etl::bitset::span
ETL_CONSTEXPR14 span_type span() ETL_NOEXCEPT
Definition bitset_new.h:2483
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::from_string
static ETL_CONSTEXPR14 void from_string(pointer pbuffer, size_t, size_t active_bits, const char16_t *text) ETL_NOEXCEPT
Set from a u16 string.
Definition bitset_new.h:369
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::set_position
static ETL_CONSTEXPR14 void set_position(pointer pbuffer, bool value=true)
Set the bit at the position.
Definition bitset_new.h:248
etl::bitset::to_ulong
unsigned long to_ulong() const
Get as an unsigned long.
Definition bitset_new.h:2055
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::operator_xor
static ETL_CONSTEXPR14 void operator_xor(pointer lhs_pbuffer, const_pointer rhs_pbuffer, size_t number_of_elements) ETL_NOEXCEPT
operator xor
Definition bitset_new.h:1388
etl::bitset::operator==
friend ETL_CONSTEXPR14 bool operator==(const bitset< Active_Bits, TElement > &lhs, const bitset< Active_Bits, TElement > &rhs) ETL_NOEXCEPT
operator ==
Definition bitset_new.h:2458
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::initialise
static ETL_CONSTEXPR14 etl::enable_if< etl::integral_limits< TElementType >::bits!=etl::integral_limits< unsignedlonglong >::bits, void >::type initialise(pointer pbuffer, size_t number_of_elements, unsigned long long value) ETL_NOEXCEPT
Definition bitset_new.h:1568
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::count
static ETL_CONSTEXPR14 size_t count(const_pointer pbuffer, size_t) ETL_NOEXCEPT
Count the number of bits set.
Definition bitset_new.h:501
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::operator_assignment
static ETL_CONSTEXPR14 void operator_assignment(pointer lhs_pbuffer, const_pointer rhs_pbuffer, size_t) ETL_NOEXCEPT
Definition bitset_new.h:644
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::test
static ETL_CONSTEXPR14 bool test(const_pointer pbuffer, size_t position) ETL_NOEXCEPT
Definition bitset_new.h:781
etl::bitset::extract
ETL_CONSTEXPR14 T extract() const
Definition bitset_new.h:2043
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::operator_not
static ETL_CONSTEXPR14 void operator_not(pointer pbuffer, size_t) ETL_NOEXCEPT
Definition bitset_new.h:680
etl::bitset::operator|=
ETL_CONSTEXPR14 bitset< Active_Bits, TElement > & operator|=(const bitset< Active_Bits, TElement > &other) ETL_NOEXCEPT
operator |=
Definition bitset_new.h:2356
etl::bitset::operator!=
friend ETL_CONSTEXPR14 bool operator!=(const bitset< Active_Bits, TElement > &lhs, const bitset< Active_Bits, TElement > &rhs) ETL_NOEXCEPT
operator !=
Definition bitset_new.h:2466
etl::bitset_impl< TElement, etl::bitset_storage_model::Single >::to_string
static ETL_CONSTEXPR14 TString to_string(const_pointer pbuffer, size_t active_bits, typename TString::value_type zero=typename TString::value_type('0'), typename TString::value_type one=typename TString::value_type('1'))
Returns a string representing the bitset.
Definition bitset_new.h:583
etl::bitset::set
ETL_CONSTEXPR14 etl::enable_if< etl::is_same< TPString, constchar32_t * >::value, bitset< Active_Bits, TElement > & >::type set(TPString text) ETL_NOEXCEPT
Set from a char32 string.
Definition bitset_new.h:1959
etl::bitset::bitset
ETL_CONSTEXPR14 bitset() ETL_NOEXCEPT
Default constructor.
Definition bitset_new.h:1796
etl::bitset::storage_model
static ETL_CONSTEXPR etl::bitset_storage_model storage_model() ETL_NOEXCEPT
Definition bitset_new.h:2179
etl::bitset
Bitset forward declaration.
Definition bitset_legacy.h:1124
etl::bitset_exception
Definition bitset_legacy.h:83
etl::bitset_impl
Definition bitset_new.h:198
etl::bitset_invalid_buffer
Definition bitset_new.h:152
etl::bitset_overflow
Definition bitset_legacy.h:125
etl::bitset_string_too_small
Definition bitset_new.h:124
etl::bitset_storage_model
Definition bitset_new.h:90
ETL_ASSERT
#define ETL_ASSERT(b, e)
Definition error_handler.h:511
etl::exception
Definition exception.h:59
etl::integral_limits
Definition integral_limits.h:517
type
ETL_DECLARE_ENUM_TYPE
#define ETL_DECLARE_ENUM_TYPE(TypeName, ValueType)
Definition enum_type.h:90
integral_limits.h
iterator.h
largest.h
log.h
minmax_pop.h
minmax_push.h
etl
Definition absolute.h:40
etl::swap
ETL_CONSTEXPR14 void swap(etl::typed_storage_ext< T > &lhs, etl::typed_storage_ext< T > &rhs) ETL_NOEXCEPT
Swap two etl::typed_storage_ext.
Definition alignment.h:856
etl::operator==
ETL_CONSTEXPR14 bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1078
etl::data
ETL_CONSTEXPR TContainer::pointer data(TContainer &container)
Definition iterator.h:1470
etl::operator|
etl::byte operator|(etl::byte lhs, etl::byte rhs)
Or.
Definition byte.h:250
etl::operator&
etl::byte operator&(etl::byte lhs, etl::byte rhs)
And.
Definition byte.h:258
etl::operator!=
ETL_CONSTEXPR14 bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1090
etl::operator^
etl::byte operator^(etl::byte lhs, etl::byte rhs)
Exclusive Or.
Definition byte.h:266
etl::strlen
ETL_CONSTEXPR14 size_t strlen(const T *t) ETL_NOEXCEPT
Alternative strlen for all character types.
Definition char_traits.h:293
nullptr.h
platform.h
smallest.h
span.h
string.h
etl::bitset_impl< TElement, etl::bitset_storage_model::Multi >::value_is_in_one_element
Check to see if the requested extract is contained within one element.
Definition bitset_new.h:771
etl::type