mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Merge branch 'development' into gh-workflow-add-o3
This commit is contained in:
commit
f66f0da36a
@ -24,7 +24,7 @@ RUN dpkg --add-architecture armhf && \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create non-root user with stable UID/GID
|
||||
ARG USERNAME=devuser
|
||||
ARG USERNAME=vscode
|
||||
ARG USER_UID=1000
|
||||
ARG USER_GID=1000
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ RUN dpkg --add-architecture i386 && \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create non-root user with stable UID/GID
|
||||
ARG USERNAME=devuser
|
||||
ARG USERNAME=vscode
|
||||
ARG USER_UID=1000
|
||||
ARG USER_GID=1000
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create non-root user with stable UID/GID
|
||||
ARG USERNAME=devuser
|
||||
ARG USERNAME=vscode
|
||||
ARG USER_UID=1000
|
||||
ARG USER_GID=1000
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ RUN dpkg --add-architecture riscv64 && \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create non-root user with stable UID/GID
|
||||
ARG USERNAME=devuser
|
||||
ARG USERNAME=vscode
|
||||
ARG USER_UID=1000
|
||||
ARG USER_GID=1000
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ RUN dpkg --add-architecture s390x && \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create non-root user with stable UID/GID
|
||||
ARG USERNAME=devuser
|
||||
ARG USERNAME=vscode
|
||||
ARG USER_UID=1000
|
||||
ARG USER_GID=1000
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@ SOFTWARE.
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#include "invoke.h"
|
||||
#include "type_traits.h"
|
||||
#include "utility.h"
|
||||
|
||||
@ -50,12 +51,31 @@ namespace etl
|
||||
using std::assignable_from;
|
||||
using std::common_reference_with;
|
||||
using std::common_with;
|
||||
using std::constructible_from;
|
||||
using std::convertible_to;
|
||||
using std::copy_constructible;
|
||||
using std::copyable;
|
||||
using std::default_initializable;
|
||||
using std::derived_from;
|
||||
using std::destructible;
|
||||
using std::equality_comparable;
|
||||
using std::equivalence_relation;
|
||||
using std::floating_point;
|
||||
using std::integral;
|
||||
using std::invocable;
|
||||
using std::movable;
|
||||
using std::move_constructible;
|
||||
using std::predicate;
|
||||
using std::regular;
|
||||
using std::regular_invocable;
|
||||
using std::relation;
|
||||
using std::same_as;
|
||||
using std::semiregular;
|
||||
using std::signed_integral;
|
||||
using std::strict_weak_order;
|
||||
using std::swappable;
|
||||
using std::swappable_with;
|
||||
using std::totally_ordered;
|
||||
using std::unsigned_integral;
|
||||
|
||||
#else // not ETL_USING_STL
|
||||
@ -114,6 +134,112 @@ namespace etl
|
||||
{ lhs = etl::forward<RHS>(rhs) } -> etl::same_as<LHS>;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
template <typename F, typename... Args>
|
||||
concept invocable = etl::is_invocable_v<F, Args...>;
|
||||
|
||||
//***************************************************************************
|
||||
template <typename F, typename... Args>
|
||||
concept regular_invocable = etl::invocable<F, Args...>;
|
||||
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
concept destructible = requires(T& t) {
|
||||
{ t.~T() } noexcept;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
template <typename T, typename... Args>
|
||||
concept constructible_from = etl::destructible<T> && etl::is_constructible_v<T, Args...>;
|
||||
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
concept default_initializable = etl::constructible_from<T> && requires {
|
||||
T{};
|
||||
::new T;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
concept move_constructible = etl::constructible_from<T, T> && etl::convertible_to<T, T>;
|
||||
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
concept copy_constructible =
|
||||
etl::move_constructible<T> && etl::constructible_from<T, T&> && etl::convertible_to<T&, T> && etl::constructible_from<T, const T&>
|
||||
&& etl::convertible_to<const T&, T> && etl::constructible_from<T, const T> && etl::convertible_to<const T, T>;
|
||||
|
||||
//***************************************************************************
|
||||
namespace private_concepts
|
||||
{
|
||||
template <typename T>
|
||||
concept boolean_testable = etl::convertible_to<T, bool> && requires(T&& t) {
|
||||
{ !etl::forward<T>(t) } -> etl::convertible_to<bool>;
|
||||
};
|
||||
} // namespace private_concepts
|
||||
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
concept equality_comparable = requires(const etl::remove_reference_t<T>& a, const etl::remove_reference_t<T>& b) {
|
||||
{ a == b } -> private_concepts::boolean_testable;
|
||||
{ a != b } -> private_concepts::boolean_testable;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
concept totally_ordered = etl::equality_comparable<T> && requires(const etl::remove_reference_t<T>& a, const etl::remove_reference_t<T>& b) {
|
||||
{ a < b } -> private_concepts::boolean_testable;
|
||||
{ a > b } -> private_concepts::boolean_testable;
|
||||
{ a <= b } -> private_concepts::boolean_testable;
|
||||
{ a >= b } -> private_concepts::boolean_testable;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
concept swappable = requires(T& a, T& b) { etl::swap(a, b); };
|
||||
|
||||
//***************************************************************************
|
||||
template <typename T, typename U>
|
||||
concept swappable_with = etl::common_reference_with<etl::remove_reference_t<T>&, etl::remove_reference_t<U>&> && requires(T&& t, U&& u) {
|
||||
etl::swap(etl::forward<T>(t), etl::forward<T>(t));
|
||||
etl::swap(etl::forward<U>(u), etl::forward<U>(u));
|
||||
etl::swap(etl::forward<T>(t), etl::forward<U>(u));
|
||||
etl::swap(etl::forward<U>(u), etl::forward<T>(t));
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
concept movable = etl::is_object_v<T> && etl::move_constructible<T> && etl::assignable_from<T&, T> && etl::swappable<T>;
|
||||
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
concept copyable = etl::copy_constructible<T> && etl::movable<T> && etl::assignable_from<T&, T&> && etl::assignable_from<T&, const T&>
|
||||
&& etl::assignable_from<T&, const T>;
|
||||
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
concept semiregular = etl::copyable<T> && etl::default_initializable<T>;
|
||||
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
concept regular = etl::semiregular<T> && etl::equality_comparable<T>;
|
||||
|
||||
//***************************************************************************
|
||||
template <typename F, typename... Args>
|
||||
concept predicate = etl::regular_invocable<F, Args...> && private_concepts::boolean_testable<etl::invoke_result_t<F, Args...> >;
|
||||
|
||||
//***************************************************************************
|
||||
template <typename R, typename T, typename U>
|
||||
concept relation = etl::predicate<R, T, T> && etl::predicate<R, U, U> && etl::predicate<R, T, U> && etl::predicate<R, U, T>;
|
||||
|
||||
//***************************************************************************
|
||||
template <typename R, typename T, typename U>
|
||||
concept equivalence_relation = etl::relation<R, T, U>;
|
||||
|
||||
//***************************************************************************
|
||||
template <typename R, typename T, typename U>
|
||||
concept strict_weak_order = etl::relation<R, T, U>;
|
||||
|
||||
#endif
|
||||
} // namespace etl
|
||||
#endif
|
||||
|
||||
@ -604,6 +604,38 @@ namespace etl
|
||||
return etl::move(etl::get<Error_Type>(storage));
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Get the error or a default value.
|
||||
//*******************************************
|
||||
template <typename G>
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 etl::enable_if_t<etl::is_convertible<G, error_type>::value, error_type> error_or(G&& default_error) const&
|
||||
{
|
||||
if (has_value())
|
||||
{
|
||||
return static_cast<error_type>(etl::forward<G>(default_error));
|
||||
}
|
||||
else
|
||||
{
|
||||
return error();
|
||||
}
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Get the error or a default value.
|
||||
//*******************************************
|
||||
template <typename G>
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 etl::enable_if_t<etl::is_convertible<G, error_type>::value, error_type> error_or(G&& default_error) &&
|
||||
{
|
||||
if (has_value())
|
||||
{
|
||||
return static_cast<error_type>(etl::forward<G>(default_error));
|
||||
}
|
||||
else
|
||||
{
|
||||
return etl::move(error());
|
||||
}
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Swap with another etl::expected.
|
||||
//*******************************************
|
||||
@ -661,6 +693,22 @@ namespace etl
|
||||
{
|
||||
return etl::get<Error_Type>(storage);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Get the error or a default value.
|
||||
//*******************************************
|
||||
template <typename G>
|
||||
error_type error_or(const G& default_error) const
|
||||
{
|
||||
if (has_value())
|
||||
{
|
||||
return static_cast<error_type>(default_error);
|
||||
}
|
||||
else
|
||||
{
|
||||
return error();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
@ -725,6 +773,39 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
/// Returns a pointer to the value if has_value(), otherwise returns nullptr.
|
||||
/// Allows expected to be used as a range of 0 or 1 elements.
|
||||
//*******************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 value_type* begin() ETL_NOEXCEPT
|
||||
{
|
||||
return has_value() ? &etl::get<value_type>(storage) : ETL_NULLPTR;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Returns a pointer past the value if has_value(), otherwise returns nullptr.
|
||||
//*******************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 value_type* end() ETL_NOEXCEPT
|
||||
{
|
||||
return has_value() ? &etl::get<value_type>(storage) + 1 : ETL_NULLPTR;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Returns a const pointer to the value if has_value(), otherwise returns nullptr.
|
||||
//*******************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 const value_type* begin() const ETL_NOEXCEPT
|
||||
{
|
||||
return has_value() ? &etl::get<value_type>(storage) : ETL_NULLPTR;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Returns a const pointer past the value if has_value(), otherwise returns nullptr.
|
||||
//*******************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 const value_type* end() const ETL_NOEXCEPT
|
||||
{
|
||||
return has_value() ? &etl::get<value_type>(storage) + 1 : ETL_NULLPTR;
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
template <typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, TValue&>::type>::type>
|
||||
auto transform(F&& f) & -> expected<U, TError>
|
||||
@ -827,13 +908,12 @@ namespace etl
|
||||
|
||||
enum
|
||||
{
|
||||
Uninitialised,
|
||||
Value_Type,
|
||||
Error_Type
|
||||
};
|
||||
|
||||
typedef etl::variant<etl::monostate, value_type, error_type> storage_type;
|
||||
storage_type storage;
|
||||
typedef etl::variant<value_type, error_type> storage_type;
|
||||
storage_type storage;
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
template < typename F, typename TExp, typename TRet, typename TValueRef, typename = typename etl::enable_if<!etl::is_void<TRet>::value>::type>
|
||||
@ -1066,6 +1146,38 @@ namespace etl
|
||||
{
|
||||
return etl::move(etl::get<Error_Type>(storage));
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Get the error or a default value.
|
||||
//*******************************************
|
||||
template <typename G>
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 etl::enable_if_t<etl::is_convertible<G, error_type>::value, error_type> error_or(G&& default_error) const&
|
||||
{
|
||||
if (has_value())
|
||||
{
|
||||
return static_cast<error_type>(etl::forward<G>(default_error));
|
||||
}
|
||||
else
|
||||
{
|
||||
return error();
|
||||
}
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Get the error or a default value.
|
||||
//*******************************************
|
||||
template <typename G>
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 etl::enable_if_t<etl::is_convertible<G, error_type>::value, error_type> error_or(G&& default_error) &&
|
||||
{
|
||||
if (has_value())
|
||||
{
|
||||
return static_cast<error_type>(etl::forward<G>(default_error));
|
||||
}
|
||||
else
|
||||
{
|
||||
return etl::move(error());
|
||||
}
|
||||
}
|
||||
#else
|
||||
//*******************************************
|
||||
/// Returns the error
|
||||
@ -1075,6 +1187,22 @@ namespace etl
|
||||
{
|
||||
return etl::get<Error_Type>(storage);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Get the error or a default value.
|
||||
//*******************************************
|
||||
template <typename G>
|
||||
error_type error_or(const G& default_error) const
|
||||
{
|
||||
if (has_value())
|
||||
{
|
||||
return static_cast<error_type>(default_error);
|
||||
}
|
||||
else
|
||||
{
|
||||
return error();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
@ -1189,7 +1317,7 @@ namespace etl
|
||||
|
||||
enum
|
||||
{
|
||||
Uninitialised,
|
||||
Void_Type,
|
||||
Error_Type
|
||||
};
|
||||
|
||||
@ -1381,24 +1509,25 @@ namespace etl
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Swap etl::expected.
|
||||
//*******************************************
|
||||
template <typename TValue, typename TError>
|
||||
ETL_CONSTEXPR14 void swap(etl::expected<TValue, TError>& lhs, etl::expected<TValue, TError>& rhs)
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Swap etl::unexpected.
|
||||
//*******************************************
|
||||
template <typename TError>
|
||||
ETL_CONSTEXPR14 void swap(etl::unexpected<TError>& lhs, etl::unexpected<TError>& rhs)
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
} // namespace etl
|
||||
|
||||
//*******************************************
|
||||
/// Swap etl::expected.
|
||||
//*******************************************
|
||||
template <typename TValue, typename TError>
|
||||
ETL_CONSTEXPR14 void swap(etl::expected<TValue, TError>& lhs, etl::expected<TValue, TError>& rhs)
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
/// Swap etl::unexpected.
|
||||
//*******************************************
|
||||
template <typename TError>
|
||||
ETL_CONSTEXPR14 void swap(etl::unexpected<TError>& lhs, etl::unexpected<TError>& rhs)
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -2370,47 +2370,43 @@ namespace etl
|
||||
pointer p;
|
||||
TDeleter deleter;
|
||||
};
|
||||
} // namespace etl
|
||||
|
||||
//*****************************************************************************
|
||||
// Global functions for unique_ptr
|
||||
//*****************************************************************************
|
||||
template <typename T1, typename TD1, typename T2, typename TD2>
|
||||
bool operator==(const etl::unique_ptr<T1, TD1>& lhs, const etl::unique_ptr<T2, TD2>& rhs)
|
||||
{
|
||||
return lhs.get() == rhs.get();
|
||||
}
|
||||
//*****************************************************************************
|
||||
// Comparison operators for unique_ptr
|
||||
//*****************************************************************************
|
||||
template <typename T1, typename TD1, typename T2, typename TD2>
|
||||
bool operator==(const etl::unique_ptr<T1, TD1>& lhs, const etl::unique_ptr<T2, TD2>& rhs)
|
||||
{
|
||||
return lhs.get() == rhs.get();
|
||||
}
|
||||
|
||||
//*********************************
|
||||
template <typename T1, typename TD1, typename T2, typename TD2>
|
||||
bool operator<(const etl::unique_ptr<T1, TD1>& lhs, const etl::unique_ptr<T2, TD2>& rhs)
|
||||
{
|
||||
return reinterpret_cast<char*>(lhs.get()) < reinterpret_cast<char*>(rhs.get());
|
||||
}
|
||||
//*********************************
|
||||
template <typename T1, typename TD1, typename T2, typename TD2>
|
||||
bool operator<(const etl::unique_ptr<T1, TD1>& lhs, const etl::unique_ptr<T2, TD2>& rhs)
|
||||
{
|
||||
return reinterpret_cast<char*>(lhs.get()) < reinterpret_cast<char*>(rhs.get());
|
||||
}
|
||||
|
||||
//*********************************
|
||||
template <typename T1, typename TD1, typename T2, typename TD2>
|
||||
bool operator<=(const etl::unique_ptr<T1, TD1>& lhs, const etl::unique_ptr<T2, TD2>& rhs)
|
||||
{
|
||||
return !(rhs < lhs);
|
||||
}
|
||||
//*********************************
|
||||
template <typename T1, typename TD1, typename T2, typename TD2>
|
||||
bool operator<=(const etl::unique_ptr<T1, TD1>& lhs, const etl::unique_ptr<T2, TD2>& rhs)
|
||||
{
|
||||
return !(rhs < lhs);
|
||||
}
|
||||
|
||||
//*********************************
|
||||
template <typename T1, typename TD1, typename T2, typename TD2>
|
||||
bool operator>(const etl::unique_ptr<T1, TD1>& lhs, const etl::unique_ptr<T2, TD2>& rhs)
|
||||
{
|
||||
return (rhs < lhs);
|
||||
}
|
||||
//*********************************
|
||||
template <typename T1, typename TD1, typename T2, typename TD2>
|
||||
bool operator>(const etl::unique_ptr<T1, TD1>& lhs, const etl::unique_ptr<T2, TD2>& rhs)
|
||||
{
|
||||
return (rhs < lhs);
|
||||
}
|
||||
|
||||
//*********************************
|
||||
template <typename T1, typename TD1, typename T2, typename TD2>
|
||||
bool operator>=(const etl::unique_ptr<T1, TD1>& lhs, const etl::unique_ptr<T2, TD2>& rhs)
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
namespace etl
|
||||
{
|
||||
//*********************************
|
||||
template <typename T1, typename TD1, typename T2, typename TD2>
|
||||
bool operator>=(const etl::unique_ptr<T1, TD1>& lhs, const etl::unique_ptr<T2, TD2>& rhs)
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
//*****************************************************************************
|
||||
/// Default construct an item at address p.
|
||||
///\ingroup memory
|
||||
|
||||
@ -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"
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -35,6 +35,7 @@ SOFTWARE.
|
||||
|
||||
#if ETL_USING_STL
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
#endif
|
||||
|
||||
#include "functional.h"
|
||||
@ -1179,7 +1180,9 @@ namespace etl
|
||||
|
||||
namespace std
|
||||
{
|
||||
#if ETL_NOT_USING_STL && !((defined(ETL_DEVELOPMENT_OS_APPLE) || (ETL_COMPILER_FULL_VERSION >= 190000)) && defined(ETL_COMPILER_CLANG))
|
||||
#if ETL_NOT_USING_STL \
|
||||
&& !((defined(ETL_DEVELOPMENT_OS_APPLE) || (ETL_COMPILER_FULL_VERSION >= 190000) && (ETL_COMPILER_FULL_VERSION < 220000)) \
|
||||
&& defined(ETL_COMPILER_CLANG))
|
||||
template <typename T>
|
||||
struct tuple_size;
|
||||
|
||||
|
||||
@ -649,6 +649,18 @@ namespace etl
|
||||
struct is_void<void> : true_type
|
||||
{
|
||||
};
|
||||
template <>
|
||||
struct is_void<const void> : true_type
|
||||
{
|
||||
};
|
||||
template <>
|
||||
struct is_void<volatile void> : true_type
|
||||
{
|
||||
};
|
||||
template <>
|
||||
struct is_void<const volatile void> : true_type
|
||||
{
|
||||
};
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
template <typename T>
|
||||
@ -3977,6 +3989,19 @@ namespace etl
|
||||
template <typename T>
|
||||
inline constexpr bool is_function_v = etl::is_function<T>::value;
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// is_object
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
struct is_object : etl::bool_constant<!etl::is_function<T>::value && !etl::is_reference<T>::value && !etl::is_void<T>::value>
|
||||
{
|
||||
};
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
template <typename T>
|
||||
inline constexpr bool is_object_v = etl::is_object<T>::value;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
|
||||
@ -29,6 +29,7 @@ SOFTWARE.
|
||||
#include "unit_test_framework.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#if ETL_USING_CPP20
|
||||
@ -52,6 +53,65 @@ namespace
|
||||
{
|
||||
};
|
||||
|
||||
struct NotDestructible
|
||||
{
|
||||
~NotDestructible() = delete;
|
||||
};
|
||||
|
||||
struct NotDefaultConstructible
|
||||
{
|
||||
NotDefaultConstructible(int) {}
|
||||
};
|
||||
|
||||
struct NotCopyable
|
||||
{
|
||||
NotCopyable() = default;
|
||||
NotCopyable(const NotCopyable&) = delete;
|
||||
NotCopyable(NotCopyable&&) = default;
|
||||
NotCopyable& operator=(const NotCopyable&) = delete;
|
||||
NotCopyable& operator=(NotCopyable&&) = default;
|
||||
};
|
||||
|
||||
struct NotMovable
|
||||
{
|
||||
NotMovable() = default;
|
||||
NotMovable(const NotMovable&) = delete;
|
||||
NotMovable(NotMovable&&) = delete;
|
||||
NotMovable& operator=(const NotMovable&) = delete;
|
||||
NotMovable& operator=(NotMovable&&) = delete;
|
||||
};
|
||||
|
||||
struct NotEqualityComparable
|
||||
{
|
||||
};
|
||||
|
||||
struct EqualityComparableType
|
||||
{
|
||||
bool operator==(const EqualityComparableType&) const = default;
|
||||
};
|
||||
|
||||
struct OrderedType
|
||||
{
|
||||
int value;
|
||||
auto operator<=>(const OrderedType&) const = default;
|
||||
};
|
||||
|
||||
struct BoolPredicate
|
||||
{
|
||||
bool operator()(int) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct IntRelation
|
||||
{
|
||||
bool operator()(int, int) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
SUITE(test_concepts)
|
||||
{
|
||||
//*************************************************************************
|
||||
@ -140,6 +200,183 @@ namespace
|
||||
static_assert(etl::assignable_from<std::string, std::string> == false);
|
||||
static_assert(etl::assignable_from<std::atomic<int>&, int> == false);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_invocable)
|
||||
{
|
||||
struct Functor
|
||||
{
|
||||
void operator()() {}
|
||||
};
|
||||
struct FunctorWithArgs
|
||||
{
|
||||
int operator()(int, double)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
static_assert(etl::invocable<void()> == true);
|
||||
static_assert(etl::invocable<void(int), int> == true);
|
||||
static_assert(etl::invocable<Functor> == true);
|
||||
static_assert(etl::invocable<FunctorWithArgs, int, double> == true);
|
||||
static_assert(etl::invocable<FunctorWithArgs> == false);
|
||||
static_assert(etl::invocable<int> == false);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_regular_invocable)
|
||||
{
|
||||
struct Functor
|
||||
{
|
||||
void operator()() {}
|
||||
};
|
||||
|
||||
static_assert(etl::regular_invocable<void()> == true);
|
||||
static_assert(etl::regular_invocable<Functor> == true);
|
||||
static_assert(etl::regular_invocable<int> == false);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_destructible)
|
||||
{
|
||||
static_assert(etl::destructible<int> == true);
|
||||
static_assert(etl::destructible<std::string> == true);
|
||||
static_assert(etl::destructible<NotDestructible> == false);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructible_from)
|
||||
{
|
||||
static_assert(etl::constructible_from<int> == true);
|
||||
static_assert(etl::constructible_from<int, int> == true);
|
||||
static_assert(etl::constructible_from<std::string, const char*> == true);
|
||||
static_assert(etl::constructible_from<NotDestructible> == false);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_default_initializable)
|
||||
{
|
||||
static_assert(etl::default_initializable<int> == true);
|
||||
static_assert(etl::default_initializable<std::string> == true);
|
||||
static_assert(etl::default_initializable<NotDefaultConstructible> == false);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_move_constructible)
|
||||
{
|
||||
static_assert(etl::move_constructible<int> == true);
|
||||
static_assert(etl::move_constructible<std::string> == true);
|
||||
static_assert(etl::move_constructible<NotMovable> == false);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_copy_constructible)
|
||||
{
|
||||
static_assert(etl::copy_constructible<int> == true);
|
||||
static_assert(etl::copy_constructible<std::string> == true);
|
||||
static_assert(etl::copy_constructible<NotCopyable> == false);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_equality_comparable)
|
||||
{
|
||||
static_assert(etl::equality_comparable<int> == true);
|
||||
static_assert(etl::equality_comparable<EqualityComparableType> == true);
|
||||
static_assert(etl::equality_comparable<NotEqualityComparable> == false);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_totally_ordered)
|
||||
{
|
||||
static_assert(etl::totally_ordered<int> == true);
|
||||
static_assert(etl::totally_ordered<OrderedType> == true);
|
||||
static_assert(etl::totally_ordered<EqualityComparableType> == false);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_swappable)
|
||||
{
|
||||
static_assert(etl::swappable<int> == true);
|
||||
static_assert(etl::swappable<std::string> == true);
|
||||
static_assert(etl::swappable<NotMovable> == false);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_swappable_with)
|
||||
{
|
||||
// Positive cases: same-type lvalue references that are swappable
|
||||
static_assert(etl::swappable_with<int&, int&> == true);
|
||||
static_assert(etl::swappable_with<std::string&, std::string&> == true);
|
||||
|
||||
// Negative cases: unrelated types (no valid swap overload)
|
||||
static_assert(etl::swappable_with<int, std::string> == false);
|
||||
|
||||
// Negative case: non-movable type cannot be swapped
|
||||
static_assert(etl::swappable_with<NotMovable&, NotMovable&> == false);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_movable)
|
||||
{
|
||||
static_assert(etl::movable<int> == true);
|
||||
static_assert(etl::movable<std::string> == true);
|
||||
static_assert(etl::movable<NotMovable> == false);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_copyable)
|
||||
{
|
||||
static_assert(etl::copyable<int> == true);
|
||||
static_assert(etl::copyable<std::string> == true);
|
||||
static_assert(etl::copyable<NotCopyable> == false);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_semiregular)
|
||||
{
|
||||
static_assert(etl::semiregular<int> == true);
|
||||
static_assert(etl::semiregular<std::string> == true);
|
||||
static_assert(etl::semiregular<NotDefaultConstructible> == false);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_regular)
|
||||
{
|
||||
static_assert(etl::regular<int> == true);
|
||||
static_assert(etl::regular<std::string> == true);
|
||||
static_assert(etl::regular<NotEqualityComparable> == false);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_predicate)
|
||||
{
|
||||
static_assert(etl::predicate<BoolPredicate, int> == true);
|
||||
static_assert(etl::predicate<bool(int), int> == true);
|
||||
static_assert(etl::predicate<void(int), int> == false);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_relation)
|
||||
{
|
||||
static_assert(etl::relation<IntRelation, int, int> == true);
|
||||
static_assert(etl::relation<std::less<int>, int, int> == true);
|
||||
static_assert(etl::relation<BoolPredicate, int, int> == false);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_equivalence_relation)
|
||||
{
|
||||
static_assert(etl::equivalence_relation<std::equal_to<int>, int, int> == true);
|
||||
static_assert(etl::equivalence_relation<BoolPredicate, int, int> == false);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_strict_weak_order)
|
||||
{
|
||||
static_assert(etl::strict_weak_order<std::less<int>, int, int> == true);
|
||||
static_assert(etl::strict_weak_order<BoolPredicate, int, int> == false);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
#endif
|
||||
|
||||
@ -31,6 +31,7 @@ SOFTWARE.
|
||||
#include "etl/expected.h"
|
||||
#include "etl/type_traits.h"
|
||||
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -1477,5 +1478,143 @@ namespace
|
||||
auto with_error_type_check = check_expected_type_helper<void, std::string>(unexpected_out);
|
||||
CHECK_TRUE(with_error_type_check);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_begin_end_with_value)
|
||||
{
|
||||
etl::expected<std::string, Error> exp(std::string("hello"));
|
||||
|
||||
CHECK_TRUE(exp.begin() != exp.end());
|
||||
CHECK_EQUAL(std::distance(exp.begin(), exp.end()), 1);
|
||||
CHECK_EQUAL(*exp.begin(), std::string("hello"));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_begin_end_with_error)
|
||||
{
|
||||
etl::expected<std::string, Error> exp(etl::unexpected<Error>(Error("err")));
|
||||
|
||||
CHECK_TRUE(exp.begin() == exp.end());
|
||||
CHECK_EQUAL(std::distance(exp.begin(), exp.end()), 0);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_begin_end_const_with_value)
|
||||
{
|
||||
const etl::expected<std::string, Error> exp(std::string("world"));
|
||||
|
||||
CHECK_TRUE(exp.begin() != exp.end());
|
||||
CHECK_EQUAL(std::distance(exp.begin(), exp.end()), 1);
|
||||
CHECK_EQUAL(*exp.begin(), std::string("world"));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_begin_end_const_with_error)
|
||||
{
|
||||
const etl::expected<std::string, Error> exp(etl::unexpected<Error>(Error("err")));
|
||||
|
||||
CHECK_TRUE(exp.begin() == exp.end());
|
||||
CHECK_EQUAL(std::distance(exp.begin(), exp.end()), 0);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_range_for_with_value)
|
||||
{
|
||||
etl::expected<int, Error> exp(42);
|
||||
|
||||
int count = 0;
|
||||
int sum = 0;
|
||||
for (auto& v : exp)
|
||||
{
|
||||
++count;
|
||||
sum += v;
|
||||
}
|
||||
|
||||
CHECK_EQUAL(1, count);
|
||||
CHECK_EQUAL(42, sum);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_range_for_with_error)
|
||||
{
|
||||
etl::expected<int, Error> exp(etl::unexpected<Error>(Error("err")));
|
||||
|
||||
int count = 0;
|
||||
for (auto& v : exp)
|
||||
{
|
||||
(void)v;
|
||||
++count;
|
||||
}
|
||||
|
||||
CHECK_EQUAL(0, count);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_error_or_with_value)
|
||||
{
|
||||
etl::expected<int, Error> exp(42);
|
||||
|
||||
Error result = exp.error_or(Error("default"));
|
||||
CHECK_EQUAL("default", result.e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_error_or_with_error)
|
||||
{
|
||||
etl::expected<int, Error> exp(etl::unexpected<Error>(Error("real_error")));
|
||||
|
||||
Error result = exp.error_or(Error("default"));
|
||||
CHECK_EQUAL("real_error", result.e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_error_or_const_with_value)
|
||||
{
|
||||
const etl::expected<int, Error> exp(42);
|
||||
|
||||
Error result = exp.error_or(Error("default"));
|
||||
CHECK_EQUAL("default", result.e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_error_or_const_with_error)
|
||||
{
|
||||
const etl::expected<int, Error> exp(etl::unexpected<Error>(Error("real_error")));
|
||||
|
||||
Error result = exp.error_or(Error("default"));
|
||||
CHECK_EQUAL("real_error", result.e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_error_or_rvalue_with_value)
|
||||
{
|
||||
Error result = etl::expected<int, Error>(42).error_or(Error("default"));
|
||||
CHECK_EQUAL("default", result.e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_error_or_rvalue_with_error)
|
||||
{
|
||||
Error result = etl::expected<int, Error>(etl::unexpected<Error>(Error("real_error"))).error_or(Error("default"));
|
||||
CHECK_EQUAL("real_error", result.e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_error_or_void_value_with_value)
|
||||
{
|
||||
etl::expected<void, Error> exp;
|
||||
|
||||
Error result = exp.error_or(Error("default"));
|
||||
CHECK_EQUAL("default", result.e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_error_or_void_value_with_error)
|
||||
{
|
||||
etl::expected<void, Error> exp(etl::unexpected<Error>(Error("real_error")));
|
||||
|
||||
Error result = exp.error_or(Error("default"));
|
||||
CHECK_EQUAL("real_error", result.e);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@ -2211,5 +2211,43 @@ namespace
|
||||
CHECK_FALSE((etl::is_function<int MF::*>::value));
|
||||
CHECK_FALSE((etl::is_function<int (MF::*)(int)>::value)); // pointer, not function
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_is_object)
|
||||
{
|
||||
CHECK_TRUE((etl::is_object<int>::value));
|
||||
CHECK_TRUE((etl::is_object<int*>::value));
|
||||
CHECK_TRUE((etl::is_object<int[]>::value));
|
||||
CHECK_TRUE((etl::is_object<int[3]>::value));
|
||||
CHECK_TRUE((etl::is_object<const int>::value));
|
||||
CHECK_TRUE((etl::is_object<volatile int>::value));
|
||||
CHECK_TRUE((etl::is_object<MF>::value));
|
||||
|
||||
CHECK_FALSE((etl::is_object<void>::value));
|
||||
CHECK_FALSE((etl::is_object<const void>::value));
|
||||
CHECK_FALSE((etl::is_object<volatile void>::value));
|
||||
CHECK_FALSE((etl::is_object<const volatile void>::value));
|
||||
CHECK_FALSE((etl::is_object<int&>::value));
|
||||
CHECK_FALSE((etl::is_object<int&&>::value));
|
||||
CHECK_FALSE((etl::is_object<decltype(f)>::value));
|
||||
|
||||
CHECK_TRUE((etl::is_void<const void>::value));
|
||||
CHECK_TRUE((etl::is_void<volatile void>::value));
|
||||
CHECK_TRUE((etl::is_void<const volatile void>::value));
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
CHECK_TRUE((etl::is_object_v<int>));
|
||||
CHECK_TRUE((etl::is_object_v<int*>));
|
||||
CHECK_TRUE((etl::is_object_v<MF>));
|
||||
|
||||
CHECK_FALSE((etl::is_object_v<void>));
|
||||
CHECK_FALSE((etl::is_object_v<const void>));
|
||||
CHECK_FALSE((etl::is_object_v<volatile void>));
|
||||
CHECK_FALSE((etl::is_object_v<const volatile void>));
|
||||
CHECK_FALSE((etl::is_object_v<int&>));
|
||||
CHECK_FALSE((etl::is_object_v<int&&>));
|
||||
CHECK_FALSE((etl::is_object_v<decltype(f)>));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user