mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Merge branch 'development' into feature/Enforce-O(log-N)-dispatch-for-messages-when-using-message_router-for-C++11-and-up
This commit is contained in:
commit
4fba82d749
@ -2757,10 +2757,11 @@ namespace etl
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Common implementation for 'assign' and 'append' for iterators.
|
||||
/// Common implementation for 'assign' and 'append' for non-pointer iterators.
|
||||
//*********************************************************************
|
||||
template <typename TIterator>
|
||||
void append_impl(iterator position, TIterator first, TIterator last, bool truncated, bool secure)
|
||||
typename etl::enable_if<!etl::is_pointer<typename etl::remove_reference<TIterator>::type>::value>::type
|
||||
append_impl(iterator position, TIterator first, TIterator last, bool truncated, bool secure)
|
||||
{
|
||||
difference_type start = etl::distance(p_buffer, position);
|
||||
difference_type count = etl::distance(first, last);
|
||||
@ -2809,20 +2810,29 @@ namespace etl
|
||||
return;
|
||||
}
|
||||
|
||||
difference_type start = etl::distance(p_buffer, position);
|
||||
difference_type free_space = etl::distance(position, p_buffer + CAPACITY);
|
||||
append_impl(position, src, get_string_length(src), truncated, secure);
|
||||
}
|
||||
|
||||
pointer dst = position;
|
||||
size_t length = get_string_length(src);
|
||||
size_t count = (length < size_t(free_space)) ? length : size_t(free_space);
|
||||
etl::mem_move(src, count, dst);
|
||||
//*********************************************************************
|
||||
/// Core non-template implementation for 'assign' and 'append'.
|
||||
//*********************************************************************
|
||||
void append_impl(iterator position, const_pointer src, size_t length, bool truncated, bool secure)
|
||||
{
|
||||
size_t start = static_cast<size_t>(etl::distance(p_buffer, position));
|
||||
size_t free_space = static_cast<size_t>(etl::distance(position, p_buffer + CAPACITY));
|
||||
size_t count = etl::min(length, free_space);
|
||||
|
||||
truncated |= (src[count] != 0);
|
||||
current_size = size_t(start) + count;
|
||||
#if ETL_IS_DEBUG_BUILD
|
||||
ETL_ASSERT(start <= CAPACITY, ETL_ERROR(string_iterator));
|
||||
#endif
|
||||
|
||||
etl::mem_move(src, count, position);
|
||||
|
||||
current_size = start + count;
|
||||
p_buffer[current_size] = 0;
|
||||
|
||||
#if ETL_HAS_STRING_TRUNCATION_CHECKS
|
||||
set_truncated(truncated);
|
||||
set_truncated((length > free_space) || truncated);
|
||||
#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
|
||||
ETL_ASSERT(is_truncated() == false, ETL_ERROR(string_truncation));
|
||||
#endif
|
||||
@ -2842,6 +2852,16 @@ namespace etl
|
||||
cleanup();
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Common implementation for 'assign' and 'append' for pointer iterators.
|
||||
//*********************************************************************
|
||||
template <typename TIterator>
|
||||
typename etl::enable_if<etl::is_pointer<typename etl::remove_reference<TIterator>::type>::value>::type
|
||||
append_impl(iterator position, TIterator first, TIterator last, bool truncated, bool secure)
|
||||
{
|
||||
append_impl(position, first, size_t(etl::distance(first, last)), truncated || is_truncated(), secure);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Common implementation for 'find'.
|
||||
//*************************************************************************
|
||||
|
||||
@ -410,6 +410,12 @@ namespace etl
|
||||
template <typename T, typename... VTypes>
|
||||
friend ETL_CONSTEXPR14 const T&& get(const etl::variant<VTypes...>&& v);
|
||||
|
||||
template< class T, typename... VTypes >
|
||||
friend ETL_CONSTEXPR14 etl::add_pointer_t<T> get_if(etl::variant<VTypes...>* pv) ETL_NOEXCEPT;
|
||||
|
||||
template< class T, typename... VTypes >
|
||||
friend ETL_CONSTEXPR14 etl::add_pointer_t<const T> get_if(const etl::variant<VTypes...>* pv) ETL_NOEXCEPT;
|
||||
|
||||
private:
|
||||
|
||||
// All types of variant are friends.
|
||||
@ -1218,15 +1224,78 @@ namespace etl
|
||||
size_t type_id;
|
||||
};
|
||||
|
||||
namespace private_variant
|
||||
{
|
||||
//***************************************************************************
|
||||
/// is_same_type_in.
|
||||
/// Checks if specified type T is at specified index in given type list
|
||||
//***************************************************************************
|
||||
template<typename T, typename T0, typename T1, typename... Ts>
|
||||
typename etl::enable_if_t<etl::is_same<T, T0>::value, bool>
|
||||
ETL_CONSTEXPR14 is_same_type_in(size_t index) ETL_NOEXCEPT;
|
||||
|
||||
template<typename T, typename T0>
|
||||
typename etl::enable_if_t<etl::is_same<T, T0>::value, bool>
|
||||
ETL_CONSTEXPR14 is_same_type_in(size_t index) ETL_NOEXCEPT;
|
||||
|
||||
template<typename T, typename T0, typename T1, typename... Ts>
|
||||
typename etl::enable_if_t<!etl::is_same<T, T0>::value, bool>
|
||||
ETL_CONSTEXPR14 is_same_type_in(size_t index) ETL_NOEXCEPT;
|
||||
|
||||
template<typename T, typename T0>
|
||||
typename etl::enable_if_t<!etl::is_same<T, T0>::value, bool>
|
||||
ETL_CONSTEXPR14 is_same_type_in(size_t index) ETL_NOEXCEPT;
|
||||
|
||||
template<typename T, typename T0, typename T1, typename... Ts>
|
||||
typename etl::enable_if_t<etl::is_same<T, T0>::value, bool>
|
||||
ETL_CONSTEXPR14 is_same_type_in(size_t index) ETL_NOEXCEPT
|
||||
{
|
||||
if (index == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return is_same_type_in<T, T1, Ts...>(index - 1);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, typename T0>
|
||||
typename etl::enable_if_t<etl::is_same<T, T0>::value, bool>
|
||||
ETL_CONSTEXPR14 is_same_type_in(size_t index) ETL_NOEXCEPT
|
||||
{
|
||||
return index == 0;
|
||||
}
|
||||
|
||||
template<typename T, typename T0, typename T1, typename... Ts>
|
||||
typename etl::enable_if_t<!etl::is_same<T, T0>::value, bool>
|
||||
ETL_CONSTEXPR14 is_same_type_in(size_t index) ETL_NOEXCEPT
|
||||
{
|
||||
if (index == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return is_same_type_in<T, T1, Ts...>(index - 1);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, typename T0>
|
||||
typename etl::enable_if_t<!etl::is_same<T, T0>::value, bool>
|
||||
ETL_CONSTEXPR14 is_same_type_in(size_t) ETL_NOEXCEPT
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Checks if the variant v holds the alternative T.
|
||||
//***************************************************************************
|
||||
template <typename T, typename... TTypes>
|
||||
ETL_CONSTEXPR14 bool holds_alternative(const etl::variant<TTypes...>& v) ETL_NOEXCEPT
|
||||
{
|
||||
constexpr size_t Index = etl::type_list_index_of_type<etl::type_list<TTypes...>, T>::value;
|
||||
|
||||
return (Index == variant_npos) ? false : (v.index() == Index);
|
||||
{
|
||||
return private_variant::is_same_type_in<T, TTypes...>(v.index());
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -1274,6 +1343,8 @@ namespace etl
|
||||
static_assert(Index < sizeof...(TTypes), "Index out of range");
|
||||
#endif
|
||||
|
||||
ETL_ASSERT(Index == v.index(), ETL_ERROR(etl::variant_incorrect_type_exception));
|
||||
|
||||
using type = etl::variant_alternative_t<Index, etl::variant<TTypes...>>;
|
||||
|
||||
return etl::move(*static_cast<type*>(v.data));
|
||||
@ -1315,36 +1386,36 @@ namespace etl
|
||||
template <typename T, typename... TTypes>
|
||||
ETL_CONSTEXPR14 T& get(etl::variant<TTypes...>& v)
|
||||
{
|
||||
constexpr size_t Index = etl::type_list_index_of_type<etl::type_list<TTypes...>, T>::value;
|
||||
ETL_ASSERT((private_variant::is_same_type_in<T, TTypes...>(v.index())), ETL_ERROR(etl::variant_incorrect_type_exception));
|
||||
|
||||
return get<Index>(v);
|
||||
return *static_cast<T*>(v.data);
|
||||
}
|
||||
|
||||
//***********************************
|
||||
template <typename T, typename... TTypes>
|
||||
ETL_CONSTEXPR14 T&& get(etl::variant<TTypes...>&& v)
|
||||
{
|
||||
constexpr size_t Index = etl::type_list_index_of_type<etl::type_list<TTypes...>, T>::value;
|
||||
ETL_ASSERT((private_variant::is_same_type_in<T, TTypes...>(v.index())), ETL_ERROR(etl::variant_incorrect_type_exception));
|
||||
|
||||
return get<Index>(etl::move(v));
|
||||
return etl::move(*static_cast<T*>(v.data));
|
||||
}
|
||||
|
||||
//***********************************
|
||||
template <typename T, typename... TTypes>
|
||||
ETL_CONSTEXPR14 const T& get(const etl::variant<TTypes...>& v)
|
||||
{
|
||||
constexpr size_t Index = etl::type_list_index_of_type<etl::type_list<TTypes...>, T>::value;
|
||||
ETL_ASSERT((private_variant::is_same_type_in<T, TTypes...>(v.index())), ETL_ERROR(etl::variant_incorrect_type_exception));
|
||||
|
||||
return get<Index>(v);
|
||||
return *static_cast<const T*>(v.data);
|
||||
}
|
||||
|
||||
//***********************************
|
||||
template <typename T, typename... TTypes>
|
||||
ETL_CONSTEXPR14 const T&& get(const etl::variant<TTypes...>&& v)
|
||||
{
|
||||
constexpr size_t Index = etl::type_list_index_of_type<etl::type_list<TTypes...>, T>::value;
|
||||
ETL_ASSERT((private_variant::is_same_type_in<T, TTypes...>(v.index())), ETL_ERROR(etl::variant_incorrect_type_exception));
|
||||
|
||||
return get<Index>(etl::move(v));
|
||||
return etl::move(*static_cast<const T*>(v.data));
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -1383,11 +1454,9 @@ namespace etl
|
||||
template< class T, typename... TTypes >
|
||||
ETL_CONSTEXPR14 etl::add_pointer_t<T> get_if(etl::variant<TTypes...>* pv) ETL_NOEXCEPT
|
||||
{
|
||||
constexpr size_t Index = etl::type_list_index_of_type<etl::type_list<TTypes...>, T>::value;
|
||||
|
||||
if ((pv != nullptr) && (pv->index() == Index))
|
||||
if ((pv != nullptr) && (private_variant::is_same_type_in<T, TTypes...>(pv->index())))
|
||||
{
|
||||
return &etl::get<Index>(*pv);
|
||||
return static_cast<T*>(pv->data);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1399,11 +1468,9 @@ namespace etl
|
||||
template< typename T, typename... TTypes >
|
||||
ETL_CONSTEXPR14 etl::add_pointer_t<const T> get_if(const etl::variant<TTypes...>* pv) ETL_NOEXCEPT
|
||||
{
|
||||
constexpr size_t Index = etl::type_list_index_of_type<etl::type_list<TTypes...>, T>::value;
|
||||
|
||||
if ((pv != nullptr) && (pv->index() == Index))
|
||||
if ((pv != nullptr) && (private_variant::is_same_type_in<T, TTypes...>(pv->index())))
|
||||
{
|
||||
return &etl::get<Index>(*pv);
|
||||
return static_cast<const T*>(pv->data);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -92,7 +92,6 @@ namespace etl
|
||||
string(const etl::string<MAX_SIZE_>& other)
|
||||
: istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
|
||||
@ -103,7 +102,6 @@ namespace etl
|
||||
string(const etl::istring& other)
|
||||
: istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
|
||||
@ -118,7 +116,6 @@ namespace etl
|
||||
{
|
||||
ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds));
|
||||
|
||||
this->initialise();
|
||||
this->assign(other, position, length);
|
||||
}
|
||||
|
||||
@ -129,7 +126,6 @@ namespace etl
|
||||
ETL_EXPLICIT_STRING_FROM_CHAR string(const value_type* text)
|
||||
: istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text);
|
||||
}
|
||||
|
||||
@ -141,7 +137,6 @@ namespace etl
|
||||
string(const value_type* text, size_t count)
|
||||
: istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + count);
|
||||
}
|
||||
|
||||
@ -167,7 +162,6 @@ namespace etl
|
||||
string(TIterator first, TIterator last, typename etl::enable_if<!etl::is_integral<TIterator>::value, int>::type = 0)
|
||||
: istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
@ -178,7 +172,6 @@ namespace etl
|
||||
string(std::initializer_list<value_type> init)
|
||||
: istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(init.begin(), init.end());
|
||||
}
|
||||
#endif
|
||||
@ -190,7 +183,6 @@ namespace etl
|
||||
explicit string(const etl::string_view& view)
|
||||
: istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
|
||||
@ -329,7 +321,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
}
|
||||
@ -347,7 +338,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
}
|
||||
@ -367,7 +357,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
}
|
||||
@ -389,7 +378,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other, position, length);
|
||||
}
|
||||
}
|
||||
@ -413,7 +401,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other, position, length);
|
||||
}
|
||||
}
|
||||
@ -433,8 +420,7 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + etl::strlen(text));
|
||||
this->assign(text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -454,8 +440,7 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + etl::strlen(text));
|
||||
this->assign(text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -473,7 +458,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(literal);
|
||||
}
|
||||
}
|
||||
@ -493,7 +477,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(literal);
|
||||
}
|
||||
}
|
||||
@ -512,7 +495,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + count);
|
||||
}
|
||||
}
|
||||
@ -533,7 +515,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + count);
|
||||
}
|
||||
}
|
||||
@ -577,7 +558,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
}
|
||||
@ -597,7 +577,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
}
|
||||
@ -618,7 +597,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(first, last);
|
||||
}
|
||||
}
|
||||
@ -640,7 +618,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(first, last);
|
||||
}
|
||||
}
|
||||
@ -652,7 +629,6 @@ namespace etl
|
||||
string_ext(std::initializer_list<value_type> init, value_type* buffer, size_type buffer_size)
|
||||
: istring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(init.begin(), init.end());
|
||||
}
|
||||
|
||||
@ -665,7 +641,6 @@ namespace etl
|
||||
string_ext(std::initializer_list<value_type> init, value_type (&buffer)[BufferSize])
|
||||
: istring(buffer, BufferSize - 1U)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(init.begin(), init.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -89,7 +89,6 @@ namespace etl
|
||||
u16string(const etl::u16string<MAX_SIZE_>& other)
|
||||
: iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
|
||||
@ -100,7 +99,6 @@ namespace etl
|
||||
u16string(const etl::iu16string& other)
|
||||
: iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
|
||||
@ -115,7 +113,6 @@ namespace etl
|
||||
{
|
||||
ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds));
|
||||
|
||||
this->initialise();
|
||||
this->assign(other, position, length);
|
||||
}
|
||||
|
||||
@ -126,7 +123,6 @@ namespace etl
|
||||
ETL_EXPLICIT_STRING_FROM_CHAR u16string(const value_type* text)
|
||||
: iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text);
|
||||
}
|
||||
|
||||
@ -138,7 +134,6 @@ namespace etl
|
||||
u16string(const value_type* text, size_type count)
|
||||
: iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + count);
|
||||
}
|
||||
|
||||
@ -164,7 +159,6 @@ namespace etl
|
||||
u16string(TIterator first, TIterator last, typename etl::enable_if<!etl::is_integral<TIterator>::value, int>::type = 0)
|
||||
: iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
@ -175,7 +169,6 @@ namespace etl
|
||||
u16string(std::initializer_list<value_type> init)
|
||||
: iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(init.begin(), init.end());
|
||||
}
|
||||
#endif
|
||||
@ -187,7 +180,6 @@ namespace etl
|
||||
explicit u16string(const etl::u16string_view& view)
|
||||
: iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
|
||||
@ -309,7 +301,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
}
|
||||
@ -327,7 +318,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
}
|
||||
@ -347,7 +337,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
}
|
||||
@ -369,7 +358,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other, position, length);
|
||||
}
|
||||
}
|
||||
@ -393,7 +381,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other, position, length);
|
||||
}
|
||||
}
|
||||
@ -413,8 +400,7 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + etl::strlen(text));
|
||||
this->assign(text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -434,8 +420,7 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + etl::strlen(text));
|
||||
this->assign(text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -453,7 +438,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(literal);
|
||||
}
|
||||
}
|
||||
@ -473,7 +457,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(literal);
|
||||
}
|
||||
}
|
||||
@ -492,7 +475,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + count);
|
||||
}
|
||||
}
|
||||
@ -513,7 +495,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + count);
|
||||
}
|
||||
}
|
||||
@ -557,7 +538,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
}
|
||||
@ -577,7 +557,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
}
|
||||
@ -598,7 +577,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(first, last);
|
||||
}
|
||||
}
|
||||
@ -620,7 +598,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(first, last);
|
||||
}
|
||||
}
|
||||
@ -632,7 +609,6 @@ namespace etl
|
||||
u16string_ext(std::initializer_list<value_type> init, value_type* buffer, size_type buffer_size)
|
||||
: iu16string(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(init.begin(), init.end());
|
||||
}
|
||||
|
||||
@ -645,7 +621,6 @@ namespace etl
|
||||
u16string_ext(std::initializer_list<value_type> init, value_type (&buffer)[BufferSize])
|
||||
: iu16string(buffer, BufferSize - 1U)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(init.begin(), init.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -89,7 +89,6 @@ namespace etl
|
||||
u32string(const etl::u32string<MAX_SIZE_>& other)
|
||||
: iu32string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
|
||||
@ -100,7 +99,6 @@ namespace etl
|
||||
u32string(const etl::iu32string& other)
|
||||
: iu32string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
|
||||
@ -115,7 +113,6 @@ namespace etl
|
||||
{
|
||||
ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds));
|
||||
|
||||
this->initialise();
|
||||
this->assign(other, position, length);
|
||||
}
|
||||
|
||||
@ -126,7 +123,6 @@ namespace etl
|
||||
ETL_EXPLICIT_STRING_FROM_CHAR u32string(const value_type* text)
|
||||
: iu32string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text);
|
||||
}
|
||||
|
||||
@ -138,7 +134,6 @@ namespace etl
|
||||
u32string(const value_type* text, size_type count)
|
||||
: iu32string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + count);
|
||||
}
|
||||
|
||||
@ -164,7 +159,6 @@ namespace etl
|
||||
u32string(TIterator first, TIterator last, typename etl::enable_if<!etl::is_integral<TIterator>::value, int>::type = 0)
|
||||
: iu32string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
@ -175,7 +169,6 @@ namespace etl
|
||||
u32string(std::initializer_list<value_type> init)
|
||||
: iu32string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(init.begin(), init.end());
|
||||
}
|
||||
#endif
|
||||
@ -187,7 +180,6 @@ namespace etl
|
||||
explicit u32string(const etl::u32string_view& view)
|
||||
: iu32string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
|
||||
@ -309,7 +301,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
}
|
||||
@ -327,7 +318,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
}
|
||||
@ -347,7 +337,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
}
|
||||
@ -369,7 +358,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other, position, length);
|
||||
}
|
||||
}
|
||||
@ -393,7 +381,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other, position, length);
|
||||
}
|
||||
}
|
||||
@ -413,8 +400,7 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + etl::strlen(text));
|
||||
this->assign(text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -434,8 +420,7 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + etl::strlen(text));
|
||||
this->assign(text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -453,7 +438,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(literal);
|
||||
}
|
||||
}
|
||||
@ -473,7 +457,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(literal);
|
||||
}
|
||||
}
|
||||
@ -492,7 +475,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + count);
|
||||
}
|
||||
}
|
||||
@ -513,7 +495,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + count);
|
||||
}
|
||||
}
|
||||
@ -557,7 +538,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
}
|
||||
@ -577,7 +557,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
}
|
||||
@ -598,7 +577,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(first, last);
|
||||
}
|
||||
}
|
||||
@ -620,7 +598,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(first, last);
|
||||
}
|
||||
}
|
||||
@ -632,7 +609,6 @@ namespace etl
|
||||
u32string_ext(std::initializer_list<value_type> init, value_type* buffer, size_type buffer_size)
|
||||
: iu32string(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(init.begin(), init.end());
|
||||
}
|
||||
|
||||
@ -645,7 +621,6 @@ namespace etl
|
||||
u32string_ext(std::initializer_list<value_type> init, value_type (&buffer)[BufferSize])
|
||||
: iu32string(buffer, BufferSize - 1U)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(init.begin(), init.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -92,7 +92,6 @@ namespace etl
|
||||
u8string(const etl::u8string<MAX_SIZE_>& other)
|
||||
: iu8string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
|
||||
@ -103,7 +102,6 @@ namespace etl
|
||||
u8string(const etl::iu8string& other)
|
||||
: iu8string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
|
||||
@ -118,7 +116,6 @@ namespace etl
|
||||
{
|
||||
ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds));
|
||||
|
||||
this->initialise();
|
||||
this->assign(other, position, length);
|
||||
}
|
||||
|
||||
@ -129,7 +126,6 @@ namespace etl
|
||||
ETL_EXPLICIT_STRING_FROM_CHAR u8string(const value_type* text)
|
||||
: iu8string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text);
|
||||
}
|
||||
|
||||
@ -141,7 +137,6 @@ namespace etl
|
||||
u8string(const value_type* text, size_t count)
|
||||
: iu8string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + count);
|
||||
}
|
||||
|
||||
@ -167,7 +162,6 @@ namespace etl
|
||||
u8string(TIterator first, TIterator last, typename etl::enable_if<!etl::is_integral<TIterator>::value, int>::type = 0)
|
||||
: iu8string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
@ -178,7 +172,6 @@ namespace etl
|
||||
u8string(std::initializer_list<value_type> init)
|
||||
: iu8string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(init.begin(), init.end());
|
||||
}
|
||||
#endif
|
||||
@ -190,7 +183,6 @@ namespace etl
|
||||
explicit u8string(const etl::u8string_view& view)
|
||||
: iu8string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
|
||||
@ -329,7 +321,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
}
|
||||
@ -347,7 +338,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
}
|
||||
@ -367,7 +357,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
}
|
||||
@ -389,7 +378,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other, position, length);
|
||||
}
|
||||
}
|
||||
@ -413,7 +401,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other, position, length);
|
||||
}
|
||||
}
|
||||
@ -433,8 +420,7 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + etl::strlen(text));
|
||||
this->assign(text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -454,8 +440,7 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + etl::strlen(text));
|
||||
this->assign(text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -473,7 +458,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(literal);
|
||||
}
|
||||
}
|
||||
@ -493,7 +477,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(literal);
|
||||
}
|
||||
}
|
||||
@ -512,7 +495,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + count);
|
||||
}
|
||||
}
|
||||
@ -533,7 +515,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + count);
|
||||
}
|
||||
}
|
||||
@ -577,7 +558,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
}
|
||||
@ -597,7 +577,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
}
|
||||
@ -618,7 +597,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(first, last);
|
||||
}
|
||||
}
|
||||
@ -640,7 +618,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(first, last);
|
||||
}
|
||||
}
|
||||
@ -652,7 +629,6 @@ namespace etl
|
||||
u8string_ext(std::initializer_list<value_type> init, value_type* buffer, size_type buffer_size)
|
||||
: iu8string(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(init.begin(), init.end());
|
||||
}
|
||||
|
||||
@ -665,7 +641,6 @@ namespace etl
|
||||
u8string_ext(std::initializer_list<value_type> init, value_type (&buffer)[BufferSize])
|
||||
: iu8string(buffer, BufferSize - 1U)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(init.begin(), init.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -89,7 +89,6 @@ namespace etl
|
||||
wstring(const etl::wstring<MAX_SIZE_>& other)
|
||||
: iwstring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
|
||||
@ -100,7 +99,6 @@ namespace etl
|
||||
wstring(const etl::iwstring& other)
|
||||
: iwstring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
|
||||
@ -115,7 +113,6 @@ namespace etl
|
||||
{
|
||||
ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds));
|
||||
|
||||
this->initialise();
|
||||
this->assign(other, position, length);
|
||||
}
|
||||
|
||||
@ -126,7 +123,6 @@ namespace etl
|
||||
ETL_EXPLICIT_STRING_FROM_CHAR wstring(const value_type* text)
|
||||
: iwstring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text);
|
||||
}
|
||||
|
||||
@ -138,7 +134,6 @@ namespace etl
|
||||
wstring(const value_type* text, size_type count)
|
||||
: iwstring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + count);
|
||||
}
|
||||
|
||||
@ -164,7 +159,6 @@ namespace etl
|
||||
wstring(TIterator first, TIterator last, typename etl::enable_if<!etl::is_integral<TIterator>::value, int>::type = 0)
|
||||
: iwstring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
@ -175,7 +169,6 @@ namespace etl
|
||||
wstring(std::initializer_list<value_type> init)
|
||||
: iwstring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(init.begin(), init.end());
|
||||
}
|
||||
#endif
|
||||
@ -187,7 +180,6 @@ namespace etl
|
||||
explicit wstring(const etl::wstring_view& view)
|
||||
: iwstring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
|
||||
@ -309,7 +301,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
}
|
||||
@ -327,7 +318,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
}
|
||||
@ -347,7 +337,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other);
|
||||
}
|
||||
}
|
||||
@ -369,7 +358,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other, position, length);
|
||||
}
|
||||
}
|
||||
@ -393,7 +381,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(other, position, length);
|
||||
}
|
||||
}
|
||||
@ -413,8 +400,7 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + etl::strlen(text));
|
||||
this->assign(text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -434,8 +420,7 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + etl::strlen(text));
|
||||
this->assign(text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -453,7 +438,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(literal);
|
||||
}
|
||||
}
|
||||
@ -473,7 +457,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(literal);
|
||||
}
|
||||
}
|
||||
@ -492,7 +475,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + count);
|
||||
}
|
||||
}
|
||||
@ -513,7 +495,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(text, text + count);
|
||||
}
|
||||
}
|
||||
@ -557,7 +538,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
}
|
||||
@ -577,7 +557,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
}
|
||||
@ -598,7 +577,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(first, last);
|
||||
}
|
||||
}
|
||||
@ -620,7 +598,6 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(first, last);
|
||||
}
|
||||
}
|
||||
@ -632,7 +609,6 @@ namespace etl
|
||||
wstring_ext(std::initializer_list<value_type> init, value_type* buffer, size_type buffer_size)
|
||||
: iwstring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(init.begin(), init.end());
|
||||
}
|
||||
|
||||
@ -645,7 +621,6 @@ namespace etl
|
||||
wstring_ext(std::initializer_list<value_type> init, value_type (&buffer)[BufferSize])
|
||||
: iwstring(buffer, BufferSize - 1U)
|
||||
{
|
||||
this->initialise();
|
||||
this->assign(init.begin(), init.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -2182,6 +2182,49 @@ namespace
|
||||
CHECK_TRUE(variant1.is_supported_type<std::string>());
|
||||
CHECK_FALSE(variant1.is_supported_type<double>());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_variant_same_types_get)
|
||||
{
|
||||
etl::variant<int, int> v1;
|
||||
etl::variant<int, int> v2;
|
||||
|
||||
v1.emplace<0>(1);
|
||||
v2.emplace<0>(1);
|
||||
|
||||
CHECK(v1 == v2);
|
||||
|
||||
v1.emplace<0>(1);
|
||||
v2.emplace<1>(1);
|
||||
|
||||
CHECK(v1 != v2);
|
||||
|
||||
v1.emplace<0>(0);
|
||||
v2.emplace<0>(1);
|
||||
|
||||
CHECK(v1 != v2);
|
||||
|
||||
v1.emplace<1>(0);
|
||||
v2.emplace<1>(1);
|
||||
|
||||
CHECK(v1 != v2);
|
||||
|
||||
v1.emplace<1>(1);
|
||||
v2.emplace<1>(1);
|
||||
|
||||
CHECK(v1 == v2);
|
||||
|
||||
v1.emplace<0>(42);
|
||||
CHECK_EQUAL(42, etl::get<0>(v1));
|
||||
CHECK_EQUAL(0U, v1.index());
|
||||
|
||||
v1.emplace<1>(99);
|
||||
CHECK_EQUAL(99, etl::get<1>(v1));
|
||||
CHECK_EQUAL(1U, v1.index());
|
||||
|
||||
CHECK(etl::holds_alternative<int>(v1));
|
||||
CHECK(etl::get_if<int>(&v1) != nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user