mirror of
https://github.com/ETLCPP/etl.git
synced 2026-11-09 14:49:53 +08:00
Removed template functions with default templare aurguments.
Not compatible with C++ 03
This commit is contained in:
parent
8863c91f13
commit
f4344818a3
202
src/hash.h
202
src/hash.h
@ -215,20 +215,17 @@ namespace etl
|
||||
struct hash<long>
|
||||
{
|
||||
// If it fits into a size_t.
|
||||
template <typename T = long>
|
||||
typename etl::enable_if<sizeof(size_t) >= sizeof(T), size_t>::type
|
||||
operator ()(T v) const
|
||||
size_t operator ()(long v) const
|
||||
{
|
||||
return static_cast<size_t>(v);
|
||||
}
|
||||
|
||||
// If it doesn't fit into a size_t.
|
||||
template <typename T = long>
|
||||
typename etl::enable_if<sizeof(size_t) < sizeof(T), size_t>::type
|
||||
operator ()(T v) const
|
||||
{
|
||||
uint8_t* p = reinterpret_cast<uint8_t*>(&v);
|
||||
return __private_hash__::generic_hash<size_t>(p, p + sizeof(v));
|
||||
if (sizeof(size_t) >= sizeof(v))
|
||||
{
|
||||
return static_cast<size_t>(v);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t* p = reinterpret_cast<uint8_t*>(&v);
|
||||
return __private_hash__::generic_hash<size_t>(p, p + sizeof(v));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -240,20 +237,17 @@ namespace etl
|
||||
struct hash<long long>
|
||||
{
|
||||
// If it fits into a size_t.
|
||||
template <typename T = long long>
|
||||
typename etl::enable_if<sizeof(size_t) >= sizeof(T), size_t>::type
|
||||
operator ()(T v) const
|
||||
size_t operator ()(long long v) const
|
||||
{
|
||||
return static_cast<size_t>(v);
|
||||
}
|
||||
|
||||
// If it doesn't fit into a size_t.
|
||||
template <typename T = long long>
|
||||
typename etl::enable_if<sizeof(size_t) < sizeof(T), size_t>::type
|
||||
operator ()(T v) const
|
||||
{
|
||||
uint8_t* p = reinterpret_cast<uint8_t*>(&v);
|
||||
return __private_hash__::generic_hash<size_t>(p, p + sizeof(v));
|
||||
if (sizeof(size_t) >= sizeof(v))
|
||||
{
|
||||
return static_cast<size_t>(v);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t* p = reinterpret_cast<uint8_t*>(&v);
|
||||
return __private_hash__::generic_hash<size_t>(p, p + sizeof(v));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -265,20 +259,17 @@ namespace etl
|
||||
struct hash<unsigned long>
|
||||
{
|
||||
// If it fits into a size_t.
|
||||
template <typename T = unsigned long>
|
||||
typename etl::enable_if<sizeof(size_t) >= sizeof(T), size_t>::type
|
||||
operator ()(T v) const
|
||||
size_t operator ()(unsigned long v) const
|
||||
{
|
||||
return static_cast<size_t>(v);
|
||||
}
|
||||
|
||||
// If it doesn't fit into a size_t.
|
||||
template <typename T = unsigned long>
|
||||
typename etl::enable_if<sizeof(size_t) < sizeof(T), size_t>::type
|
||||
operator ()(T v) const
|
||||
{
|
||||
uint8_t* p = reinterpret_cast<uint8_t*>(&v);
|
||||
return __private_hash__::generic_hash<size_t>(p, p + sizeof(v));
|
||||
if (sizeof(size_t) >= sizeof(v))
|
||||
{
|
||||
return static_cast<size_t>(v);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t* p = reinterpret_cast<uint8_t*>(&v);
|
||||
return __private_hash__::generic_hash<size_t>(p, p + sizeof(v));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -290,20 +281,17 @@ namespace etl
|
||||
struct hash<unsigned long long>
|
||||
{
|
||||
// If it fits into a size_t.
|
||||
template <typename T = unsigned long long>
|
||||
typename etl::enable_if<sizeof(size_t) >= sizeof(T), size_t>::type
|
||||
operator ()(T v) const
|
||||
size_t operator ()(unsigned long long v) const
|
||||
{
|
||||
return static_cast<size_t>(v);
|
||||
}
|
||||
|
||||
// If it doesn't fit into a size_t.
|
||||
template <typename T = unsigned long long>
|
||||
typename etl::enable_if<sizeof(size_t) < sizeof(T), size_t>::type
|
||||
operator ()(T v) const
|
||||
{
|
||||
uint8_t* p = reinterpret_cast<uint8_t*>(&v);
|
||||
return __private_hash__::generic_hash<size_t>(p, p + sizeof(v));
|
||||
if (sizeof(size_t) >= sizeof(v))
|
||||
{
|
||||
return static_cast<size_t>(v);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t* p = reinterpret_cast<uint8_t*>(&v);
|
||||
return __private_hash__::generic_hash<size_t>(p, p + sizeof(v));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -315,20 +303,17 @@ namespace etl
|
||||
struct hash<float>
|
||||
{
|
||||
// If it's the same size as a size_t.
|
||||
template <typename T = float>
|
||||
typename etl::enable_if<sizeof(size_t) == sizeof(T), size_t>::type
|
||||
operator ()(T v) const
|
||||
size_t operator ()(float v) const
|
||||
{
|
||||
return *reinterpret_cast<size_t*>(&v);
|
||||
}
|
||||
|
||||
// If it's not the same size as a size_t.
|
||||
template <typename T = float>
|
||||
typename etl::enable_if<sizeof(size_t) != sizeof(T), size_t>::type
|
||||
operator ()(T v) const
|
||||
{
|
||||
uint8_t* p = reinterpret_cast<uint8_t*>(&v);
|
||||
return __private_hash__::generic_hash<size_t>(p, p + sizeof(v));
|
||||
if (sizeof(size_t) == sizeof(v))
|
||||
{
|
||||
return *reinterpret_cast<size_t*>(&v);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t* p = reinterpret_cast<uint8_t*>(&v);
|
||||
return __private_hash__::generic_hash<size_t>(p, p + sizeof(v));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -340,20 +325,17 @@ namespace etl
|
||||
struct hash<double>
|
||||
{
|
||||
// If it's the same size as a size_t.
|
||||
template <typename T = double>
|
||||
typename etl::enable_if<sizeof(size_t) == sizeof(T), size_t>::type
|
||||
operator ()(T v) const
|
||||
size_t operator ()(double v) const
|
||||
{
|
||||
return *reinterpret_cast<size_t*>(&v);
|
||||
}
|
||||
|
||||
// If it's not the same size as a size_t.
|
||||
template <typename T = double>
|
||||
typename etl::enable_if<sizeof(size_t) != sizeof(T), size_t>::type
|
||||
operator ()(T v) const
|
||||
{
|
||||
uint8_t* p = reinterpret_cast<uint8_t*>(&v);
|
||||
return __private_hash__::generic_hash<size_t>(p, p + sizeof(v));
|
||||
if (sizeof(size_t) == sizeof(v))
|
||||
{
|
||||
return *reinterpret_cast<size_t*>(&v);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t* p = reinterpret_cast<uint8_t*>(&v);
|
||||
return __private_hash__::generic_hash<size_t>(p, p + sizeof(v));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -365,20 +347,17 @@ namespace etl
|
||||
struct hash<long double>
|
||||
{
|
||||
// If it's the same size as a size_t.
|
||||
template <typename T = long double>
|
||||
typename etl::enable_if<sizeof(size_t) == sizeof(T), size_t>::type
|
||||
operator ()(T v) const
|
||||
size_t operator ()(long double v) const
|
||||
{
|
||||
return *reinterpret_cast<size_t*>(&v);
|
||||
}
|
||||
|
||||
// If it's not the same size as a size_t.
|
||||
template <typename T = long double>
|
||||
typename etl::enable_if<sizeof(size_t) != sizeof(T), size_t>::type
|
||||
operator ()(T v) const
|
||||
{
|
||||
uint8_t* p = reinterpret_cast<uint8_t*>(&v);
|
||||
return __private_hash__::generic_hash<size_t>(p, p + sizeof(v));
|
||||
if (sizeof(size_t) == sizeof(v))
|
||||
{
|
||||
return *reinterpret_cast<size_t*>(&v);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t* p = reinterpret_cast<uint8_t*>(&v);
|
||||
return __private_hash__::generic_hash<size_t>(p, p + sizeof(v));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -389,38 +368,17 @@ namespace etl
|
||||
template <typename T>
|
||||
struct hash<T*>
|
||||
{
|
||||
// If it's the same size as a size_t.
|
||||
template <typename U = T>
|
||||
typename etl::enable_if<sizeof(size_t) == sizeof(U*), size_t>::type
|
||||
operator ()(U* v) const
|
||||
size_t operator ()(const T* v) const
|
||||
{
|
||||
return reinterpret_cast<size_t>(v);
|
||||
}
|
||||
|
||||
// If it's the same size as a size_t.
|
||||
template <typename U = T>
|
||||
typename etl::enable_if<sizeof(size_t) == sizeof(U*), size_t>::type
|
||||
operator ()(const U* v) const
|
||||
{
|
||||
return reinterpret_cast<size_t>(v);
|
||||
}
|
||||
|
||||
// If it's not the same size as a size_t.
|
||||
template <typename U = T>
|
||||
typename etl::enable_if<sizeof(size_t) != sizeof(U*), size_t>::type
|
||||
operator ()(U* v) const
|
||||
{
|
||||
uint8_t* p = reinterpret_cast<uint8_t*>(&v);
|
||||
return __private_hash__::generic_hash<size_t>(p, p + sizeof(v));
|
||||
}
|
||||
|
||||
// If it's not the same size as a size_t.
|
||||
template <typename U = T>
|
||||
typename etl::enable_if<sizeof(size_t) != sizeof(U*), size_t>::type
|
||||
operator ()(const U* v) const
|
||||
{
|
||||
const uint8_t* p = reinterpret_cast<const uint8_t*>(&v);
|
||||
return __private_hash__::generic_hash<size_t>(p, p + sizeof(v));
|
||||
if (sizeof(size_t) == sizeof(T*))
|
||||
{
|
||||
return reinterpret_cast<size_t>(v);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t* p = reinterpret_cast<uint8_t*>(&v);
|
||||
return __private_hash__::generic_hash<size_t>(p, p + sizeof(v));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -31,7 +31,9 @@ SOFTWARE.
|
||||
#ifndef __ETL_INTRUSIVE_FORWARD_LIST__
|
||||
#define __ETL_INTRUSIVE_FORWARD_LIST__
|
||||
|
||||
#if WIN32
|
||||
#include "platform.h"
|
||||
|
||||
#ifdef ETL_COMPILER_MICROSOFT
|
||||
#undef min
|
||||
#endif
|
||||
|
||||
@ -494,55 +496,32 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Inserts a value to the intrusive_forward_list after the specified position.
|
||||
/// Checks that the value is unlinked if CHECKED.
|
||||
//*************************************************************************
|
||||
template <typename T = TLink>
|
||||
typename etl::enable_if<T::OPTION == etl::link_option::DEFAULT, iterator>::type
|
||||
insert_after(iterator position, value_type& value)
|
||||
iterator insert_after(iterator position, value_type& value)
|
||||
{
|
||||
insert_link_after(*position.p_value, value);
|
||||
return iterator(value);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Inserts a value to the intrusive_forward_list after the specified position.
|
||||
/// Checks that the value is unlinked.
|
||||
//*************************************************************************
|
||||
template <typename T = TLink>
|
||||
typename etl::enable_if<T::OPTION == etl::link_option::CHECKED, iterator>::type
|
||||
insert_after(iterator position, value_type& value)
|
||||
{
|
||||
ETL_ASSERT(!value.TLink::is_linked(), ETL_ERROR(etl::not_unlinked_exception));
|
||||
|
||||
insert_link_after(*position.p_value, value);
|
||||
return iterator(value);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Inserts a range of values to the intrusive_forward_list after the specified position.
|
||||
//*************************************************************************
|
||||
template <typename TIterator, typename T = TLink>
|
||||
typename etl::enable_if<T::OPTION == etl::link_option::DEFAULT, void>::type
|
||||
insert_after(iterator position, TIterator first, TIterator last)
|
||||
{
|
||||
while (first != last)
|
||||
if (TLink::OPTION == etl::link_option::CHECKED)
|
||||
{
|
||||
// Set up the next free link.
|
||||
insert_link_after(*position.p_value, *first++);
|
||||
++position;
|
||||
ETL_ASSERT(!value.TLink::is_linked(), ETL_ERROR(etl::not_unlinked_exception));
|
||||
}
|
||||
|
||||
insert_link_after(*position.p_value, value);
|
||||
return iterator(value);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Inserts a range of values to the intrusive_forward_list after the specified position.
|
||||
/// Checks that the values are unlinked.
|
||||
/// Checks that the values are unlinked if CHECKED.
|
||||
//*************************************************************************
|
||||
template <typename TIterator, typename T = TLink>
|
||||
typename etl::enable_if<T::OPTION == etl::link_option::CHECKED, void>::type
|
||||
insert_after(iterator position, TIterator first, TIterator last)
|
||||
template <typename TIterator>
|
||||
void insert_after(iterator position, TIterator first, TIterator last)
|
||||
{
|
||||
while (first != last)
|
||||
{
|
||||
ETL_ASSERT(!position.p_value->TLink::is_linked(), ETL_ERROR(etl::not_unlinked_exception));
|
||||
if (TLink::OPTION == etl::link_option::CHECKED)
|
||||
{
|
||||
ETL_ASSERT(!position.p_value->TLink::is_linked(), ETL_ERROR(etl::not_unlinked_exception));
|
||||
}
|
||||
|
||||
// Set up the next free link.
|
||||
insert_link_after(*position.p_value, *first++);
|
||||
@ -552,81 +531,29 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Erases the value at the specified position.
|
||||
/// Clears the link after erasing if CHECKED.
|
||||
//*************************************************************************
|
||||
template <typename T = TLink>
|
||||
typename etl::enable_if<T::OPTION == etl::link_option::DEFAULT, iterator>::type
|
||||
erase_after(iterator position)
|
||||
iterator erase_after(iterator position)
|
||||
{
|
||||
iterator next(position);
|
||||
++next;
|
||||
++next;
|
||||
|
||||
remove_link_after(*position.p_value);
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Erases the value at the specified position.
|
||||
/// Clears the link after erasing.
|
||||
//*************************************************************************
|
||||
template <typename T = TLink>
|
||||
typename etl::enable_if<T::OPTION == etl::link_option::CHECKED, iterator>::type
|
||||
erase_after(iterator position)
|
||||
{
|
||||
iterator next(position);
|
||||
++next;
|
||||
++next;
|
||||
|
||||
remove_link_after(*position.p_value);
|
||||
position.p_value->TLink::clear();
|
||||
|
||||
if (TLink::OPTION == etl::link_option::CHECKED)
|
||||
{
|
||||
position.p_value->TLink::clear();
|
||||
}
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Erases a range of elements.
|
||||
/// Clears the links after erasing if CHECKED.
|
||||
//*************************************************************************
|
||||
template <typename T = TLink>
|
||||
typename etl::enable_if<T::OPTION == etl::link_option::DEFAULT, iterator>::type
|
||||
erase_after(iterator first, iterator last)
|
||||
{
|
||||
link_type* p_first = first.p_value;
|
||||
link_type* p_last = last.p_value;
|
||||
link_type* p_next = p_first->etl_next;
|
||||
|
||||
// Join the ends.
|
||||
etl::link<link_type>(p_first, p_last);
|
||||
|
||||
p_first = p_next;
|
||||
|
||||
// Erase the ones in between.
|
||||
while (p_first != p_last)
|
||||
{
|
||||
// One less.
|
||||
--current_size;
|
||||
|
||||
p_next = p_first->etl_next; // Remember the next link.
|
||||
p_first = p_next; // Move to the next link.
|
||||
}
|
||||
|
||||
if (p_next == nullptr)
|
||||
{
|
||||
return end();
|
||||
}
|
||||
else
|
||||
{
|
||||
return iterator(*static_cast<value_type*>(p_last));
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Erases a range of elements.
|
||||
/// Clears the links after erasing.
|
||||
//*************************************************************************
|
||||
template <typename T = TLink>
|
||||
typename etl::enable_if<T::OPTION == etl::link_option::CHECKED, iterator>::type
|
||||
erase_after(iterator first, iterator last)
|
||||
iterator erase_after(iterator first, iterator last)
|
||||
{
|
||||
link_type* p_first = first.p_value;
|
||||
link_type* p_last = last.p_value;
|
||||
@ -644,7 +571,12 @@ namespace etl
|
||||
--current_size;
|
||||
|
||||
p_next = p_first->etl_next; // Remember the next link.
|
||||
p_first->TLink::clear(); // Clear the link.
|
||||
|
||||
if (TLink::OPTION == etl::link_option::CHECKED)
|
||||
{
|
||||
p_first->TLink::clear(); // Clear the link.
|
||||
}
|
||||
|
||||
p_first = p_next; // Move to the next link.
|
||||
}
|
||||
|
||||
@ -871,21 +803,16 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns the number of elements.
|
||||
//*************************************************************************
|
||||
template <const size_t OPT = COUNT_OPTION>
|
||||
typename etl::enable_if<OPT == etl::count_option::FAST_COUNT, size_t>::type
|
||||
size() const
|
||||
size_t size() const
|
||||
{
|
||||
return current_size.count;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns the number of elements.
|
||||
//*************************************************************************
|
||||
template <const size_t OPT = COUNT_OPTION>
|
||||
typename etl::enable_if<OPT == etl::count_option::SLOW_COUNT, size_t>::type
|
||||
size() const
|
||||
{
|
||||
return std::distance(cbegin(), cend());
|
||||
if (COUNT_OPTION == etl::count_option::SLOW_COUNT)
|
||||
{
|
||||
return std::distance(cbegin(), cend());
|
||||
}
|
||||
else
|
||||
{
|
||||
return current_size.count;
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1216,7 +1143,7 @@ namespace etl
|
||||
};
|
||||
}
|
||||
|
||||
#if WIN32
|
||||
#ifdef ETL_COMPILER_MICROSOFT
|
||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
|
||||
@ -31,7 +31,9 @@ SOFTWARE.
|
||||
#ifndef __ETL_INTRUSIVE_LIST__
|
||||
#define __ETL_INTRUSIVE_LIST__
|
||||
|
||||
#if WIN32
|
||||
#include "platform.h"
|
||||
|
||||
#ifdef ETL_COMPILER_MICROSOFT
|
||||
#undef min
|
||||
#endif
|
||||
|
||||
@ -532,54 +534,32 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Inserts a value to the intrusive_list before the specified position.
|
||||
/// Checks that the value is unlinked if CHECKED
|
||||
//*************************************************************************
|
||||
template <typename T = TLink>
|
||||
typename etl::enable_if<(T::OPTION == etl::link_option::DEFAULT) || (T::OPTION == etl::link_option::AUTO), iterator>::type
|
||||
insert(iterator position, value_type& value)
|
||||
iterator insert(iterator position, value_type& value)
|
||||
{
|
||||
if (TLink::OPTION == etl::link_option::CHECKED)
|
||||
{
|
||||
ETL_ASSERT(!value.TLink::is_linked(), ETL_ERROR(etl::not_unlinked_exception));
|
||||
}
|
||||
|
||||
insert_link(position.p_value->link_type::etl_previous, value);
|
||||
return iterator(value);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Inserts a value to the intrusive_list before the specified position.
|
||||
/// Checks that the value is unlinked.
|
||||
//*************************************************************************
|
||||
template <typename T = TLink>
|
||||
typename etl::enable_if<T::OPTION == etl::link_option::CHECKED, iterator>::type
|
||||
insert(iterator position, value_type& value)
|
||||
{
|
||||
ETL_ASSERT(!value.TLink::is_linked(), ETL_ERROR(etl::not_unlinked_exception));
|
||||
|
||||
insert_link(position.p_value->etl_previous, value);
|
||||
return iterator(value);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Inserts a range of values to the intrusive_list before the specified position.
|
||||
//*************************************************************************
|
||||
template <typename TIterator, typename T = TLink>
|
||||
typename etl::enable_if<(T::OPTION == etl::link_option::DEFAULT) || (T::OPTION == etl::link_option::AUTO), void>::type
|
||||
insert(iterator position, TIterator first, TIterator last)
|
||||
{
|
||||
while (first != last)
|
||||
{
|
||||
// Set up the next free link.
|
||||
insert_link(*position.p_value->link_type::etl_previous, *first++);
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Inserts a range of values to the intrusive_list after the specified position.
|
||||
/// Checks that the values are unlinked.
|
||||
/// Checks that the values are unlinked if CHECKED.
|
||||
//*************************************************************************
|
||||
template <typename TIterator, typename T = TLink>
|
||||
typename etl::enable_if<T::OPTION == etl::link_option::CHECKED, void>::type
|
||||
insert(iterator position, TIterator first, TIterator last)
|
||||
template <typename TIterator>
|
||||
void insert(iterator position, TIterator first, TIterator last)
|
||||
{
|
||||
while (first != last)
|
||||
{
|
||||
ETL_ASSERT(!position.p_value->TLink::is_linked(), ETL_ERROR(etl::not_unlinked_exception));
|
||||
if (TLink::OPTION == etl::link_option::CHECKED)
|
||||
{
|
||||
ETL_ASSERT(!position.p_value->TLink::is_linked(), ETL_ERROR(etl::not_unlinked_exception));
|
||||
}
|
||||
|
||||
// Set up the next free link.
|
||||
insert_link(*position.p_value->link_type::etl_previous, *first++);
|
||||
@ -601,10 +581,9 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Erases a range of elements.
|
||||
/// Clears the links after erasing if AUTO or CHECKED.
|
||||
//*************************************************************************
|
||||
template <typename T = TLink>
|
||||
typename etl::enable_if<T::OPTION == etl::link_option::DEFAULT, iterator>::type
|
||||
erase(iterator first, iterator last)
|
||||
iterator erase(iterator first, iterator last)
|
||||
{
|
||||
link_type* p_first = first.p_value;
|
||||
link_type* p_last = last.p_value;
|
||||
@ -617,41 +596,21 @@ namespace etl
|
||||
current_size -= std::distance(first, last);
|
||||
}
|
||||
|
||||
if (p_last == &terminal_link)
|
||||
if ((TLink::OPTION == etl::link_option::AUTO) ||
|
||||
(TLink::OPTION == etl::link_option::CHECKED))
|
||||
{
|
||||
return end();
|
||||
}
|
||||
else
|
||||
{
|
||||
return iterator(*static_cast<value_type*>(p_last));
|
||||
}
|
||||
}
|
||||
// Clear the ones in between.
|
||||
link_type* p_next;
|
||||
|
||||
//*************************************************************************
|
||||
/// Erases a range of elements.
|
||||
/// Clears the links after erasing.
|
||||
//*************************************************************************
|
||||
template <typename T = TLink>
|
||||
typename etl::enable_if<(T::OPTION == etl::link_option::AUTO) || (T::OPTION == etl::link_option::CHECKED), iterator>::type
|
||||
erase(iterator first, iterator last)
|
||||
{
|
||||
link_type* p_first = first.p_value;
|
||||
link_type* p_last = last.p_value;
|
||||
while (p_first != p_last)
|
||||
{
|
||||
// One less.
|
||||
--current_size;
|
||||
|
||||
// Join the ends.
|
||||
etl::link<link_type>(p_first->etl_previous, p_last);
|
||||
|
||||
// Clear the ones in between.
|
||||
link_type* p_next;
|
||||
|
||||
while (p_first != p_last)
|
||||
{
|
||||
// One less.
|
||||
--current_size;
|
||||
|
||||
p_next = p_first->etl_next; // Remember the next link.
|
||||
p_first->TLink::clear(); // Clear the link.
|
||||
p_first = p_next; // Move to the next link.
|
||||
p_next = p_first->etl_next; // Remember the next link.
|
||||
p_first->TLink::clear(); // Clear the link.
|
||||
p_first = p_next; // Move to the next link.
|
||||
}
|
||||
}
|
||||
|
||||
if (p_last == &terminal_link)
|
||||
@ -867,21 +826,16 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns the number of elements.
|
||||
//*************************************************************************
|
||||
template <const size_t OPT = COUNT_OPTION>
|
||||
typename etl::enable_if<OPT == etl::count_option::FAST_COUNT, size_t>::type
|
||||
size() const
|
||||
size_t size() const
|
||||
{
|
||||
return current_size.count;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns the number of elements.
|
||||
//*************************************************************************
|
||||
template <const size_t OPT = COUNT_OPTION>
|
||||
typename etl::enable_if<OPT == etl::count_option::SLOW_COUNT, size_t>::type
|
||||
size() const
|
||||
{
|
||||
return std::distance(cbegin(), cend());
|
||||
if (COUNT_OPTION == etl::count_option::SLOW_COUNT)
|
||||
{
|
||||
return std::distance(cbegin(), cend());
|
||||
}
|
||||
else
|
||||
{
|
||||
return current_size.count;
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1237,7 +1191,7 @@ namespace etl
|
||||
};
|
||||
}
|
||||
|
||||
#if WIN32
|
||||
#ifdef ETL_COMPILER_MICROSOFT
|
||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user