Fix usage of template keyword (#1131)

For non-GCC-compilers, the template keyword is being used in
parameter_pack.h for referring to a template template member.

However, clang 19 and 20 don't accept this.

It should be verified which compiler really needs the template
keyword here at all. If not, the if-branch can be removed.

Removed redundant ETL_USING_WIDE_CHARACTERS

Added using_libc_wchar_h to ETL traits

#1127 type_traits.h and C++03

Changed many instances of mem_copy to mem_move
This commit is contained in:
Roland Reichwein 2025-06-21 17:25:10 +02:00 committed by John Wellbelove
parent bcf00d008e
commit 185557db59
8 changed files with 54 additions and 56 deletions

View File

@ -1319,7 +1319,7 @@ namespace etl
//*********************************************************************
iterator erase(iterator i_element)
{
etl::mem_copy(i_element + 1, end(), i_element);
etl::mem_move(i_element + 1, end(), i_element);
p_buffer[--current_size] = 0;
return i_element;
@ -1334,7 +1334,7 @@ namespace etl
{
iterator i_element_(to_iterator(i_element));
etl::mem_copy(i_element + 1, end(), i_element_);
etl::mem_move(i_element + 1, end(), i_element_);
p_buffer[--current_size] = 0;
return i_element_;
@ -1395,7 +1395,7 @@ namespace etl
count = size() - pos;
}
etl::mem_copy(p_buffer + pos, count, dest);
etl::mem_move(p_buffer + pos, count, dest);
return count;
}
@ -2675,7 +2675,7 @@ namespace etl
typename etl::enable_if<etl::is_pointer<TIterator1>::value && etl::is_pointer<TIterator2>::value, TIterator2>::type
copy_characters(TIterator1 from, size_t n, TIterator2 to)
{
etl::mem_copy(from, n, to);
etl::mem_move(from, n, to);
return to + n;
}
@ -2755,7 +2755,7 @@ namespace etl
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_copy(src, count, dst);
etl::mem_move(src, count, dst);
truncated |= (src[count] != 0);
current_size = size_t(start) + count;

View File

@ -2423,8 +2423,7 @@ typedef integral_constant<bool, true> true_type;
template <typename T>
struct underlying_type
{
ETL_STATIC_ASSERT(false, "No user defined specialisation of etl::underlying_type for this type");
typedef char type;
typedef int type;
};
#endif

View File

@ -2290,9 +2290,9 @@ namespace etl
{
ETL_STATIC_ASSERT(etl::is_trivially_copyable<T>::value, "Cannot mem_copy a non trivially copyable type");
memcpy(reinterpret_cast<void*>(db),
reinterpret_cast<const void*>(sb),
sizeof(typename etl::iterator_traits<T*>::value_type) * static_cast<size_t>(se - sb));
::memcpy(reinterpret_cast<void*>(db),
reinterpret_cast<const void*>(sb),
sizeof(T) * static_cast<size_t>(se - sb));
return db;
}
@ -2309,9 +2309,9 @@ namespace etl
{
ETL_STATIC_ASSERT(etl::is_trivially_copyable<T>::value, "Cannot mem_copy a non trivially copyable type");
memcpy(reinterpret_cast<void*>(db),
reinterpret_cast<const void*>(sb),
sizeof(typename etl::iterator_traits<T*>::value_type) * n);
::memcpy(reinterpret_cast<void*>(db),
reinterpret_cast<const void*>(sb),
sizeof(T) * n);
return db;
}
@ -2328,9 +2328,9 @@ namespace etl
{
ETL_STATIC_ASSERT(etl::is_trivially_copyable<T>::value, "Cannot mem_move a non trivially copyable type");
memmove(reinterpret_cast<void*>(db),
reinterpret_cast<const void*>(sb),
sizeof(T) * static_cast<size_t>(se - sb));
::memmove(reinterpret_cast<void*>(db),
reinterpret_cast<const void*>(sb),
sizeof(T) * static_cast<size_t>(se - sb));
return db;
}
@ -2347,9 +2347,9 @@ namespace etl
{
ETL_STATIC_ASSERT(etl::is_trivially_copyable<T>::value, "Cannot mem_move a non trivially copyable type");
memmove(reinterpret_cast<void*>(db),
reinterpret_cast<const void*>(sb),
sizeof(typename etl::iterator_traits<T*>::value_type) * n);
::memmove(reinterpret_cast<void*>(db),
reinterpret_cast<const void*>(sb),
sizeof(T) * n);
return db;
}
@ -2369,9 +2369,9 @@ namespace etl
{
ETL_STATIC_ASSERT(etl::is_trivially_copyable<T>::value, "Cannot mem_compare a non trivially copyable type");
return memcmp(reinterpret_cast<const void*>(db),
reinterpret_cast<const void*>(sb),
sizeof(T) * static_cast<size_t>(se - sb));
return ::memcmp(reinterpret_cast<const void*>(db),
reinterpret_cast<const void*>(sb),
sizeof(T) * static_cast<size_t>(se - sb));
}
//***************************************************************************
@ -2389,16 +2389,16 @@ namespace etl
{
ETL_STATIC_ASSERT(etl::is_trivially_copyable<T>::value, "Cannot mem_compare a non trivially copyable type");
return memcmp(reinterpret_cast<const void*>(db),
reinterpret_cast<const void*>(sb),
sizeof(T) * n);
return ::memcmp(reinterpret_cast<const void*>(db),
reinterpret_cast<const void*>(sb),
sizeof(T) * n);
}
//***************************************************************************
/// Template wrapper for memset.
/// \param db Destination begin.
/// \param de Destination end.
/// \param value The value to set each byte of the memory region.
/// \param value The value to set each <b>char</b> of the memory region.
/// \return The destination
//***************************************************************************
template <typename TPointer, typename T>
@ -2410,9 +2410,9 @@ namespace etl
{
ETL_STATIC_ASSERT(etl::is_trivially_copyable<typename etl::iterator_traits<TPointer>::value_type>::value, "Cannot mem_set a non trivially copyable type");
memset(reinterpret_cast<void*>(db),
static_cast<char>(value),
sizeof(typename etl::iterator_traits<TPointer>::value_type) * static_cast<size_t>(de - db));
::memset(reinterpret_cast<void*>(db),
static_cast<char>(value),
sizeof(typename etl::iterator_traits<TPointer>::value_type) * static_cast<size_t>(de - db));
return db;
}
@ -2421,7 +2421,7 @@ namespace etl
/// Template wrapper for memset.
/// \param db Destination begin.
/// \param n Destination length.
/// \param value The value to set each byte of the memory region.
/// \param value The value to set each <b>char</b> of the memory region.
/// \return The destination
//***************************************************************************
template <typename TPointer, typename T>
@ -2433,9 +2433,9 @@ namespace etl
{
ETL_STATIC_ASSERT(etl::is_trivially_copyable<typename etl::iterator_traits<TPointer>::value_type>::value, "Cannot mem_set a non trivially copyable type");
memset(reinterpret_cast<void*>(db),
static_cast<char>(value),
sizeof(typename etl::iterator_traits<TPointer>::value_type) * n);
::memset(reinterpret_cast<void*>(db),
static_cast<char>(value),
sizeof(typename etl::iterator_traits<TPointer>::value_type) * n);
return db;
}
@ -2455,9 +2455,9 @@ namespace etl
sizeof(T) == 1, char*>::type
mem_char(TPointer sb, TPointer se, T value) ETL_NOEXCEPT
{
void* result = memchr(reinterpret_cast<void*>(sb),
static_cast<char>(value),
sizeof(typename etl::iterator_traits<TPointer>::value_type) * static_cast<size_t>(se - sb));
void* result = ::memchr(reinterpret_cast<void*>(sb),
static_cast<char>(value),
sizeof(typename etl::iterator_traits<TPointer>::value_type) * static_cast<size_t>(se - sb));
return (result == 0U) ? reinterpret_cast<char*>(se) : reinterpret_cast<char*>(result);
}
@ -2477,9 +2477,9 @@ namespace etl
sizeof(T) == 1, const char*>::type
mem_char(TPointer sb, TPointer se, T value) ETL_NOEXCEPT
{
const void* result = memchr(reinterpret_cast<const void*>(sb),
static_cast<char>(value),
sizeof(typename etl::iterator_traits<TPointer>::value_type) * static_cast<size_t>(se - sb));
const void* result = ::memchr(reinterpret_cast<const void*>(sb),
static_cast<char>(value),
sizeof(typename etl::iterator_traits<TPointer>::value_type) * static_cast<size_t>(se - sb));
return (result == 0U) ? reinterpret_cast<const char*>(se) : reinterpret_cast<const char*>(result);
}
@ -2499,9 +2499,9 @@ namespace etl
sizeof(T) == 1, char*>::type
mem_char(TPointer sb, size_t n, T value) ETL_NOEXCEPT
{
void* result = memchr(reinterpret_cast<void*>(sb),
static_cast<char>(value),
sizeof(typename etl::iterator_traits<TPointer>::value_type) * n);
void* result = ::memchr(reinterpret_cast<void*>(sb),
static_cast<char>(value),
sizeof(typename etl::iterator_traits<TPointer>::value_type) * n);
return (result == 0U) ? reinterpret_cast<char*>(sb + n) : reinterpret_cast<char*>(result);
}
@ -2521,9 +2521,9 @@ namespace etl
sizeof(T) == 1, const char*>::type
mem_char(TPointer sb, size_t n, T value) ETL_NOEXCEPT
{
const void* result = memchr(reinterpret_cast<const void*>(sb),
static_cast<char>(value),
sizeof(typename etl::iterator_traits<TPointer>::value_type) * n);
const void* result = ::memchr(reinterpret_cast<const void*>(sb),
static_cast<char>(value),
sizeof(typename etl::iterator_traits<TPointer>::value_type) * n);
return (result == 0U) ? reinterpret_cast<const char*>(sb + n) : reinterpret_cast<const char*>(result);
}

View File

@ -579,7 +579,7 @@ namespace etl
static ETL_CONSTANT bool using_generic_compiler = (ETL_USING_GENERIC_COMPILER == 1);
static ETL_CONSTANT bool using_legacy_bitset = (ETL_USING_LEGACY_BITSET == 1);
static ETL_CONSTANT bool using_exceptions = (ETL_USING_EXCEPTIONS == 1);
static ETL_CONSTANT bool using_wide_characters = (ETL_USING_WIDE_CHARACTERS == 1);
static ETL_CONSTANT bool using_libc_wchar_h = (ETL_USING_LIBC_WCHAR_H == 1);
// Has...
static ETL_CONSTANT bool has_initializer_list = (ETL_HAS_INITIALIZER_LIST == 1);

View File

@ -367,7 +367,7 @@ namespace etl
void** p_first = (void**)(first);
void** p_last = (void**)(last);
p_end = etl::mem_copy(p_first, p_last, p_buffer) + (p_last - p_first);
p_end = etl::mem_move(p_first, p_last, p_buffer) + (p_last - p_first);
}
//*********************************************************************
@ -593,7 +593,7 @@ namespace etl
ETL_ASSERT_OR_RETURN((size() + count) <= CAPACITY, ETL_ERROR(vector_full));
etl::mem_move(position_, p_end, position_ + count);
etl::mem_copy((void**)first, (void**)last, position_);
etl::mem_move((void**)first, (void**)last, position_);
p_end += count;
}
@ -604,7 +604,7 @@ namespace etl
//*********************************************************************
iterator erase(iterator i_element)
{
etl::mem_copy(i_element + 1, end(), i_element);
etl::mem_move(i_element + 1, end(), i_element);
--p_end;
return i_element;
@ -619,7 +619,7 @@ namespace etl
{
iterator i_element_ = to_iterator(i_element);
etl::mem_copy(i_element_ + 1, end(), i_element_);
etl::mem_move(i_element_ + 1, end(), i_element_);
--p_end;
return i_element_;
@ -638,7 +638,7 @@ namespace etl
iterator first_ = to_iterator(first);
iterator last_ = to_iterator(last);
etl::mem_copy(last_, end(), first_);
etl::mem_move(last_, end(), first_);
size_t n_delete = static_cast<size_t>(etl::distance(first, last));
// Just adjust the count.

View File

@ -366,7 +366,7 @@ namespace etl
{
n = etl::min(count, size() - position);
etl::mem_copy(mbegin + position, n, destination);
etl::mem_move(mbegin + position, n, destination);
}
return n;

View File

@ -2412,12 +2412,11 @@ typedef integral_constant<bool, true> true_type;
};
#else
/// Primary template for etl::underlying_type
/// Users must spelialise this template for their enumerations.
/// Users must specialise this template for their enumerations.
template <typename T>
struct underlying_type
{
ETL_STATIC_ASSERT(false, "No user defined specialisation of etl::underlying_type for this type");
typedef char type;
typedef int type;
};
#endif

View File

@ -50,7 +50,7 @@ namespace
CHECK_EQUAL((ETL_USING_CPP20 == 1), etl::traits::using_cpp20);
CHECK_EQUAL((ETL_USING_CPP23 == 1), etl::traits::using_cpp23);
CHECK_EQUAL((ETL_USING_EXCEPTIONS == 1), etl::traits::using_exceptions);
CHECK_EQUAL((ETL_USING_WIDE_CHARACTERS == 1), etl::traits::using_wide_characters);
CHECK_EQUAL((ETL_USING_LIBC_WCHAR_H == 1), etl::traits::using_libc_wchar_h);
CHECK_EQUAL((ETL_USING_GCC_COMPILER == 1), etl::traits::using_gcc_compiler);
CHECK_EQUAL((ETL_USING_MICROSOFT_COMPILER == 1), etl::traits::using_microsoft_compiler);
CHECK_EQUAL((ETL_USING_ARM5_COMPILER == 1), etl::traits::using_arm5_compiler);