#959 Treat bitset with size_type

This commit is contained in:
John Wellbelove 2024-11-10 10:28:58 +00:00
parent 0026a8b908
commit fd82a9c113
7 changed files with 49 additions and 0 deletions

View File

@ -148,6 +148,8 @@ namespace etl
public:
typedef size_t size_type;
typedef typename etl::make_unsigned<ETL_BITSET_ELEMENT_TYPE>::type element_type;
typedef element_type element_t; // Backward compatibility

View File

@ -171,6 +171,7 @@ namespace etl
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;
@ -1937,6 +1938,8 @@ namespace etl
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;
@ -2826,6 +2829,8 @@ namespace etl
{
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;
@ -2850,6 +2855,8 @@ namespace etl
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;

View File

@ -1493,6 +1493,14 @@ namespace
CHECK_EQUAL("...*..*...**.*...*.*.**..****...", stdtext.c_str());
}
//*************************************************************************
TEST(test_global_size)
{
etl::bitset<32> b(0x12345678UL);
CHECK_EQUAL(32, ETL_OR_STD::size(b));
}
//*************************************************************************
TEST(test_issue_497_count_inverted_bits)
{

View File

@ -2722,5 +2722,13 @@ namespace
CHECK_EQUAL(test_bit(6), t6);
CHECK_EQUAL(test_bit(7), t7);
}
//*************************************************************************
TEST(test_global_size)
{
etl::bitset<32> b(0x12345678UL);
CHECK_EQUAL(32, ETL_OR_STD::size(b));
}
};
}

View File

@ -2815,5 +2815,13 @@ namespace
CHECK_EQUAL(test_bit(6), t6);
CHECK_EQUAL(test_bit(7), t7);
}
//*************************************************************************
TEST(test_global_size)
{
etl::bitset<32, uint32_t> b(0x12345678UL);
CHECK_EQUAL(32, ETL_OR_STD::size(b));
}
};
}

View File

@ -2471,5 +2471,13 @@ namespace
CHECK_EQUAL(test_bit(6), t6);
CHECK_EQUAL(test_bit(7), t7);
}
//*************************************************************************
TEST(test_global_size)
{
etl::bitset<32> b(0x12345678UL);
CHECK_EQUAL(32, ETL_OR_STD::size(b));
}
};
}

View File

@ -2619,5 +2619,13 @@ namespace
CHECK_EQUAL(test_bit(6), t6);
CHECK_EQUAL(test_bit(7), t7);
}
//*************************************************************************
TEST(test_global_size)
{
etl::bitset<32, uint32_t> b(0x12345678UL);
CHECK_EQUAL(32, ETL_OR_STD::size(b));
}
};
}