Global namespace bitset free functions cleanup (#1411)

* Print test names at test time (#1343)

* Fix operator| conflict with std::ranges (#1395)

* Keep comparison and swap free functions out of the global namespace and
let ADL do its thing.

* Apply the same global to etl namespace move on overlooked functions

---------

Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de>
Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.com>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
This commit is contained in:
Joris Putcuyps 2026-04-28 14:13:55 +02:00 committed by GitHub
parent ee0d4740b3
commit 15ca12649e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 256 additions and 260 deletions

View File

@ -1523,16 +1523,16 @@ namespace etl
{
return !(lhs == rhs);
}
} // namespace etl
//*************************************************************************
/// swap
//*************************************************************************
template <size_t MaxN>
void swap(etl::bitset<MaxN>& lhs, etl::bitset<MaxN>& rhs)
{
lhs.swap(rhs);
}
//*************************************************************************
/// swap
//*************************************************************************
template <size_t MaxN>
void swap(etl::bitset<MaxN>& lhs, etl::bitset<MaxN>& rhs)
{
lhs.swap(rhs);
}
} // namespace etl
#include "minmax_pop.h"

View File

@ -2519,32 +2519,30 @@ namespace etl
temp ^= rhs;
return temp;
}
} // namespace etl
//***************************************************************************
/// operator !=
///\ingroup bitset
//***************************************************************************
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);
}
//***************************************************************************
/// operator !=
///\ingroup bitset
//***************************************************************************
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);
}
//*************************************************************************
/// swap
//*************************************************************************
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);
}
//*************************************************************************
/// swap
//*************************************************************************
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);
}
//***************************************************************************
/// bitset_ext
//***************************************************************************
//***************************************************************************
/// bitset_ext
//***************************************************************************
namespace etl
{
//***************************************************************************
template <size_t Active_Bits = 0U, typename TElement = unsigned char>
class bitset_ext;
@ -3396,29 +3394,26 @@ namespace etl
// Pointer to the storage for the bitset.
element_type* pbuffer;
};
} // namespace etl
//***************************************************************************
/// operator !=
///\ingroup bitset
//***************************************************************************
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);
}
//***************************************************************************
/// operator !=
///\ingroup bitset
//***************************************************************************
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);
}
//*************************************************************************
/// swap
//*************************************************************************
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);
}
//*************************************************************************
/// swap
//*************************************************************************
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 etl
{
namespace private_bitset
{
//*************************************************************************
@ -3464,216 +3459,217 @@ namespace etl
return true;
}
} // namespace private_bitset
//***************************************************************************
/// operator ==
/// bitset
/// Different element types
///\ingroup 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);
}
}
//***************************************************************************
/// operator !=
/// bitset
/// Different element types
///\ingroup 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
{
return !(lhs == rhs);
}
//***************************************************************************
/// operator ==
/// bitset_ext
/// Different element types
///\ingroup 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_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);
}
}
//***************************************************************************
/// operator !=
/// bitset_ext
/// Different element types
///\ingroup 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_ext<Active_Bits, TLhsElement>& lhs, const etl::bitset_ext<Active_Bits, TRhsElement>& rhs) ETL_NOEXCEPT
{
return !(lhs == rhs);
}
//***************************************************************************
/// operator ==
/// bitset compared with bitset_ext, same element types.
///\ingroup bitset
//***************************************************************************
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);
}
//***************************************************************************
/// operator !=
/// bitset compared with bitset_ext, same element types.
///\ingroup bitset
//***************************************************************************
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);
}
//***************************************************************************
/// operator ==
/// bitset_ext compared with bitset, same element types.
///\ingroup bitset
//***************************************************************************
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);
}
//***************************************************************************
/// operator !=
/// bitset_ext compared with bitset, same element types.
///\ingroup bitset
//***************************************************************************
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);
}
//***************************************************************************
/// operator ==
/// bitset compared with bitset_ext, different element types.
///\ingroup 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_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);
}
}
//***************************************************************************
/// operator !=
/// bitset compared with bitset_ext, different element types.
///\ingroup 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_ext<Active_Bits, TRhsElement>& rhs) ETL_NOEXCEPT
{
return !(lhs == rhs);
}
//***************************************************************************
/// operator ==
/// bitset_ext compared with bitset, different element types.
///\ingroup 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_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);
}
}
//***************************************************************************
/// operator !=
/// bitset_ext compared with bitset, different element types.
///\ingroup 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_ext<Active_Bits, TLhsElement>& lhs, const etl::bitset<Active_Bits, TRhsElement>& rhs) ETL_NOEXCEPT
{
return !(lhs == rhs);
}
} // namespace etl
//***************************************************************************
/// operator ==
/// bitset
/// Different element types
///\ingroup 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);
}
}
//***************************************************************************
/// operator !=
/// bitset
/// Different element types
///\ingroup 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
{
return !(lhs == rhs);
}
//***************************************************************************
/// operator ==
/// bitset_ext
/// Different element types
///\ingroup 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_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);
}
}
//***************************************************************************
/// operator !=
/// bitset_ext
/// Different element types
///\ingroup 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_ext<Active_Bits, TLhsElement>& lhs, const etl::bitset_ext<Active_Bits, TRhsElement>& rhs) ETL_NOEXCEPT
{
return !(lhs == rhs);
}
//***************************************************************************
/// operator ==
/// bitset compared with bitset_ext, same element types.
///\ingroup bitset
//***************************************************************************
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);
}
//***************************************************************************
/// operator !=
/// bitset compared with bitset_ext, same element types.
///\ingroup bitset
//***************************************************************************
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);
}
//***************************************************************************
/// operator ==
/// bitset_ext compared with bitset, same element types.
///\ingroup bitset
//***************************************************************************
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);
}
//***************************************************************************
/// operator !=
/// bitset_ext compared with bitset, same element types.
///\ingroup bitset
//***************************************************************************
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);
}
//***************************************************************************
/// operator ==
/// bitset compared with bitset_ext, different element types.
///\ingroup 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_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);
}
}
//***************************************************************************
/// operator !=
/// bitset compared with bitset_ext, different element types.
///\ingroup 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_ext<Active_Bits, TRhsElement>& rhs) ETL_NOEXCEPT
{
return !(lhs == rhs);
}
//***************************************************************************
/// operator ==
/// bitset_ext compared with bitset, different element types.
///\ingroup 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_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);
}
}
//***************************************************************************
/// operator !=
/// bitset_ext compared with bitset, different element types.
///\ingroup 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_ext<Active_Bits, TLhsElement>& lhs, const etl::bitset<Active_Bits, TRhsElement>& rhs) ETL_NOEXCEPT
{
return !(lhs == rhs);
}
#include "minmax_pop.h"
#endif