Merge remote-tracking branch 'origin/development'

This commit is contained in:
John Wellbelove 2016-12-28 17:12:46 +00:00
commit 5c42b7a830
107 changed files with 7138 additions and 2982 deletions

View File

@ -1,5 +1,5 @@
name=Embedded Template Library
version=8.2.0
version=9.0.0
author= John Wellbelove <john.wellbelove@etlcpp.com>
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
sentence=A C++ template library tailored for embedded systems.

View File

@ -174,7 +174,7 @@ namespace etl
union
{
uint8_t data[LENGTH];
uint_least8_t data[LENGTH];
typename etl::type_with_alignment<ALIGNMENT>::type __etl_alignment_type__; // A POD type that has the same alignment as ALIGNMENT.
};
};

View File

@ -44,6 +44,7 @@ SOFTWARE.
#include "log.h"
#include "power.h"
#include "smallest.h"
#include "platform.h"
namespace etl
{
@ -170,6 +171,7 @@ namespace etl
return result;
}
#if ETL_8BIT_SUPPORT
//***************************************************************************
/// Reverse 8 bits.
//***************************************************************************
@ -183,6 +185,7 @@ namespace etl
return value;
}
#endif
//***************************************************************************
/// Reverse 16 bits.
@ -282,6 +285,7 @@ namespace etl
return (value >> 1) ^ value;
}
#if ETL_8BIT_SUPPORT
//***************************************************************************
/// Converts Gray code to binary.
//***************************************************************************
@ -295,6 +299,7 @@ namespace etl
return value;
}
#endif
//***************************************************************************
/// Converts Gray code to binary.
@ -344,6 +349,7 @@ namespace etl
return value;
}
#if ETL_8BIT_SUPPORT
//***************************************************************************
/// Count set bits. 8 bits.
//***************************************************************************
@ -361,6 +367,7 @@ namespace etl
return count;
}
#endif
//***************************************************************************
/// Count set bits. 16 bits.
@ -422,6 +429,7 @@ namespace etl
return size_t(count);
}
#if ETL_8BIT_SUPPORT
//***************************************************************************
/// Parity. 8bits. 0 = even, 1 = odd
//***************************************************************************
@ -433,6 +441,7 @@ namespace etl
value &= 0x0F;
return (0x6996 >> value) & 1;
}
#endif
//***************************************************************************
/// Parity. 16bits. 0 = even, 1 = odd

81
src/callback.h Normal file
View File

@ -0,0 +1,81 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
http://www.etlcpp.com
Copyright(c) 2015 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_CALLBACK__
#define __ETL_CALLBACK__
namespace etl
{
//***************************************************************************
/// A callback class designed to be multiply inherited by other client classes.
/// The class is parametrised with a callback parameter type and a unique id.
/// The unique id allows multiple callbacks with the same parameter type.
///\tparam TParameter The callback parameter type.
///\tparam ID The unique id for this callback.
//***************************************************************************
template <typename TParameter, const int ID>
class callback
{
private:
// Creates a parameter type unique to this ID.
template <typename T, const int I>
struct parameter
{
parameter(T value)
: value(value)
{
}
typedef T value_type;
T value;
private:
parameter();
};
// Specialisation for void.
template <const int I>
struct parameter<void, I>
{
typedef void value_type;
};
public:
typedef parameter<TParameter, ID> type;
virtual void etl_callback(type p = type()) = 0;
};
}
#endif

View File

@ -44,7 +44,7 @@ SOFTWARE.
//*****************************************************************************
// Define the large character types if necessary.
#ifdef NO_LARGE_CHAR_SUPPORT
#ifdef ETL_NO_LARGE_CHAR_SUPPORT
typedef int16_t char16_t;
typedef int32_t char32_t;
#endif

View File

@ -277,7 +277,7 @@ namespace etl
///\ingroup container
///**************************************************************************
template<typename TValue, const size_t ARRAY_SIZE>
size_t size(TValue(&data)[ARRAY_SIZE])
size_t size(TValue(&)[ARRAY_SIZE])
{
return ARRAY_SIZE;
}

View File

@ -30,6 +30,11 @@ SOFTWARE.
#include <stdint.h>
#include "platform.h"
#include "static_assert.h"
STATIC_ASSERT(ETL_8BIT_SUPPORT, "This file does not currently support targets with no 8bit type");
namespace etl
{
//***************************************************************************

View File

@ -33,6 +33,8 @@ SOFTWARE.
#include "platform.h"
#include "basic_string.h"
#include "ibasic_string.h"
#include "hash.h"
#if defined(ETL_COMPILER_MICROSOFT)
#undef min
@ -40,7 +42,7 @@ SOFTWARE.
namespace etl
{
typedef ibasic_string<char> istring;
typedef etl::ibasic_string<char> istring;
//***************************************************************************
/// A string implementation that uses a fixed size buffer.
@ -151,11 +153,11 @@ namespace etl
{
etl::string<MAX_SIZE_> new_string;
if (position != size())
if (position != this->size())
{
ETL_ASSERT(position < size(), ETL_ERROR(string_out_of_bounds));
ETL_ASSERT(position < this->size(), ETL_ERROR(string_out_of_bounds));
length = std::min(length, size() - position);
length = std::min(length, this->size() - position);
new_string.assign(buffer + position, buffer + position + length);
}
@ -180,6 +182,19 @@ namespace etl
value_type buffer[MAX_SIZE + 1];
};
//*************************************************************************
/// Hash function.
//*************************************************************************
template <>
struct hash<etl::istring>
{
size_t operator()(const etl::istring& text) const
{
return etl::__private_hash__::generic_hash<>(reinterpret_cast<const uint8_t*>(&text[0]),
reinterpret_cast<const uint8_t*>(&text[text.size()]));
}
};
}
#if defined(ETL_COMPILER_MICROSOFT)

View File

@ -116,7 +116,7 @@ namespace etl
REPEATING = 16
};
uint8_t state;
uint_least8_t state;
/// The state count.
uint16_t count;

View File

@ -68,7 +68,7 @@ namespace etl
struct endianness
{
endianness()
: ETL_ENDIAN_TEST(0x0011)
: ETL_ENDIAN_TEST(0x0011223344556677)
{
}
@ -79,12 +79,12 @@ namespace etl
operator endian() const
{
return (*reinterpret_cast<const uint8_t*>(&ETL_ENDIAN_TEST) == 0x11) ? endian::little : endian::big;
return (*reinterpret_cast<const uint32_t*>(&ETL_ENDIAN_TEST) == 0x44556677) ? endian::little : endian::big;
}
private:
const uint16_t ETL_ENDIAN_TEST;
const uint64_t ETL_ENDIAN_TEST;
};
}

View File

@ -35,7 +35,7 @@ SOFTWARE.
/// The base class for all ETL exceptions.
///\ingroup utilities
namespace etl
namespace etl
{
//***************************************************************************
///\ingroup exception
@ -66,6 +66,7 @@ namespace etl
: reason(reason),
line(line)
{
(void)file;
}
#endif

View File

@ -23,4 +23,7 @@
23 iunordered_set, iunordered_multiset
24 variant
25 iunordered_multimap
26 iunordered_multiset
26 iunordered_multiset
27 string_base
28 intrusive_stack
29 intrusive_queue

View File

@ -137,7 +137,7 @@ namespace etl
//***************************************************************************
/// += operator.
//***************************************************************************
fixed_iterator& operator +=(typename std::iterator_traits<TIterator>::difference_type offset)
fixed_iterator& operator +=(typename std::iterator_traits<TIterator>::difference_type /*offset*/)
{
return *this;
}
@ -145,7 +145,7 @@ namespace etl
//***************************************************************************
/// -= operator.
//***************************************************************************
fixed_iterator& operator -=(typename std::iterator_traits<TIterator>::difference_type offset)
fixed_iterator& operator -=(typename std::iterator_traits<TIterator>::difference_type /*offset*/)
{
return *this;
}
@ -179,7 +179,7 @@ namespace etl
//*****************************************************************************
template <typename TIterator>
etl::fixed_iterator<TIterator>& operator +(etl::fixed_iterator<TIterator>& lhs,
typename std::iterator_traits<TIterator>::difference_type rhs)
typename std::iterator_traits<TIterator>::difference_type /*rhs*/)
{
return lhs;
}
@ -189,7 +189,7 @@ etl::fixed_iterator<TIterator>& operator +(etl::fixed_iterator<TIterator>& lhs,
//*****************************************************************************
template <typename TIterator>
etl::fixed_iterator<TIterator>& operator -(etl::fixed_iterator<TIterator>& lhs,
typename std::iterator_traits<TIterator>::difference_type rhs)
typename std::iterator_traits<TIterator>::difference_type /*rhs*/)
{
return lhs;
}

View File

@ -37,6 +37,8 @@ SOFTWARE.
#include "static_assert.h"
#include "type_traits.h"
#include "ihash.h"
#include "frame_check_sequence.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
@ -47,22 +49,49 @@ SOFTWARE.
namespace etl
{
//***************************************************************************
/// fnv_1 policy.
/// Calculates FNV1.
//***************************************************************************
struct fnv_1_policy_64
{
typedef uint64_t value_type;
inline uint64_t initial() const
{
return OFFSET_BASIS;
}
inline uint64_t add(uint64_t hash, uint8_t value) const
{
hash *= PRIME;
hash ^= value;
return hash;
}
inline uint64_t final(uint64_t hash) const
{
return hash;
}
static const uint64_t OFFSET_BASIS = 0xCBF29CE484222325;
static const uint64_t PRIME = 0x00000100000001b3;
};
//***************************************************************************
/// Calculates the fnv_1_64 hash.
///\ingroup fnv_1_64
//***************************************************************************
class fnv_1_64
class fnv_1_64 : public etl::frame_check_sequence<fnv_1_policy_64>
{
public:
typedef uint64_t value_type;
//*************************************************************************
/// Default constructor.
//*************************************************************************
fnv_1_64()
{
reset();
this->reset();
}
//*************************************************************************
@ -73,70 +102,36 @@ namespace etl
template<typename TIterator>
fnv_1_64(TIterator begin, const TIterator end)
{
STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Type not supported");
this->reset();
this->add(begin, end);
}
};
reset();
while (begin != end)
//***************************************************************************
/// fnv_1a policy.
/// Calculates FNV1A.
//***************************************************************************
struct fnv_1a_policy_64
{
typedef uint64_t value_type;
inline uint64_t initial() const
{
hash *= PRIME;
hash ^= *begin++;
}
return OFFSET_BASIS;
}
//*************************************************************************
/// Resets the CRC to the initial state.
//*************************************************************************
void reset()
inline uint64_t add(uint64_t hash, uint8_t value) const
{
hash = OFFSET_BASIS;
}
//*************************************************************************
/// Adds a range.
/// \param begin
/// \param end
//*************************************************************************
template<typename TIterator>
void add(TIterator begin, const TIterator end)
{
STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Type not supported");
while (begin != end)
{
hash *= PRIME;
hash ^= *begin++;
}
}
//*************************************************************************
/// \param value The char to add to the fnv_1_64.
//*************************************************************************
void add(uint8_t value)
{
hash *= PRIME;
hash ^= value;
}
//*************************************************************************
/// Gets the fnv_1_64 value.
//*************************************************************************
value_type value() const
{
hash *= PRIME;
return hash;
}
//*************************************************************************
/// Conversion operator to value_type.
//*************************************************************************
operator value_type () const
inline uint64_t final(uint64_t hash) const
{
return hash;
}
private:
value_type hash;
static const uint64_t OFFSET_BASIS = 0xCBF29CE484222325;
static const uint64_t PRIME = 0x00000100000001b3;
};
@ -145,18 +140,16 @@ namespace etl
/// Calculates the fnv_1a_64 hash.
///\ingroup fnv_1a_64
//***************************************************************************
class fnv_1a_64
class fnv_1a_64 : public etl::frame_check_sequence<fnv_1a_policy_64>
{
public:
typedef uint64_t value_type;
//*************************************************************************
/// Default constructor.
//*************************************************************************
fnv_1a_64()
{
reset();
this->reset();
}
//*************************************************************************
@ -167,90 +160,54 @@ namespace etl
template<typename TIterator>
fnv_1a_64(TIterator begin, const TIterator end)
{
STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Type not supported");
reset();
while (begin != end)
{
hash ^= *begin++;
hash *= PRIME;
}
this->reset();
this->add(begin, end);
}
};
//*************************************************************************
/// Resets the CRC to the initial state.
//*************************************************************************
void reset()
//***************************************************************************
/// fnv_1 policy.
/// Calculates FNV1.
//***************************************************************************
struct fnv_1_policy_32
{
hash = OFFSET_BASIS;
}
//*************************************************************************
/// Adds a range.
/// \param begin
/// \param end
//*************************************************************************
template<typename TIterator>
void add(TIterator begin, const TIterator end)
{
STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Type not supported");
typedef uint32_t value_type;
while (begin != end)
inline uint32_t initial() const
{
hash ^= *begin++;
hash *= PRIME;
}
return OFFSET_BASIS;
}
//*************************************************************************
/// \param value The char to add to the fnv_1a_64.
//*************************************************************************
void add(uint8_t value)
inline uint32_t add(uint32_t hash, uint8_t value) const
{
hash ^= value;
hash *= PRIME;
hash ^= value;
return hash;
}
//*************************************************************************
/// Gets the fnv_1a_64 value.
//*************************************************************************
value_type value() const
inline uint32_t final(uint32_t hash) const
{
return hash;
}
//*************************************************************************
/// Conversion operator to value_type.
//*************************************************************************
operator value_type () const
{
return hash;
}
private:
value_type hash;
static const uint64_t OFFSET_BASIS = 0xCBF29CE484222325;
static const uint64_t PRIME = 0x00000100000001b3;
static const uint32_t OFFSET_BASIS = 0x811C9DC5;
static const uint32_t PRIME = 0x01000193;
};
//***************************************************************************
/// Calculates the fnv_1_32 hash.
///\ingroup fnv_1_32
//***************************************************************************
class fnv_1_32
class fnv_1_32 : public etl::frame_check_sequence<fnv_1_policy_32>
{
public:
typedef uint32_t value_type;
//*************************************************************************
/// Default constructor.
//*************************************************************************
fnv_1_32()
{
reset();
this->reset();
}
//*************************************************************************
@ -261,70 +218,36 @@ namespace etl
template<typename TIterator>
fnv_1_32(TIterator begin, const TIterator end)
{
STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Type not supported");
this->reset();
this->add(begin, end);
}
};
reset();
while (begin != end)
//***************************************************************************
/// fnv_1a policy.
/// Calculates FNV1A.
//***************************************************************************
struct fnv_1a_policy_32
{
typedef uint32_t value_type;
inline uint32_t initial() const
{
hash *= PRIME;
hash ^= *begin++;
}
return OFFSET_BASIS;
}
//*************************************************************************
/// Resets the CRC to the initial state.
//*************************************************************************
void reset()
inline uint32_t add(uint32_t hash, uint8_t value) const
{
hash = OFFSET_BASIS;
}
//*************************************************************************
/// Adds a range.
/// \param begin
/// \param end
//*************************************************************************
template<typename TIterator>
void add(TIterator begin, const TIterator end)
{
STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Type not supported");
while (begin != end)
{
hash *= PRIME;
hash ^= *begin++;
}
}
//*************************************************************************
/// \param value The char to add to the fnv_1_32.
//*************************************************************************
void add(uint8_t value)
{
hash *= PRIME;
hash ^= value;
}
//*************************************************************************
/// Gets the fnv_1_32 value.
//*************************************************************************
value_type value() const
{
hash *= PRIME;
return hash;
}
//*************************************************************************
/// Conversion operator to value_type.
//*************************************************************************
operator value_type () const
inline uint32_t final(uint32_t hash) const
{
return hash;
}
private:
value_type hash;
static const uint32_t OFFSET_BASIS = 0x811C9DC5;
static const uint32_t PRIME = 0x01000193;
};
@ -333,18 +256,16 @@ namespace etl
/// Calculates the fnv_1a_32 hash.
///\ingroup fnv_1a_32
//***************************************************************************
class fnv_1a_32
class fnv_1a_32 : public etl::frame_check_sequence<fnv_1a_policy_32>
{
public:
typedef uint32_t value_type;
//*************************************************************************
/// Default constructor.
//*************************************************************************
fnv_1a_32()
{
reset();
this->reset();
}
//*************************************************************************
@ -355,72 +276,9 @@ namespace etl
template<typename TIterator>
fnv_1a_32(TIterator begin, const TIterator end)
{
STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Type not supported");
reset();
while (begin != end)
{
hash ^= *begin++;
hash *= PRIME;
}
this->reset();
this->add(begin, end);
}
//*************************************************************************
/// Resets the CRC to the initial state.
//*************************************************************************
void reset()
{
hash = OFFSET_BASIS;
}
//*************************************************************************
/// Adds a range.
/// \param begin
/// \param end
//*************************************************************************
template<typename TIterator>
void add(TIterator begin, const TIterator end)
{
STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Type not supported");
while (begin != end)
{
hash ^= *begin++;
hash *= PRIME;
}
}
//*************************************************************************
/// \param value The char to add to the fnv_1a_32.
//*************************************************************************
void add(uint8_t value)
{
hash ^= value;
hash *= PRIME;
}
//*************************************************************************
/// Gets the fnv_1a_32 value.
//*************************************************************************
value_type value() const
{
return hash;
}
//*************************************************************************
/// Conversion operator to value_type.
//*************************************************************************
operator value_type () const
{
return hash;
}
private:
value_type hash;
static const uint32_t OFFSET_BASIS = 0x811C9DC5;
static const uint32_t PRIME = 0x01000193;
};
}

View File

@ -29,10 +29,13 @@ SOFTWARE.
#include <stdint.h>
#include "platform.h"
#include "static_assert.h"
#include "type_traits.h"
#include "binary.h"
STATIC_ASSERT(ETL_8BIT_SUPPORT, "This file does not currently support targets with no 8bit type");
///\defgroup frame_check_sequence Frame check sequence calculation
///\ingroup maths
@ -50,9 +53,9 @@ namespace etl
typedef TPolicy policy_type;
typedef typename policy_type::value_type value_type;
STATIC_ASSERT(etl::is_unsigned<value_type>::value, "Signed frame check type not supported");
//*************************************************************************
/// Default constructor.
//*************************************************************************
@ -110,7 +113,7 @@ namespace etl
//*************************************************************************
/// Gets the FCS value.
//*************************************************************************
value_type value() const
value_type value()
{
return policy.final(frame_check);
}
@ -118,7 +121,7 @@ namespace etl
//*************************************************************************
/// Conversion operator to value_type.
//*************************************************************************
operator value_type () const
operator value_type ()
{
return policy.final(frame_check);
}

View File

@ -200,8 +200,8 @@ namespace etl
/// Constructor.
///\param p_function Pointer to the function.
//*************************************************************************
function(void(*p_function)(void))
: p_function(p_function)
function(void(*p_function_)(void))
: p_function(p_function_)
{
}

View File

@ -32,6 +32,7 @@ SOFTWARE.
#define __ETL_HASH__
#include <stdint.h>
#include <stdlib.h>
// The default hash calculation.
#include "fnv_1.h"
@ -49,9 +50,9 @@ namespace etl
/// Hash to use when size_t is 16 bits.
/// T is always expected to be size_t.
//*************************************************************************
template <typename T>
template <typename T = size_t>
typename enable_if<sizeof(T) == sizeof(uint16_t), size_t>::type
generic_hash(uint8_t* begin, uint8_t* end)
generic_hash(const uint8_t* begin, const uint8_t* end)
{
uint32_t h = fnv_1a_32(begin, end);
@ -62,9 +63,9 @@ namespace etl
/// Hash to use when size_t is 32 bits.
/// T is always expected to be size_t.
//*************************************************************************
template <typename T>
template <typename T = size_t>
typename enable_if<sizeof(T) == sizeof(uint32_t), size_t>::type
generic_hash(uint8_t* begin, uint8_t* end)
generic_hash(const uint8_t* begin, const uint8_t* end)
{
return fnv_1a_32(begin, end);
}
@ -73,9 +74,9 @@ namespace etl
/// Hash to use when size_t is 64 bits.
/// T is always expected to be size_t.
//*************************************************************************
template <typename T>
template <typename T = size_t>
typename enable_if<sizeof(T) == sizeof(uint64_t), size_t>::type
generic_hash(uint8_t* begin, uint8_t* end)
generic_hash(const uint8_t* begin, const uint8_t* end)
{
return fnv_1a_64(begin, end);
}
@ -229,9 +230,9 @@ namespace etl
template<>
struct hash<long>
{
// If it fits into a size_t.
size_t operator ()(long v) const
{
// If it's the same size as a size_t.
if (sizeof(size_t) >= sizeof(v))
{
return static_cast<size_t>(v);
@ -251,9 +252,9 @@ namespace etl
template<>
struct hash<long long>
{
// If it fits into a size_t.
size_t operator ()(long long v) const
{
// If it's the same size as a size_t.
if (sizeof(size_t) >= sizeof(v))
{
return static_cast<size_t>(v);
@ -273,9 +274,9 @@ namespace etl
template<>
struct hash<unsigned long>
{
// If it fits into a size_t.
size_t operator ()(unsigned long v) const
{
// If it's the same size as a size_t.
if (sizeof(size_t) >= sizeof(v))
{
return static_cast<size_t>(v);
@ -295,9 +296,9 @@ namespace etl
template<>
struct hash<unsigned long long>
{
// If it fits into a size_t.
size_t operator ()(unsigned long long v) const
{
// If it's the same size as a size_t.
if (sizeof(size_t) >= sizeof(v))
{
return static_cast<size_t>(v);
@ -317,12 +318,20 @@ namespace etl
template<>
struct hash<float>
{
// If it's the same size as a size_t.
size_t operator ()(float v) const
{
// If it's the same size as a size_t.
if (sizeof(size_t) == sizeof(v))
{
return *reinterpret_cast<size_t*>(&v);
union
{
size_t s;
float v;
} u;
u.v = v;
return u.s;
}
else
{
@ -339,12 +348,20 @@ namespace etl
template<>
struct hash<double>
{
// If it's the same size as a size_t.
size_t operator ()(double v) const
{
// If it's the same size as a size_t.
if (sizeof(size_t) == sizeof(v))
{
return *reinterpret_cast<size_t*>(&v);
union
{
size_t s;
double v;
} u;
u.v = v;
return u.s;
}
else
{
@ -361,12 +378,20 @@ namespace etl
template<>
struct hash<long double>
{
// If it's the same size as a size_t.
size_t operator ()(long double v) const
{
// If it's the same size as a size_t.
if (sizeof(size_t) == sizeof(v))
{
return *reinterpret_cast<size_t*>(&v);
union
{
size_t s;
long double v;
} u;
u.v = v;
return u.s;
}
else
{
@ -385,9 +410,18 @@ namespace etl
{
size_t operator ()(const T* v) const
{
// If it's the same size as a size_t.
if (sizeof(size_t) == sizeof(T*))
{
return reinterpret_cast<size_t>(v);
union
{
size_t s;
const T* v;
} u;
u.v = v;
return u.s;
}
else
{

View File

@ -36,7 +36,7 @@ SOFTWARE.
#include <algorithm>
#include <functional>
#include <stddef.h>
#include <cstring>
#include <string.h>
#include "private/string_base.h"
#include "platform.h"
@ -148,7 +148,7 @@ namespace etl
//*********************************************************************
reverse_iterator rbegin()
{
return reverse_iterator(end());
return reverse_iterator(end());
}
//*********************************************************************
@ -157,7 +157,7 @@ namespace etl
//*********************************************************************
const_reverse_iterator rbegin() const
{
return const_reverse_iterator(end());
return const_reverse_iterator(end());
}
//*********************************************************************
@ -184,7 +184,7 @@ namespace etl
//*********************************************************************
const_reverse_iterator crbegin() const
{
return const_reverse_iterator(cend());
return const_reverse_iterator(cend());
}
//*********************************************************************
@ -193,7 +193,7 @@ namespace etl
//*********************************************************************
const_reverse_iterator crend() const
{
return const_reverse_iterator(cbegin());
return const_reverse_iterator(cbegin());
}
//*********************************************************************
@ -400,7 +400,7 @@ namespace etl
template <typename TIterator>
void assign(TIterator first, TIterator last)
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
difference_type count = std::distance(first, last);
ETL_ASSERT(count >= 0, ETL_ERROR(string_iterator));
#endif
@ -464,10 +464,11 @@ namespace etl
//*************************************************************************
void pop_back()
{
if (current_size > 0)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!empty(), ETL_ERROR(string_empty));
#endif
p_buffer[--current_size] = 0;
}
}
//*********************************************************************
@ -892,7 +893,7 @@ namespace etl
//*********************************************************************
size_t find(const_pointer s, size_t pos = 0) const
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
if ((pos + etl::strlen(s)) > size())
{
return npos;
@ -919,7 +920,7 @@ namespace etl
//*********************************************************************
size_t find(const_pointer s, size_t pos, size_t n) const
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
if ((pos + etl::strlen(s) - n) > size())
{
return npos;

View File

@ -85,7 +85,7 @@ namespace etl
// The type used for each element in the array.
#if !defined(ETL_BITSET_ELEMENT_TYPE)
typedef uint8_t element_t;
typedef uint_least8_t element_t;
#else
typedef ETL_BITSET_ELEMENT_TYPE element_t;
#endif

View File

@ -295,7 +295,7 @@ namespace etl
//***************************************************
const_iterator& operator ++()
{
index = (index == p_deque->BUFFER_SIZE - 1) ? 0 : index + 1;
index = (static_cast<size_t>(index) == p_deque->BUFFER_SIZE - 1) ? 0 : index + 1;
return *this;
}
@ -331,7 +331,7 @@ namespace etl
if (offset > 0)
{
index -= offset;
index = (index < 0) ? index + p_deque->BUFFER_SIZE : index;
index = (index < 0) ? static_cast<size_t>(index) + p_deque->BUFFER_SIZE : index;
}
else if (offset < 0)
{

View File

@ -271,7 +271,7 @@ namespace etl
template <typename TIterator>
void assign(TIterator first, TIterator last)
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
difference_type count = std::distance(first, last);
ETL_ASSERT(count <= difference_type(capacity()), ETL_ERROR(flat_map_full));
#endif

View File

@ -222,7 +222,7 @@ namespace etl
template <typename TIterator>
void assign(TIterator first, TIterator last)
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
difference_type count = std::distance(first, last);
ETL_ASSERT(count <= difference_type(capacity()), ETL_ERROR(flat_multimap_full));
#endif

View File

@ -198,7 +198,7 @@ namespace etl
template <typename TIterator>
void assign(TIterator first, TIterator last)
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
difference_type count = std::distance(first, last);
ETL_ASSERT(count <= difference_type(capacity()), ETL_ERROR(flat_multiset_full));
#endif

View File

@ -198,7 +198,7 @@ namespace etl
template <typename TIterator>
void assign(TIterator first, TIterator last)
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
difference_type count = std::distance(first, last);
ETL_ASSERT(count <= difference_type(capacity()), ETL_ERROR(flat_set_full));
#endif

View File

@ -354,7 +354,7 @@ namespace etl
template <typename TIterator>
void assign(TIterator first, TIterator last)
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
difference_type count = std::distance(first, last);
ETL_ASSERT(count >= 0, ETL_ERROR(forward_list_iterator));
#endif
@ -512,7 +512,7 @@ namespace etl
template <typename TIterator>
void insert_after(iterator position, TIterator first, TIterator last)
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
difference_type count = std::distance(first, last);
ETL_ASSERT((count + current_size) <= MAX_SIZE, ETL_ERROR(forward_list_full));
#endif
@ -609,7 +609,7 @@ namespace etl
return; // Can't more to before yourself!
}
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
// Check that we are not doing an illegal move!
for (const_iterator item = first_before; item != last; ++item)
{

View File

@ -452,7 +452,7 @@ namespace etl
template <typename TIterator>
void assign(TIterator first, TIterator last)
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
difference_type count = std::distance(first, last);
ETL_ASSERT(count >= 0, ETL_ERROR(list_iterator));
ETL_ASSERT(size_t(count) <= MAX_SIZE, ETL_ERROR(list_full));
@ -475,7 +475,7 @@ namespace etl
//*************************************************************************
void assign(size_t n, parameter_t value)
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
ETL_ASSERT(n <= MAX_SIZE, ETL_ERROR(list_full));
#endif
@ -1062,7 +1062,7 @@ namespace etl
return; // Can't more to before yourself!
}
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
// Check that we are not doing an illegal move!
for (const_iterator item = first; item != last; ++item)
{

View File

@ -675,7 +675,7 @@ namespace etl
///\param position The position that would precede the value to insert.
///\param value The value to insert.
//*********************************************************************
iterator insert(iterator position, const value_type& value)
iterator insert(iterator /*position*/, const value_type& value)
{
// Ignore position provided and just do a normal insert
return insert(value);
@ -687,7 +687,7 @@ namespace etl
///\param position The position that would precede the value to insert.
///\param value The value to insert.
//*********************************************************************
iterator insert(const_iterator position, const value_type& value)
iterator insert(const_iterator /*position*/, const value_type& value)
{
// Ignore position provided and just do a normal insert
return insert(value);

View File

@ -656,7 +656,7 @@ namespace etl
///\param position The position that would precede the value to insert.
///\param value The value to insert.
//*********************************************************************
iterator insert(iterator position, const value_type& value)
iterator insert(iterator /*position*/, const value_type& value)
{
// Ignore position provided and just do a normal insert
return insert(value);
@ -668,7 +668,7 @@ namespace etl
///\param position The position that would precede the value to insert.
///\param value The value to insert.
//*********************************************************************
iterator insert(const_iterator position, const value_type& value)
iterator insert(const_iterator /*position*/, const value_type& value)
{
// Ignore position provided and just do a normal insert
return insert(value);

View File

@ -145,13 +145,6 @@ namespace etl
typedef const value_type& const_reference;
typedef size_t size_type;
enum
{
// The count option is based on the type of link.
COUNT_OPTION = ((TLink::OPTION == etl::link_option::AUTO) ||
(TLink::OPTION == etl::link_option::CHECKED)) ? etl::count_option::SLOW_COUNT : etl::count_option::FAST_COUNT
};
typedef intrusive_forward_list<TValue, TLink> list_type;
//*************************************************************************
@ -324,7 +317,7 @@ namespace etl
const value_type* p_value;
};
typedef typename std::iterator_traits<iterator>::difference_type difference_type;
typedef typename std::iterator_traits<iterator>::difference_type difference_type;
//*************************************************************************
/// Constructor.
@ -334,6 +327,14 @@ namespace etl
initialise();
}
//*************************************************************************
/// Destructor.
//*************************************************************************
~intrusive_forward_list()
{
clear();
}
//*************************************************************************
/// Constructor from range
//*************************************************************************
@ -438,7 +439,7 @@ namespace etl
template <typename TIterator>
void assign(TIterator first, TIterator last)
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
difference_type count = std::distance(first, last);
ETL_ASSERT(count >= 0, ETL_ERROR(intrusive_forward_list_iterator_exception));
#endif
@ -503,33 +504,21 @@ namespace etl
//*************************************************************************
/// Inserts a value to the intrusive_forward_list after the specified position.
/// Checks that the value is unlinked if CHECKED.
//*************************************************************************
iterator insert_after(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_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 if CHECKED.
//*************************************************************************
template <typename TIterator>
void insert_after(iterator position, TIterator first, TIterator last)
{
while (first != last)
{
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++);
++position;
@ -544,13 +533,10 @@ namespace etl
{
iterator next(position);
++next;
++next;
remove_link_after(*position.p_value);
if (TLink::OPTION == etl::link_option::CHECKED)
if (next != end())
{
position.p_value->TLink::clear();
++next;
remove_link_after(*position.p_value);
}
return next;
@ -577,14 +563,8 @@ namespace etl
// One less.
--current_size;
p_next = p_first->etl_next; // Remember the next link.
if (TLink::OPTION == etl::link_option::CHECKED)
{
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 = p_next; // Move to the next link.
}
if (p_next == nullptr)
@ -657,7 +637,7 @@ namespace etl
if (is_trivial_list())
{
return;
return;
}
while (true)
@ -696,32 +676,32 @@ namespace etl
// Decide whether the next link of merge comes from left or right.
if (left_size == 0)
{
// Left is empty. The link must come from right.
i_link = i_right;
// Left is empty. The link must come from right.
i_link = i_right;
++i_right;
--right_size;
}
}
else if (right_size == 0 || i_right == end())
{
// Right is empty. The link must come from left.
i_link = i_left;
// Right is empty. The link must come from left.
i_link = i_left;
++i_left;
--left_size;
}
}
else if (compare(*i_left, *i_right))
{
// First link of left is lower or same. The link must come from left.
i_link = i_left;
// First link of left is lower or same. The link must come from left.
i_link = i_left;
++i_left;
--left_size;
}
}
else
{
// First link of right is lower. The link must come from right.
i_link = i_right;
// First link of right is lower. The link must come from right.
i_link = i_right;
++i_right;
--right_size;
}
}
// Add the next link to the merged head.
if (i_head == before_begin())
@ -812,34 +792,24 @@ namespace etl
//*************************************************************************
size_t size() const
{
if (COUNT_OPTION == etl::count_option::SLOW_COUNT)
{
return std::distance(cbegin(), cend());
}
else
{
return current_size.get_count();
}
return current_size;
}
//*************************************************************************
/// Splice another list into this one.
//*************************************************************************
void splice_after(iterator position, etl::intrusive_forward_list<TValue, TLink>& list)
void splice_after(iterator position, etl::intrusive_forward_list<TValue, TLink>& other)
{
// No point splicing to ourself!
if (&list != this)
if (&other != this)
{
if (!list.empty())
if (!other.empty())
{
link_type& first = list.get_head();
link_type& first = other.get_head();
if (COUNT_OPTION == etl::count_option::FAST_COUNT)
if (&other != this)
{
if (&list != this)
{
current_size += list.size();
}
current_size += other.size();
}
link_type& before = *position.p_value;
@ -855,7 +825,7 @@ namespace etl
etl::link<link_type>(last, after);
list.clear();
other.initialise();
}
}
}
@ -863,38 +833,32 @@ namespace etl
//*************************************************************************
/// Splice an element from another list into this one.
//*************************************************************************
void splice(iterator position, etl::intrusive_forward_list<TValue, TLink>& list, iterator isource)
void splice(iterator position, etl::intrusive_forward_list<TValue, TLink>& other, iterator isource)
{
link_type& before = *position.p_value;
etl::unlink<link_type>(*isource.p_value);
etl::link_splice<link_type>(before, *isource.p_value);
if (COUNT_OPTION == etl::count_option::FAST_COUNT)
if (&other != this)
{
if (&list != this)
{
++current_size;
--list.current_size;
}
++current_size;
--other.current_size;
}
}
//*************************************************************************
/// Splice a range of elements from another list into this one.
//*************************************************************************
void splice_after(iterator position, etl::intrusive_forward_list<TValue, TLink>& list, iterator begin_, iterator end_)
void splice_after(iterator position, etl::intrusive_forward_list<TValue, TLink>& other, iterator begin_, iterator end_)
{
if (!list.empty())
if (!other.empty())
{
if (COUNT_OPTION == etl::count_option::FAST_COUNT)
if (&other != this)
{
if (&list != this)
{
size_t n = std::distance(begin_, end_) - 1;
current_size += n;
list.current_size -= n;
}
size_t n = std::distance(begin_, end_) - 1;
current_size += n;
other.current_size -= n;
}
link_type* first = begin_.p_value;
@ -919,25 +883,25 @@ namespace etl
//*************************************************************************
/// Merge another list into this one. Both lists should be sorted.
//*************************************************************************
void merge(list_type& list)
void merge(list_type& other)
{
merge(list, std::less<value_type>());
merge(other, std::less<value_type>());
}
//*************************************************************************
/// Merge another list into this one. Both lists should be sorted.
//*************************************************************************
template <typename TCompare>
void merge(list_type& list, TCompare compare)
void merge(list_type& other, TCompare compare)
{
if (!list.empty())
if (!other.empty())
{
#if _DEBUG
ETL_ASSERT(etl::is_sorted(list.begin(), list.end(), compare), ETL_ERROR(intrusive_forward_list_unsorted));
ETL_ASSERT(etl::is_sorted(other.begin(), other.end(), compare), ETL_ERROR(intrusive_forward_list_unsorted));
ETL_ASSERT(etl::is_sorted(begin(), end(), compare), ETL_ERROR(intrusive_forward_list_unsorted));
#endif
value_type* other_begin = static_cast<value_type*>(&list.get_head());
value_type* other_begin = static_cast<value_type*>(&other.get_head());
value_type* other_terminal = nullptr;
value_type* before = static_cast<value_type*>(&start_link);
@ -978,12 +942,9 @@ namespace etl
}
}
if (COUNT_OPTION == etl::count_option::FAST_COUNT)
{
current_size += list.size();
}
current_size += other.size();
list.clear();
other.initialise();
}
}
@ -991,105 +952,7 @@ namespace etl
link_type start_link; ///< The link that acts as the intrusive_forward_list start.
//*************************************************************************
/// Counter type based on count option.
//*************************************************************************
template <const size_t OPTION, bool dummy = true>
class counter_type
{
};
//*************************************************************************
/// Slow type.
//*************************************************************************
template <bool dummy>
class counter_type<etl::count_option::SLOW_COUNT, dummy>
{
public:
counter_type& operator ++()
{
return *this;
}
counter_type& operator --()
{
return *this;
}
counter_type& operator =(size_t new_count)
{
return *this;
}
counter_type& operator +=(size_t diff)
{
return *this;
}
counter_type& operator -=(size_t diff)
{
return *this;
}
size_t get_count() const
{
return 0;
}
};
//*************************************************************************
/// Fast type.
//*************************************************************************
template <bool dummy>
class counter_type<etl::count_option::FAST_COUNT, dummy>
{
public:
counter_type()
: count(0)
{
}
counter_type& operator ++()
{
++count;
return *this;
}
counter_type& operator --()
{
--count;
return *this;
}
counter_type& operator =(size_t new_count)
{
count = new_count;
return *this;
}
counter_type& operator +=(size_t diff)
{
count += diff;
return *this;
}
counter_type& operator -=(size_t diff)
{
count -= diff;
return *this;
}
size_t get_count() const
{
return count;
}
size_t count;
};
counter_type<COUNT_OPTION> current_size; ///< Counts the number of elements in the list.
size_t current_size; ///< Counts the number of elements in the list.
//*************************************************************************
/// Is the intrusive_forward_list a trivial length?
@ -1114,7 +977,9 @@ namespace etl
//*************************************************************************
void remove_link_after(link_type& link)
{
if (link.etl_next != nullptr)
link_type* p_next = link.etl_next;
if (p_next != nullptr)
{
etl::unlink_after<link_type>(link);
--current_size;

View File

@ -55,25 +55,6 @@ SOFTWARE.
namespace etl
{
namespace link_option
{
enum
{
DEFAULT,
AUTO,
CHECKED
};
}
namespace count_option
{
enum
{
SLOW_COUNT,
FAST_COUNT
};
}
//***************************************************************************
/// Link exception.
//***************************************************************************
@ -100,18 +81,15 @@ namespace etl
}
};
namespace __private_intrusive_links__
//***************************************************************************
/// A forward link.
//***************************************************************************
template <const size_t ID_>
struct forward_link
{
//***************************************************************************
/// A forward link base.
//***************************************************************************
template <typename TLink, const size_t ID_, const size_t OPTION_>
struct forward_link_base
{
enum
{
ID = ID_,
OPTION = OPTION_
};
void clear()
@ -124,55 +102,12 @@ namespace etl
return etl_next != nullptr;
}
TLink* etl_next;
};
}
//***************************************************************************
/// A forward link.
//***************************************************************************
template <const size_t ID_, const size_t OPTION_ = etl::link_option::DEFAULT>
struct forward_link
: public __private_intrusive_links__::forward_link_base<forward_link<ID_, OPTION_>, ID_, OPTION_>
{
};
//******************************************************************
// There is no valid specialisation for auto link
//******************************************************************
template <const size_t ID_>
struct forward_link<ID_, etl::link_option::AUTO>
: public __private_intrusive_links__::forward_link_base<forward_link<ID_, etl::link_option::AUTO>, ID_, etl::link_option::AUTO>
{
forward_link()
{
this->clear();
}
};
//******************************************************************
// Specialisation for checked unlink option.
// An error will be generated if the links are valid when the object
// is destroyed.
//******************************************************************
template <const size_t ID_>
struct forward_link<ID_, etl::link_option::CHECKED>
: public __private_intrusive_links__::forward_link_base<forward_link<ID_, etl::link_option::CHECKED>, ID_, etl::link_option::CHECKED>
{
forward_link()
{
this->clear();
}
~forward_link()
{
assert(this->etl_next != nullptr);
}
forward_link* etl_next;
};
// Reference, Reference
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID> >::value, void>::type
link(TLink& lhs, TLink& rhs)
{
lhs.etl_next = &rhs;
@ -180,7 +115,7 @@ namespace etl
// Reference, Reference
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID> >::value, void>::type
link_splice(TLink& lhs, TLink& rhs)
{
rhs.etl_next = lhs.etl_next;
@ -189,7 +124,7 @@ namespace etl
// Pointer, Pointer
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID> >::value, void>::type
link(TLink* lhs, TLink* rhs)
{
if (lhs != nullptr)
@ -200,7 +135,7 @@ namespace etl
// Pointer, Pointer
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID> >::value, void>::type
link_splice(TLink* lhs, TLink* rhs)
{
if (lhs != nullptr)
@ -216,7 +151,7 @@ namespace etl
// Reference, Pointer
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID> >::value, void>::type
link(TLink& lhs, TLink* rhs)
{
lhs.etl_next = rhs;
@ -224,7 +159,7 @@ namespace etl
// Reference, Pointer
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID> >::value, void>::type
link_splice(TLink& lhs, TLink* rhs)
{
if (rhs != nullptr)
@ -237,7 +172,7 @@ namespace etl
// Pointer, Reference
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID> >::value, void>::type
link(TLink* lhs, TLink& rhs)
{
if (lhs != nullptr)
@ -248,7 +183,7 @@ namespace etl
// Pointer, Reference
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID> >::value, void>::type
link_splice(TLink* lhs, TLink& rhs)
{
if (lhs != nullptr)
@ -260,7 +195,7 @@ namespace etl
// Reference, Reference, Reference
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID> >::value, void>::type
link_splice(TLink& lhs, TLink& first, TLink& last)
{
last.etl_next = lhs.etl_next;
@ -269,7 +204,7 @@ namespace etl
// Pointer, Reference, Reference
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID> >::value, void>::type
link_splice(TLink* lhs, TLink& first, TLink& last)
{
if (lhs != nullptr)
@ -285,48 +220,33 @@ namespace etl
// Reference
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID> >::value, void>::type
unlink_after(TLink& node)
{
if (node.etl_next != nullptr)
{
TLink* unlinked_node = node.etl_next;
node.etl_next = unlinked_node->etl_next;
if ((int(TLink::OPTION) == etl::link_option::AUTO) ||
(int(TLink::OPTION) == etl::link_option::CHECKED))
{
unlinked_node->clear();
}
}
}
// Reference, Reference
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::forward_link<TLink::ID> >::value, void>::type
unlink_after(TLink& before, TLink& last)
{
before.etl_next = last.etl_next;
if ((int(TLink::OPTION) == etl::link_option::AUTO) ||
(int(TLink::OPTION) == etl::link_option::CHECKED))
{
last.clear();
}
}
namespace __private_intrusive_links__
//***************************************************************************
/// A bidirectional link.
//***************************************************************************
template <const size_t ID_>
struct bidirectional_link
{
//***************************************************************************
/// A bidirectional link base.
//***************************************************************************
template <typename TLink, const size_t ID_, const size_t OPTION_>
struct bidirectional_link_base
{
enum
{
ID = ID_,
OPTION = OPTION_
ID = ID_,
};
void clear()
@ -345,13 +265,11 @@ namespace etl
std::swap(etl_previous, etl_next);
}
TLink* etl_previous;
TLink* etl_next;
bidirectional_link* etl_previous;
bidirectional_link* etl_next;
protected:
void base_unlink()
{
void unlink()
{
// Connect the previous link with the next.
if (etl_previous != nullptr)
{
@ -363,78 +281,12 @@ namespace etl
{
etl_next->etl_previous = etl_previous;
}
}
};
}
//***************************************************************************
/// A bidirectional link.
//***************************************************************************
template <const size_t ID_, const size_t OPTION_ = etl::link_option::DEFAULT>
struct bidirectional_link
: public __private_intrusive_links__::bidirectional_link_base<bidirectional_link<ID_, OPTION_>, ID_, OPTION_>
{
void unlink()
{
this->base_unlink();
}
};
//******************************************************************
// Specialisation for auto unlinked option.
// When this link is destroyed it will automatically unlink itself.
//******************************************************************
template <const size_t ID_>
struct bidirectional_link<ID_, etl::link_option::AUTO>
: public __private_intrusive_links__::bidirectional_link_base<bidirectional_link<ID_, etl::link_option::AUTO>, ID_, etl::link_option::AUTO>
{
bidirectional_link()
{
this->clear();
}
~bidirectional_link()
{
this->base_unlink();
}
void unlink()
{
this->base_unlink();
this->clear();
}
};
//******************************************************************
// Specialisation for checked unlink option.
// An error will be generated if the links are valid when the object
// is destroyed.
//******************************************************************
template <const size_t ID_>
struct bidirectional_link<ID_, etl::link_option::CHECKED>
: public __private_intrusive_links__::bidirectional_link_base<bidirectional_link<ID_, etl::link_option::CHECKED>, ID_, etl::link_option::CHECKED>
{
bidirectional_link()
{
this->clear();
}
~bidirectional_link()
{
assert(this->etl_previous == nullptr);
assert(this->etl_next == nullptr);
}
void unlink()
{
this->base_unlink();
this->clear();
}
};
// Reference, Reference
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID> >::value, void>::type
link(TLink& lhs, TLink& rhs)
{
lhs.etl_next = &rhs;
@ -443,7 +295,7 @@ namespace etl
// Reference, Reference
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID> >::value, void>::type
link_splice(TLink& lhs, TLink& rhs)
{
rhs.etl_next = lhs.etl_next;
@ -459,7 +311,7 @@ namespace etl
// Pointer, Pointer
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID> >::value, void>::type
link(TLink* lhs, TLink* rhs)
{
if (lhs != nullptr)
@ -475,7 +327,7 @@ namespace etl
// Pointer, Pointer
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID> >::value, void>::type
link_splice(TLink* lhs, TLink* rhs)
{
if (rhs != nullptr)
@ -501,7 +353,7 @@ namespace etl
// Reference, Pointer
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID> >::value, void>::type
link(TLink& lhs, TLink* rhs)
{
lhs.etl_next = rhs;
@ -514,7 +366,7 @@ namespace etl
// Reference, Pointer
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID> >::value, void>::type
link_splice(TLink& lhs, TLink* rhs)
{
if (rhs != nullptr)
@ -533,7 +385,7 @@ namespace etl
// Pointer, Reference
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID> >::value, void>::type
link(TLink* lhs, TLink& rhs)
{
if (lhs != nullptr)
@ -546,7 +398,7 @@ namespace etl
// Pointer, Reference
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID> >::value, void>::type
link_splice(TLink* lhs, TLink& rhs)
{
if (lhs != nullptr)
@ -569,7 +421,7 @@ namespace etl
// Reference, Reference, Reference
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID> >::value, void>::type
link_splice(TLink& lhs, TLink& first, TLink& last)
{
last.etl_next = lhs.etl_next;
@ -585,7 +437,7 @@ namespace etl
// Pointer, Reference, Reference
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID> >::value, void>::type
link_splice(TLink* lhs, TLink& first, TLink& last)
{
if (lhs != nullptr)
@ -612,7 +464,7 @@ namespace etl
// Reference
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID> >::value, void>::type
unlink(TLink& node)
{
node.unlink();
@ -620,7 +472,7 @@ namespace etl
// Reference Reference
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::bidirectional_link<TLink::ID> >::value, void>::type
unlink(TLink& first, TLink& last)
{
if (&first == &last)
@ -638,28 +490,18 @@ namespace etl
{
first.etl_previous->etl_next = last.etl_next;
}
if ((TLink::OPTION == etl::link_option::AUTO) ||
(int(TLink::OPTION) == etl::link_option::CHECKED))
{
first.etl_previous = nullptr;
last.etl_next = nullptr;
}
}
}
namespace __private_intrusive_links__
//***************************************************************************
/// A binary tree link.
//***************************************************************************
template <const size_t ID_>
struct tree_link
{
//***************************************************************************
/// A tree link base.
//***************************************************************************
template <typename TLink, const size_t ID_, const size_t OPTION_>
struct tree_link_base
{
enum
{
ID = ID_,
OPTION = OPTION_
ID = ID_,
};
void clear()
@ -674,59 +516,14 @@ namespace etl
return (etl_parent != nullptr) || (etl_left != nullptr) || (etl_right != nullptr);
}
TLink* etl_parent;
TLink* etl_left;
TLink* etl_right;
};
}
//***************************************************************************
/// A tree link.
//***************************************************************************
template <const size_t ID_, const size_t OPTION_ = etl::link_option::DEFAULT>
struct tree_link
: public __private_intrusive_links__::tree_link_base<tree_link<ID_, OPTION_>, ID_, OPTION_>
{
};
//******************************************************************
// There is no valid specialisation for auto link
//******************************************************************
template <const size_t ID_>
struct tree_link<ID_, etl::link_option::AUTO>
: public __private_intrusive_links__::tree_link_base<tree_link<ID_, etl::link_option::AUTO>, ID_, etl::link_option::AUTO>
{
tree_link()
{
this->clear();
}
};
//******************************************************************
// Specialisation for checked unlink option.
// An error will be generated if the links are valid when the object
// is destroyed.
//******************************************************************
template <const size_t ID_>
struct tree_link<ID_, etl::link_option::CHECKED>
: public __private_intrusive_links__::tree_link_base<tree_link<ID_, etl::link_option::CHECKED>, ID_, etl::link_option::CHECKED>
{
tree_link()
{
this->clear();
}
~tree_link()
{
assert(this->etl_parent != nullptr);
assert(this->etl_left != nullptr);
assert(this->etl_right != nullptr);
}
tree_link* etl_parent;
tree_link* etl_left;
tree_link* etl_right;
};
// Reference, Reference
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID> >::value, void>::type
link_left(TLink& parent, TLink& leaf)
{
parent.etl_left = &leaf;
@ -734,7 +531,7 @@ namespace etl
}
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID> >::value, void>::type
link_right(TLink& parent, TLink& leaf)
{
parent.etl_right = &leaf;
@ -743,7 +540,7 @@ namespace etl
// Pointer, Pointer
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID> >::value, void>::type
link_left(TLink* parent, TLink* leaf)
{
if (parent != nullptr)
@ -758,7 +555,7 @@ namespace etl
}
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID> >::value, void>::type
link_right(TLink* parent, TLink* leaf)
{
if (parent != nullptr)
@ -774,7 +571,7 @@ namespace etl
// Reference, Pointer
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID> >::value, void>::type
link_left(TLink& parent, TLink* leaf)
{
parent.etl_left = leaf;
@ -786,7 +583,7 @@ namespace etl
}
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID> >::value, void>::type
link_right(TLink& parent, TLink* leaf)
{
parent.etl_right = leaf;
@ -799,7 +596,7 @@ namespace etl
// Pointer, Reference
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID> >::value, void>::type
link_left(TLink* parent, TLink& leaf)
{
if (parent != nullptr)
@ -811,7 +608,7 @@ namespace etl
}
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID, TLink::OPTION> >::value, void>::type
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID> >::value, void>::type
link_right(TLink* parent, TLink& leaf)
{
if (parent != nullptr)
@ -821,6 +618,175 @@ namespace etl
leaf.etl_parent = parent;
}
// Reference, Reference
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID> >::value, void>::type
link_rotate_left(TLink& parent, TLink& leaf)
{
parent.etl_right = leaf.etl_left;
if (parent.etl_right != nullptr)
{
parent.etl_right->etl_parent = &parent;
}
leaf.etl_parent = parent.etl_parent;
parent.etl_parent = &leaf;
leaf.etl_left = &parent;
}
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID> >::value, void>::type
link_rotate_right(TLink& parent, TLink& leaf)
{
parent.etl_left = leaf.etl_right;
if (parent.etl_left != nullptr)
{
parent.etl_left->etl_parent = &parent;
}
leaf.etl_parent = parent.etl_parent;
parent.etl_parent = &leaf;
leaf.etl_right = &parent;
}
// Pointer, Pointer
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID> >::value, void>::type
link_rotate_left(TLink* parent, TLink* leaf)
{
if ((parent != nullptr) && (leaf != nullptr))
{
link_rotate_left(*parent, *leaf);
}
}
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID> >::value, void>::type
link_rotate_right(TLink* parent, TLink* leaf)
{
if ((parent != nullptr) && (leaf != nullptr))
{
link_rotate_right(*parent, *leaf);
}
}
// Reference, Pointer
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID> >::value, void>::type
link_rotate_left(TLink& parent, TLink* leaf)
{
if (leaf != nullptr)
{
link_rotate_left(parent, *leaf);
}
}
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID> >::value, void>::type
link_rotate_right(TLink& parent, TLink* leaf)
{
if (leaf != nullptr)
{
link_rotate_right(parent, *leaf);
}
}
// Pointer, Reference
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID> >::value, void>::type
link_rotate_left(TLink* parent, TLink& leaf)
{
if (parent != nullptr)
{
link_rotate_left(*parent, leaf);
}
}
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID> >::value, void>::type
link_rotate_right(TLink* parent, TLink& leaf)
{
if (parent != nullptr)
{
link_rotate_right(*parent, leaf);
}
}
// Reference, Reference
/// Automatically detects whether a left or right rotate is expected.
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID> >::value, void>::type
link_rotate(TLink& parent, TLink& leaf)
{
if (parent.etl_left == &leaf)
{
etl::link_rotate_right(parent, leaf);
}
else
{
etl::link_rotate_left(parent, leaf);
}
}
// Pointer, Pointer
/// Automatically detects whether a left or right rotate is expected.
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID> >::value, void>::type
link_rotate(TLink* parent, TLink* leaf)
{
if ((parent != nullptr) && (leaf != nullptr))
{
if (parent->etl_left == leaf)
{
etl::link_rotate_right(*parent, *leaf);
}
else
{
etl::link_rotate_left(*parent, *leaf);
}
}
}
// Reference, Pointer
/// Automatically detects whether a left or right rotate is expected.
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID> >::value, void>::type
link_rotate(TLink& parent, TLink* leaf)
{
if (leaf != nullptr)
{
if (parent.etl_left == leaf)
{
etl::link_rotate_right(parent, *leaf);
}
else
{
etl::link_rotate_left(parent, *leaf);
}
}
}
// Pointer, Reference
/// Automatically detects whether a left or right rotate is expected.
template <typename TLink>
typename etl::enable_if<etl::is_same<TLink, etl::tree_link<TLink::ID> >::value, void>::type
link_rotate(TLink* parent, TLink& leaf)
{
if (parent != nullptr)
{
if (parent->etl_left == &leaf)
{
etl::link_rotate_right(*parent, leaf);
}
else
{
etl::link_rotate_left(*parent, leaf);
}
}
}
}
#undef ETL_FILE

View File

@ -121,13 +121,6 @@ namespace etl
{
public:
enum
{
// The count option is based on the type of link.
COUNT_OPTION = ((TLink::OPTION == etl::link_option::AUTO) ||
(TLink::OPTION == etl::link_option::CHECKED)) ? etl::count_option::SLOW_COUNT : etl::count_option::FAST_COUNT
};
typedef intrusive_list<TValue, TLink> list_type;
// Node typedef.
@ -341,7 +334,7 @@ namespace etl
const value_type* p_value;
};
typedef typename std::iterator_traits<iterator>::difference_type difference_type;
typedef typename std::iterator_traits<iterator>::difference_type difference_type;
//*************************************************************************
/// Constructor.
@ -351,6 +344,14 @@ namespace etl
initialise();
}
//*************************************************************************
/// Destructor.
//*************************************************************************
~intrusive_list()
{
clear();
}
//*************************************************************************
/// Constructor from range
//*************************************************************************
@ -456,7 +457,7 @@ namespace etl
template <typename TIterator>
void assign(TIterator first, TIterator last)
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
difference_type count = std::distance(first, last);
ETL_ASSERT(count >= 0, ETL_ERROR(intrusive_list_iterator_exception));
#endif
@ -478,7 +479,7 @@ namespace etl
//*************************************************************************
/// Pushes a value to the front of the intrusive_list.
//*************************************************************************
void push_front(value_type& value)
void push_front(link_type& value)
{
insert_link(terminal_link, value);
}
@ -537,33 +538,21 @@ namespace etl
//*************************************************************************
/// Inserts a value to the intrusive_list before the specified position.
/// Checks that the value is unlinked if CHECKED
//*************************************************************************
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 range of values to the intrusive_list after the specified position.
/// Checks that the values are unlinked if CHECKED.
//*************************************************************************
template <typename TIterator>
void insert(iterator position, TIterator first, TIterator last)
{
while (first != last)
{
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++);
}
@ -594,27 +583,7 @@ namespace etl
// Join the ends.
etl::link<link_type>(p_first->etl_previous, p_last);
if (COUNT_OPTION == etl::count_option::FAST_COUNT)
{
current_size -= std::distance(first, last);
}
if ((TLink::OPTION == etl::link_option::AUTO) ||
(TLink::OPTION == etl::link_option::CHECKED))
{
// 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.
}
}
current_size -= std::distance(first, last);
if (p_last == &terminal_link)
{
@ -831,35 +800,25 @@ namespace etl
//*************************************************************************
size_t size() const
{
if (COUNT_OPTION == etl::count_option::SLOW_COUNT)
{
return std::distance(cbegin(), cend());
}
else
{
return current_size.get_count();
}
return current_size;
}
//*************************************************************************
/// Splice another list into this one.
//*************************************************************************
void splice(iterator position, list_type& list)
void splice(iterator position, list_type& other)
{
// No point splicing to ourself!
if (&list != this)
if (&other != this)
{
if (!list.empty())
if (!other.empty())
{
link_type& first = *list.get_head();
link_type& last = *list.get_tail();
link_type& first = *other.get_head();
link_type& last = *other.get_tail();
if (COUNT_OPTION == etl::count_option::FAST_COUNT)
if (&other != this)
{
if (&list != this)
{
current_size += list.size();
}
current_size += other.size();
}
link_type& after = *position.p_value;
@ -868,7 +827,7 @@ namespace etl
etl::link<link_type>(before, first);
etl::link<link_type>(last, after);
list.clear();
other.initialise();
}
}
}
@ -876,38 +835,32 @@ namespace etl
//*************************************************************************
/// Splice an element from another list into this one.
//*************************************************************************
void splice(iterator position, list_type& list, iterator isource)
void splice(iterator position, list_type& other, iterator isource)
{
link_type& before = *position.p_value->link_type::etl_previous;
etl::unlink<link_type>(*isource.p_value);
etl::link_splice<link_type>(before, *isource.p_value);
if (COUNT_OPTION == etl::count_option::FAST_COUNT)
if (&other != this)
{
if (&list != this)
{
++current_size;
--list.current_size;
}
++current_size;
--other.current_size;
}
}
//*************************************************************************
/// Splice a range of elements from another list into this one.
//*************************************************************************
void splice(iterator position, list_type& list, iterator begin_, iterator end_)
void splice(iterator position, list_type& other, iterator begin_, iterator end_)
{
if (!list.empty())
if (!other.empty())
{
if (COUNT_OPTION == etl::count_option::FAST_COUNT)
if (&other != this)
{
if (&list != this)
{
size_t n = std::distance(begin_, end_);
current_size += n;
list.current_size -= n;
}
size_t n = std::distance(begin_, end_);
current_size += n;
other.current_size -= n;
}
link_type& first = *begin_.p_value;
@ -926,26 +879,26 @@ namespace etl
//*************************************************************************
/// Merge another list into this one. Both lists should be sorted.
//*************************************************************************
void merge(list_type& list)
void merge(list_type& other)
{
merge(list, std::less<value_type>());
merge(other, std::less<value_type>());
}
//*************************************************************************
/// Merge another list into this one. Both lists should be sorted.
//*************************************************************************
template <typename TCompare>
void merge(list_type& list, TCompare compare)
void merge(list_type& other, TCompare compare)
{
if (!list.empty())
if (!other.empty())
{
#if _DEBUG
ETL_ASSERT(etl::is_sorted(list.begin(), list.end(), compare), ETL_ERROR(intrusive_list_unsorted));
ETL_ASSERT(etl::is_sorted(other.begin(), other.end(), compare), ETL_ERROR(intrusive_list_unsorted));
ETL_ASSERT(etl::is_sorted(begin(), end(), compare), ETL_ERROR(intrusive_list_unsorted));
#endif
value_type* other_begin = static_cast<value_type*>(list.get_head());
value_type* other_end = static_cast<value_type*>(&list.terminal_link);
value_type* other_begin = static_cast<value_type*>(other.get_head());
value_type* other_end = static_cast<value_type*>(&other.terminal_link);
value_type* begin = static_cast<value_type*>(get_head());
value_type* end = static_cast<value_type*>(&terminal_link);
@ -976,13 +929,9 @@ namespace etl
etl::link_splice<link_type>(*get_tail(), *other_begin, *other_end->link_type::etl_previous);
}
current_size += other.size();
if (COUNT_OPTION == etl::count_option::FAST_COUNT)
{
current_size += list.size();
}
list.clear();
other.initialise();
}
}
@ -991,105 +940,7 @@ namespace etl
/// The link that acts as the intrusive_list start & end.
link_type terminal_link;
//*************************************************************************
/// Counter type based on count option.
//*************************************************************************
template <const size_t OPTION, bool dummy = true>
class counter_type
{
};
//*************************************************************************
/// Slow type.
//*************************************************************************
template <bool dummy>
class counter_type<etl::count_option::SLOW_COUNT, dummy>
{
public:
counter_type& operator ++()
{
return *this;
}
counter_type& operator --()
{
return *this;
}
counter_type& operator =(size_t new_count)
{
return *this;
}
counter_type& operator +=(size_t diff)
{
return *this;
}
counter_type& operator -=(size_t diff)
{
return *this;
}
size_t get_count() const
{
return 0;
}
};
//*************************************************************************
/// Fast type.
//*************************************************************************
template <bool dummy>
class counter_type<etl::count_option::FAST_COUNT, dummy>
{
public:
counter_type()
: count(0)
{
}
counter_type& operator ++()
{
++count;
return *this;
}
counter_type& operator --()
{
--count;
return *this;
}
counter_type& operator =(size_t new_count)
{
count = new_count;
return *this;
}
counter_type& operator +=(size_t diff)
{
count += diff;
return *this;
}
counter_type& operator -=(size_t diff)
{
count -= diff;
return *this;
}
size_t get_count() const
{
return count;
}
size_t count;
};
counter_type<COUNT_OPTION> current_size; ///< Counts the number of elements in the list.
size_t current_size; ///< Counts the number of elements in the list.
//*************************************************************************
/// Is the intrusive_list a trivial length?

233
src/intrusive_queue.h Normal file
View File

@ -0,0 +1,233 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
http://www.etlcpp.com
Copyright(c) 2016 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_INTRUSIVE_QUEUE__
#define __ETL_INTRUSIVE_QUEUE__
#include <stddef.h>
#include "type_traits.h"
#include "error_handler.h"
#include "intrusive_links.h"
#define ETL_FILE "29"
namespace etl
{
//***************************************************************************
/// Exception base for intrusive queue
///\ingroup intrusive_queue
//***************************************************************************
class intrusive_queue_exception : public etl::exception
{
public:
intrusive_queue_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
//***************************************************************************
/// intrusive_queue empty exception.
///\ingroup intrusive_queue
//***************************************************************************
class intrusive_queue_empty : public intrusive_queue_exception
{
public:
intrusive_queue_empty(string_type file_name, numeric_type line_number)
: intrusive_queue_exception(ETL_ERROR_TEXT("intrusive_queue:empty", ETL_FILE"A"), file_name, line_number)
{
}
};
//***************************************************************************
///\ingroup queue
/// An intrusive queue. Stores elements derived from etl::forward_link
/// \warning This queue cannot be used for concurrent access from multiple threads.
/// \tparam TValue The type of value that the queue holds.
/// \tparam TLink The link type that the value is derived from.
//***************************************************************************
template <typename TValue, typename TLink>
class intrusive_queue
{
public:
// Node typedef.
typedef TLink link_type;
// STL style typedefs.
typedef TValue value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef size_t size_type;
//*************************************************************************
/// Constructor
//*************************************************************************
intrusive_queue()
: p_front(nullptr),
p_back(nullptr),
current_size(0)
{
}
//*************************************************************************
/// Gets a reference to the value at the front of the queue.
/// Undefined behaviour if the queue is empty.
/// \return A reference to the value at the front of the queue.
//*************************************************************************
reference front()
{
return *static_cast<TValue*>(p_front);
}
//*************************************************************************
/// Gets a reference to the value at the back of the queue.
/// Undefined behaviour if the queue is empty.
/// \return A reference to the value at the back of the queue.
//*************************************************************************
reference back()
{
return *static_cast<TValue*>(p_back);
}
//*************************************************************************
/// Gets a const reference to the value at the front of the queue.
/// Undefined behaviour if the queue is empty.
/// \return A const reference to the value at the front of the queue.
//*************************************************************************
const_reference front() const
{
return *static_cast<const TValue*>(p_front);
}
//*************************************************************************
/// Gets a reference to the value at the back of the queue.
/// Undefined behaviour if the queue is empty.
/// \return A reference to the value at the back of the queue.
//*************************************************************************
const_reference back() const
{
return *static_cast<const TValue*>(p_back);
}
//*************************************************************************
/// Adds a value to the queue.
///\param value The value to push to the queue.
//*************************************************************************
void push(link_type& value)
{
value.clear();
if (p_back != nullptr)
{
etl::link(p_back, value);
}
else
{
p_front = &value;
}
p_back = &value;
++current_size;
}
//*************************************************************************
/// Removes the oldest item from the queue.
/// Undefined behaviour if the queue is already empty.
//*************************************************************************
void pop()
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!empty(), ETL_ERROR(intrusive_queue_empty));
#endif
link_type* p_next = p_front->etl_next;
p_front = p_next;
// Now empty?
if (p_front == nullptr)
{
p_back = nullptr;
}
--current_size;
}
//*************************************************************************
/// Clears the queue to the empty state.
//*************************************************************************
void clear()
{
while (!empty())
{
pop();
}
current_size = 0;
}
//*************************************************************************
/// Checks if the queue is in the empty state.
//*************************************************************************
bool empty() const
{
return current_size == 0;
}
//*************************************************************************
/// Returns the number of elements.
//*************************************************************************
size_t size() const
{
return current_size;
}
private:
// Disable copy construction and assignment.
intrusive_queue(const intrusive_queue&);
intrusive_queue& operator = (const intrusive_queue& rhs);
link_type* p_front; // The current front of the queue.
link_type* p_back; // The current back of the queue.
size_t current_size; ///< Counts the number of elements in the list.
};
}
#undef ETL_FILE
#endif

198
src/intrusive_stack.h Normal file
View File

@ -0,0 +1,198 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
http://www.etlcpp.com
Copyright(c) 2016 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_INTRUSIVE_STACK__
#define __ETL_INTRUSIVE_STACK__
#include <stddef.h>
#include "type_traits.h"
#include "error_handler.h"
#include "intrusive_links.h"
#define ETL_FILE "28"
namespace etl
{
//***************************************************************************
/// Exception base for intrusive stack
///\ingroup intrusive_stack
//***************************************************************************
class intrusive_stack_exception : public etl::exception
{
public:
intrusive_stack_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
//***************************************************************************
/// intrusive_stack empty exception.
///\ingroup intrusive_stack
//***************************************************************************
class intrusive_stack_empty : public intrusive_stack_exception
{
public:
intrusive_stack_empty(string_type file_name, numeric_type line_number)
: intrusive_stack_exception(ETL_ERROR_TEXT("intrusive_stack:empty", ETL_FILE"A"), file_name, line_number)
{
}
};
//***************************************************************************
///\ingroup stack
/// An intrusive stack. Stores elements derived from etl::forward_link
/// \warning This stack cannot be used for concurrent access from multiple threads.
/// \tparam TValue The type of value that the stack holds.
/// \tparam TLink The link type that the value is derived from.
//***************************************************************************
template <typename TValue, typename TLink>
class intrusive_stack
{
public:
// Node typedef.
typedef TLink link_type;
// STL style typedefs.
typedef TValue value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef size_t size_type;
//*************************************************************************
/// Constructor
//*************************************************************************
intrusive_stack()
: p_top(nullptr),
current_size(0)
{
}
//*************************************************************************
/// Gets a reference to the value at the top of the stack.
/// Undefined behaviour if the stack is empty.
/// \return A reference to the value at the top of the stack.
//*************************************************************************
reference top()
{
return *static_cast<TValue*>(p_top);
}
//*************************************************************************
/// Gets a const reference to the value at the top of the stack.<br>
/// \return A const reference to the value at the top of the stack.
//*************************************************************************
const_reference top() const
{
return *static_cast<const TValue*>(p_top);
}
//*************************************************************************
/// Adds a value to the stack.
///\param value The value to push to the stack.
//*************************************************************************
void push(link_type& value)
{
value.clear();
if (p_top != nullptr)
{
etl::link(value, p_top);
}
p_top = &value;
++current_size;
}
//*************************************************************************
/// Removes the oldest item from the top of the stack.
/// Undefined behaviour if the stack is already empty.
//*************************************************************************
void pop()
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!empty(), ETL_ERROR(intrusive_stack_empty));
#endif
link_type* p_next = p_top->etl_next;
p_top = p_next;
--current_size;
}
//*************************************************************************
/// Clears the stack to the empty state.
//*************************************************************************
void clear()
{
while (!empty())
{
pop();
}
current_size = 0;
}
//*************************************************************************
/// Checks if the stack is in the empty state.
//*************************************************************************
bool empty() const
{
return current_size == 0;
}
//*************************************************************************
/// Returns the number of elements.
//*************************************************************************
size_t size() const
{
return current_size;
}
private:
// Disable copy construction and assignment.
intrusive_stack(const intrusive_stack&);
intrusive_stack& operator = (const intrusive_stack& rhs);
link_type* p_top; // The current top of the stack.
size_t current_size; ///< Counts the number of elements in the list.
};
}
#undef ETL_FILE
#endif

View File

@ -46,7 +46,7 @@ namespace etl
//***************************************************************************
template <typename T>
class ipool : public pool_base
{
{
public:
typedef T value_type;
@ -358,7 +358,7 @@ namespace etl
return result;
}
//*************************************************************************
/// Release an object in the pool.
/// If asserts or exceptions are enabled and the object does not belong to this
@ -505,6 +505,14 @@ namespace etl
{
}
//*************************************************************************
/// Destructor
//*************************************************************************
~ipool()
{
release_all();
}
private:
// Disable copy construction and assignment.

View File

@ -167,7 +167,7 @@ namespace etl
template <typename TIterator>
void assign(TIterator first, TIterator last)
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
difference_type count = std::distance(first, last);
ETL_ASSERT(count >= 0, ETL_ERROR(priority_queue_iterator));
ETL_ASSERT(static_cast<size_t>(count) <= max_size(), ETL_ERROR(priority_queue_full));
@ -184,13 +184,10 @@ namespace etl
//*************************************************************************
void pop()
{
if (!empty())
{
// Move largest element to end
std::pop_heap(container.begin(), container.end(), TCompare());
std::pop_heap(container.begin(), container.end(), TCompare());
// Actually remove largest element at end
container.pop_back();
}
}
//*************************************************************************

View File

@ -736,7 +736,7 @@ namespace etl
template <typename TIterator>
void assign(TIterator first, TIterator last)
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
difference_type count = std::distance(first, last);
ETL_ASSERT(count >= 0, ETL_ERROR(unordered_map_iterator));
ETL_ASSERT(size_t(count) <= max_size() , ETL_ERROR(unordered_map_full));

View File

@ -630,7 +630,7 @@ namespace etl
template <typename TIterator>
void assign(TIterator first, TIterator last)
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
difference_type count = std::distance(first, last);
ETL_ASSERT(count >= 0, ETL_ERROR(unordered_multimap_iterator));
ETL_ASSERT(size_t(count) <= max_size() , ETL_ERROR(unordered_multimap_full));

View File

@ -625,7 +625,7 @@ namespace etl
template <typename TIterator>
void assign(TIterator first, TIterator last)
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
difference_type count = std::distance(first, last);
ETL_ASSERT(count >= 0, ETL_ERROR(unordered_multiset_iterator));
ETL_ASSERT(size_t(count) <= max_size() , ETL_ERROR(unordered_multiset_full));

View File

@ -625,7 +625,7 @@ namespace etl
template <typename TIterator>
void assign(TIterator first, TIterator last)
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
difference_type count = std::distance(first, last);
ETL_ASSERT(count >= 0, ETL_ERROR(unordered_set_iterator));
ETL_ASSERT(size_t(count) <= max_size() , ETL_ERROR(unordered_set_full));

View File

@ -382,7 +382,7 @@ namespace etl
template <typename TIterator>
void assign(TIterator first, TIterator last)
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
difference_type count = std::distance(first, last);
ETL_ASSERT(static_cast<size_t>(count) <= MAX_SIZE, ETL_ERROR(vector_full));
#endif

531
src/ivectorpointer.h Normal file
View File

@ -0,0 +1,531 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
http://www.etlcpp.com
Copyright(c) 2016 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_IVECTOR_POINTER__
#define __ETL_IVECTOR_POINTER__
#ifndef __ETL_IN_IVECTOR_H__
#error This header is a private element of etl::ivector
#endif
namespace etl
{
//***************************************************************************
/// The base class for specifically sized vectors.
/// Can be used as a reference type for all vectors containing a specific pointer type.
///\ingroup vector
//***************************************************************************
template <typename T/*, typename etl::enable_if<!etl::is_same<T*, void*>::value, void>::type*/>
class ivector<T*> : public ivector<void*>
{
private:
// Stops warning messages about unused template parameter.
//const bool not_void_ptr = typedef etl::is_same<T*, void*>::value;
public:
typedef T* value_type;
typedef T*& reference;
typedef const T* const & const_reference;
typedef T** pointer;
typedef const T* const * const_pointer;
typedef T** iterator;
typedef const T* const * const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef size_t size_type;
typedef typename std::iterator_traits<iterator>::difference_type difference_type;
protected:
typedef value_type parameter_t;
private:
typedef ivector<void*> base_t;
public:
//*********************************************************************
/// Returns an iterator to the beginning of the vector.
///\return An iterator to the beginning of the vector.
//*********************************************************************
iterator begin()
{
return iterator(base_t::begin());
}
//*********************************************************************
/// Returns a const_iterator to the beginning of the vector.
///\return A const iterator to the beginning of the vector.
//*********************************************************************
const_iterator begin() const
{
return const_iterator(base_t::begin());
}
//*********************************************************************
/// Returns an iterator to the end of the vector.
///\return An iterator to the end of the vector.
//*********************************************************************
iterator end()
{
return iterator(base_t::end());
}
//*********************************************************************
/// Returns a const_iterator to the end of the vector.
///\return A const iterator to the end of the vector.
//*********************************************************************
const_iterator end() const
{
return const_iterator(base_t::end());
}
//*********************************************************************
/// Returns a const_iterator to the beginning of the vector.
///\return A const iterator to the beginning of the vector.
//*********************************************************************
const_iterator cbegin() const
{
return const_iterator(base_t::cbegin());
}
//*********************************************************************
/// Returns a const_iterator to the end of the vector.
///\return A const iterator to the end of the vector.
//*********************************************************************
const_iterator cend() const
{
return const_iterator(base_t::cend());
}
//*********************************************************************
/// Returns an reverse iterator to the reverse beginning of the vector.
///\return Iterator to the reverse beginning of the vector.
//*********************************************************************
reverse_iterator rbegin()
{
return reverse_iterator(iterator(base_t::end()));
}
//*********************************************************************
/// Returns a const reverse iterator to the reverse beginning of the vector.
///\return Const iterator to the reverse beginning of the vector.
//*********************************************************************
const_reverse_iterator rbegin() const
{
return const_reverse_iterator(const_iterator(base_t::end()));
}
//*********************************************************************
/// Returns a reverse iterator to the end + 1 of the vector.
///\return Reverse iterator to the end + 1 of the vector.
//*********************************************************************
reverse_iterator rend()
{
return reverse_iterator(iterator(base_t::begin()));
}
//*********************************************************************
/// Returns a const reverse iterator to the end + 1 of the vector.
///\return Const reverse iterator to the end + 1 of the vector.
//*********************************************************************
const_reverse_iterator rend() const
{
return const_reverse_iterator(const_iterator(base_t::begin()));
}
//*********************************************************************
/// Returns a const reverse iterator to the reverse beginning of the vector.
///\return Const reverse iterator to the reverse beginning of the vector.
//*********************************************************************
const_reverse_iterator crbegin() const
{
return const_reverse_iterator(const_iterator(base_t::cend()));
}
//*********************************************************************
/// Returns a const reverse iterator to the end + 1 of the vector.
///\return Const reverse iterator to the end + 1 of the vector.
//*********************************************************************
const_reverse_iterator crend() const
{
return const_reverse_iterator(const_iterator(base_t::cbegin()));
}
//*********************************************************************
/// Resizes the vector.
/// If asserts or exceptions are enabled and the new size is larger than the
/// maximum then a vector_full is thrown.
///\param new_size The new size.
//*********************************************************************
void resize(size_t new_size)
{
base_t::resize(new_size);
}
//*********************************************************************
/// Resizes the vector.
/// If asserts or exceptions are enabled and the new size is larger than the
/// maximum then a vector_full is thrown.
///\param new_size The new size.
///\param value The value to fill new elements with. Default = default constructed value.
//*********************************************************************
void resize(size_t new_size, value_type value)
{
base_t::resize(new_size, value);
}
//*********************************************************************
/// Returns a reference to the value at index 'i'
///\param i The index.
///\return A reference to the value at index 'i'
//*********************************************************************
reference operator [](size_t i)
{
return reference(base_t::operator[](i));
}
//*********************************************************************
/// Returns a const reference to the value at index 'i'
///\param i The index.
///\return A const reference to the value at index 'i'
//*********************************************************************
const_reference operator [](size_t i) const
{
return const_reference(base_t::operator[](i));
}
//*********************************************************************
/// Returns a reference to the value at index 'i'
/// If asserts or exceptions are enabled, emits an etl::vector_out_of_bounds if the index is out of range.
///\param i The index.
///\return A reference to the value at index 'i'
//*********************************************************************
reference at(size_t i)
{
return reference(base_t::at(i));
}
//*********************************************************************
/// Returns a const reference to the value at index 'i'
/// If asserts or exceptions are enabled, emits an etl::vector_out_of_bounds if the index is out of range.
///\param i The index.
///\return A const reference to the value at index 'i'
//*********************************************************************
const_reference at(size_t i) const
{
return const_reference(base_t::at(i));
}
//*********************************************************************
/// Returns a reference to the first element.
///\return A reference to the first element.
//*********************************************************************
reference front()
{
return reference(base_t::front());
}
//*********************************************************************
/// Returns a const reference to the first element.
///\return A const reference to the first element.
//*********************************************************************
const_reference front() const
{
return const_reference(base_t::front());
}
//*********************************************************************
/// Returns a reference to the last element.
///\return A reference to the last element.
//*********************************************************************
reference back()
{
return reference(base_t::back());
}
//*********************************************************************
/// Returns a const reference to the last element.
///\return A const reference to the last element.
//*********************************************************************
const_reference back() const
{
return const_reference(base_t::back());
}
//*********************************************************************
/// Returns a pointer to the beginning of the vector data.
///\return A pointer to the beginning of the vector data.
//*********************************************************************
pointer data()
{
return pointer(base_t::data());
}
//*********************************************************************
/// Returns a const pointer to the beginning of the vector data.
///\return A const pointer to the beginning of the vector data.
//*********************************************************************
const_pointer data() const
{
return const_pointer(base_t::data());
}
//*********************************************************************
/// Assigns values to the vector.
/// If asserts or exceptions are enabled, emits vector_full if the vector does not have enough free space.
/// If asserts or exceptions are enabled, emits vector_iterator if the iterators are reversed.
///\param first The iterator to the first element.
///\param last The iterator to the last element + 1.
//*********************************************************************
template <typename TIterator>
void assign(TIterator first, TIterator last)
{
base_t::initialise();
while (first != last)
{
p_buffer[current_size++] = (void*)*first++;
}
}
//*********************************************************************
/// Assigns values to the vector.
/// If asserts or exceptions are enabled, emits vector_full if the vector does not have enough free space.
///\param n The number of elements to add.
///\param value The value to insert for each element.
//*********************************************************************
void assign(size_t n, parameter_t value)
{
base_t::assign(n, value);
}
//*************************************************************************
/// Clears the vector.
//*************************************************************************
void clear()
{
base_t::clear();
}
//*************************************************************************
/// Increases the size of the vector by one, but does not initialise the new element.
/// If asserts or exceptions are enabled, throws a vector_full if the vector is already full.
//*************************************************************************
void push_back()
{
base_t::push_back();
}
//*********************************************************************
/// Inserts a value at the end of the vector.
/// If asserts or exceptions are enabled, emits vector_full if the vector is already full.
///\param value The value to add.
//*********************************************************************
void push_back(parameter_t value)
{
base_t::push_back(value);
}
//*************************************************************************
/// Removes an element from the end of the vector.
/// Does nothing if the vector is empty.
//*************************************************************************
void pop_back()
{
base_t::pop_back();
}
//*********************************************************************
/// Inserts a value to the vector.
/// If asserts or exceptions are enabled, emits vector_full if the vector is already full.
///\param position The position to insert before.
///\param value The value to insert.
//*********************************************************************
iterator insert(iterator position, parameter_t value)
{
return iterator(base_t::insert(base_t::iterator(position), value));
}
//*********************************************************************
/// Inserts 'n' values to the vector.
/// If asserts or exceptions are enabled, emits vector_full if the vector does not have enough free space.
///\param position The position to insert before.
///\param n The number of elements to add.
///\param value The value to insert.
//*********************************************************************
void insert(iterator position, size_t n, parameter_t value)
{
base_t::insert(base_t::iterator(position), n, value);
}
//*********************************************************************
/// Inserts a range of values to the vector.
/// If asserts or exceptions are enabled, emits vector_full if the vector does not have enough free space.
///\param position The position to insert before.
///\param first The first element to add.
///\param last The last + 1 element to add.
//*********************************************************************
template <class TIterator>
void insert(iterator position, TIterator first, TIterator last)
{
base_t::insert(base_t::iterator(position), first, last);
}
//*********************************************************************
/// Erases an element.
///\param i_element Iterator to the element.
///\return An iterator pointing to the element that followed the erased element.
//*********************************************************************
iterator erase(iterator i_element)
{
return iterator(base_t::erase(base_t::iterator(i_element)));
}
//*********************************************************************
/// Erases a range of elements.
/// The range includes all the elements between first and last, including the
/// element pointed by first, but not the one pointed by last.
///\param first Iterator to the first element.
///\param last Iterator to the last element.
///\return An iterator pointing to the element that followed the erased element.
//*********************************************************************
iterator erase(iterator first, iterator last)
{
return iterator(base_t::erase(base_t::iterator(first), base_t::iterator(last)));
}
//*************************************************************************
/// Assignment operator.
//*************************************************************************
ivector& operator = (const ivector& rhs)
{
if (&rhs != this)
{
assign(rhs.cbegin(), rhs.cend());
}
return *this;
}
protected:
//*********************************************************************
/// Constructor.
//*********************************************************************
ivector(void** p_buffer, size_t MAX_SIZE)
: ivector<void*>(p_buffer, MAX_SIZE)
{
}
};
//***************************************************************************
/// Equal operator.
///\param lhs Reference to the first vector.
///\param rhs Reference to the second vector.
///\return <b>true</b> if the arrays are equal, otherwise <b>false</b>
///\ingroup vector
//***************************************************************************
template <typename T>
bool operator ==(const etl::ivector<T*>& lhs, const etl::ivector<T*>& rhs)
{
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin());
}
//***************************************************************************
/// Not equal operator.
///\param lhs Reference to the first vector.
///\param rhs Reference to the second vector.
///\return <b>true</b> if the arrays are not equal, otherwise <b>false</b>
///\ingroup vector
//***************************************************************************
template <typename T>
bool operator !=(const etl::ivector<T*>& lhs, const etl::ivector<T*>& rhs)
{
return !(lhs == rhs);
}
//***************************************************************************
/// Less than operator.
///\param lhs Reference to the first vector.
///\param rhs Reference to the second vector.
///\return <b>true</b> if the first vector is lexicographically less than the second, otherwise <b>false</b>
///\ingroup vector
//***************************************************************************
template <typename T>
bool operator <(const etl::ivector<T*>& lhs, const etl::ivector<T*>& rhs)
{
return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
}
//***************************************************************************
/// Greater than operator.
///\param lhs Reference to the first vector.
///\param rhs Reference to the second vector.
///\return <b>true</b> if the first vector is lexicographically greater than the second, otherwise <b>false</b>
///\ingroup vector
//***************************************************************************
template <typename T>
bool operator >(const etl::ivector<T*>& lhs, const etl::ivector<T*>& rhs)
{
return (rhs < lhs);
}
//***************************************************************************
/// Less than or equal operator.
///\param lhs Reference to the first vector.
///\param rhs Reference to the second vector.
///\return <b>true</b> if the first vector is lexigraphically less than or equal to the second, otherwise <b>false</b>
///\ingroup vector
//***************************************************************************
template <typename T>
bool operator <=(const etl::ivector<T*>& lhs, const etl::ivector<T*>& rhs)
{
return !(lhs > rhs);
}
//***************************************************************************
/// Greater than or equal operator.
///\param lhs Reference to the first vector.
///\param rhs Reference to the second vector.
///\return <b>true</b> if the first vector is lexigraphically greater than or equal to the second, otherwise <b>false</b>
///\ingroup vector
//***************************************************************************
template <typename T>
bool operator >=(const etl::ivector<T*>& lhs, const etl::ivector<T*>& rhs)
{
return !(lhs < rhs);
}
}
#endif

View File

@ -39,9 +39,10 @@ SOFTWARE.
#include "type_traits.h"
#include "error_handler.h"
#include "ihash.h"
#include "frame_check_sequence.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
#pragma diag_suppress 1300
#endif
///\defgroup jenkins Jenkins 32 & 64 bit hash calculations
@ -50,24 +51,96 @@ SOFTWARE.
namespace etl
{
//***************************************************************************
/// Calculates the jenkins hash.
///\ingroup jenkins
/// Jenkins32 policy.
/// Calculates 32 bit Jenkins hash.
//***************************************************************************
template <typename THash>
class jenkins
struct jenkins32_policy
{
typedef uint32_t value_type;
inline uint32_t initial()
{
is_finalised = false;
return 0;
}
inline uint32_t add(value_type hash, uint8_t value) const
{
ETL_ASSERT(!is_finalised, ETL_ERROR(hash_finalised));
hash += value;
hash += (hash << 10);
hash ^= (hash >> 6);
return hash;
}
inline uint32_t final(value_type hash)
{
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
is_finalised = true;
return hash;
}
bool is_finalised;
};
//***************************************************************************
/// Jenkins64 policy.
/// Calculates 32 bit Jenkins hash.
//***************************************************************************
struct jenkins64_policy
{
typedef uint64_t value_type;
inline uint64_t initial()
{
is_finalised = false;
return 0;
}
inline uint64_t add(value_type hash, uint8_t value) const
{
ETL_ASSERT(!is_finalised, ETL_ERROR(hash_finalised));
hash += value;
hash += (hash << 10);
hash ^= (hash >> 6);
return hash;
}
inline uint64_t final(value_type hash)
{
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
is_finalised = true;
return hash;
}
bool is_finalised;
};
//*************************************************************************
/// Jenkins32
//*************************************************************************
class jenkins32 : public etl::frame_check_sequence<etl::jenkins32_policy>
{
public:
STATIC_ASSERT((etl::is_same<THash, uint32_t>::value || etl::is_same<THash, uint64_t>::value), "Only 32 & 64 bit types supported");
typedef THash value_type;
//*************************************************************************
/// Default constructor.
//*************************************************************************
jenkins()
jenkins32()
{
reset();
this->reset();
}
//*************************************************************************
@ -76,92 +149,39 @@ namespace etl
/// \param end End of the range.
//*************************************************************************
template<typename TIterator>
jenkins(TIterator begin, const TIterator end)
jenkins32(TIterator begin, const TIterator end)
{
STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Incompatible type");
this->reset();
this->add(begin, end);
}
};
reset();
//*************************************************************************
/// Jenkins64
//*************************************************************************
class jenkins64 : public etl::frame_check_sequence<etl::jenkins64_policy>
{
public:
while (begin != end)
{
hash += *begin++;
hash += (hash << 10);
hash ^= (hash >> 6);
}
//*************************************************************************
/// Default constructor.
//*************************************************************************
jenkins64()
{
this->reset();
}
//*************************************************************************
/// Resets the CRC to the initial state.
//*************************************************************************
void reset()
{
hash = 0;
is_finalised = false;
}
//*************************************************************************
/// Adds a range.
/// \param begin
/// \param end
/// Constructor from range.
/// \param begin Start of the range.
/// \param end End of the range.
//*************************************************************************
template<typename TIterator>
void add(TIterator begin, const TIterator end)
jenkins64(TIterator begin, const TIterator end)
{
STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Incompatible type");
ETL_ASSERT(!is_finalised, ETL_ERROR(hash_finalised));
while (begin != end)
{
hash += *begin++;
hash += (hash << 10);
hash ^= (hash >> 6);
}
this->reset();
this->add(begin, end);
}
//*************************************************************************
/// \param value The char to add to the jenkins.
//*************************************************************************
void add(uint8_t value)
{
ETL_ASSERT(!is_finalised, ETL_ERROR(hash_finalised));
hash += value;
hash += (hash << 10);
hash ^= (hash >> 6);
}
//*************************************************************************
/// Gets the jenkins value.
//*************************************************************************
value_type value()
{
finalise();
return hash;
}
//*************************************************************************
/// Conversion operator to value_type.
//*************************************************************************
operator value_type ()
{
return value();
}
private:
void finalise()
{
if (!is_finalised)
{
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
is_finalised = true;
}
}
value_type hash;
bool is_finalised;
};
}

View File

@ -37,7 +37,7 @@ SOFTWARE.
/// A definition of nullptr for compilers that don't support it as standard.
///\ingroup utilities
#if defined(NO_NULLPTR_SUPPORT)
#if defined(ETL_NO_NULLPTR_SUPPORT)
namespace std
{
//*****************************************************************************

View File

@ -218,7 +218,7 @@ namespace etl
//***************************************************************************
T* operator ->()
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
#endif
@ -230,7 +230,7 @@ namespace etl
//***************************************************************************
const T* operator ->() const
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
#endif
@ -242,7 +242,7 @@ namespace etl
//***************************************************************************
T& operator *()
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
#endif
@ -254,7 +254,7 @@ namespace etl
//***************************************************************************
const T& operator *() const
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
#endif
@ -274,7 +274,7 @@ namespace etl
//***************************************************************************
T& value()
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
#endif
@ -286,7 +286,7 @@ namespace etl
//***************************************************************************
const T& value() const
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
#endif

View File

@ -30,6 +30,11 @@ SOFTWARE.
#include <stdint.h>
#include "platform.h"
#include "static_assert.h"
STATIC_ASSERT(ETL_8BIT_SUPPORT, "This file does not currently support targets with no 8bit type");
namespace etl
{
//***************************************************************************

View File

@ -41,6 +41,8 @@ SOFTWARE.
#include "array.h"
#include "container.h"
STATIC_ASSERT(ETL_8BIT_SUPPORT, "This file does not currently support targets with no 8bit type");
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
#endif

View File

@ -28,46 +28,60 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
// Define the platform.
// For FreeRTOS you must define ETL_PLATFORM_FREERTOS in the project settings.
#if defined(__linux__)
#define ETL_PLATFORM_LINUX
#elif defined(WIN32) || defined(WIN64)
#define ETL_PLATFORM_WINDOWS
#elif defined(__VXWORKS__) || defined(_WRS_VXWORKS_MAJOR)
#define ETL_PLATFORM_VXWORKS
#elif defined(__QNX__) || defined(__QNXNTO__)
#define ETL_PLATFORM_QNX
#elif defined(_WIN32_WCE)
#define ETL_PLATFORM_WINDOWS_CE
#else
#define ETL_PLATFORM_GENERIC
#endif
#include <stdint.h>
#include <limits.h>
// Define the compiler.
#if defined(__IAR_SYSTEMS_ICC__)
#define ETL_COMPILER_IAR
#define ETL_COMPILER_IAR
#elif defined(__KEIL__) && !defined(__GNUC__)
#define ETL_COMPILER_KEIL
#define ETL_COMPILER_KEIL
#elif defined(__ghs__)
#define ETL_COMPILER_GREEN_HILLS
#define ETL_COMPILER_GREEN_HILLS
#elif defined(__INTEL_COMPILER)
#define ETL_COMPILER_INTEL
#define ETL_COMPILER_INTEL
#elif defined(_MSC_VER)
#define ETL_COMPILER_MICROSOFT
#define ETL_COMPILER_MICROSOFT
#elif defined(__GNUC__)
#define ETL_COMPILER_GCC
#define ETL_COMPILER_GCC
#elif defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
#define ETL_COMPILER_TI_MSP430
#define ETL_COMPILER_TI_MSP430
#elif defined(_MRI)
#define ETL_COMPILER_MICROTEC
#elif defined(__HIGHC__)
#define ETL_COMPILER_METAWARE_HIGH
#elif defined(__llvm__)
#define ETL_COMPILER_LLVM
#elif defined(__KCC_VERSION)
#define ETL_COMPILER_KAI
#elif defined(_COMO__)
#define ETL_COMPILER_COMEAU
#elif defined(__BORLANDC__)
#define ETL_COMPILER_BORLAND
#elif defined(__CC_ARM)
#define ETL_COMPILER_ARM
#elif defined(__MRC__)
#define ETL_COMPILER_MPW
#else
#define ETL_COMPILER_GENERIC
#define ETL_COMPILER_GENERIC
#endif
// Check to see if the compiler supports nullptr and large character types.
#if (defined(ETL_COMPILER_MICROSOFT) && (_MSC_VER < 1600)) || \
defined(ETL_COMPILER_KEIL) || \
defined(ETL_COMPILER_TI_MSP430) || \
defined(ETL_COMPILER_IAR) || \
(defined(ETL_COMPILER_GCC) && (__cplusplus < 201103L))
#define NO_NULLPTR_SUPPORT
#define NO_LARGE_CHAR_SUPPORT
#define ETL_ETL_NO_NULLPTR_SUPPORT
#define ETL_ETL_NO_LARGE_CHAR_SUPPORT
#endif
// Check to see if the compiler supports static_assert.
#if (defined(ETL_COMPILER_MICROSOFT) && (_MSC_VER >= 1600)) || \
(defined(ETL_COMPILER_GCC) && (__cplusplus >= 201103L))
#define ETL_STATIC_ASSERT_SUPPORTED
#endif
// Some targets do not support 8bit types.
#define ETL_8BIT_SUPPORT (CHAR_BIT == 8)

View File

@ -456,7 +456,7 @@ namespace etl
template <typename T>
bool operator ==(const etl::ivector<T*>& lhs, const etl::ivector<T*>& rhs)
{
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin());
return pvoidvector_equal(lhs, rhs);
}
//***************************************************************************
@ -469,7 +469,7 @@ namespace etl
template <typename T>
bool operator !=(const etl::ivector<T*>& lhs, const etl::ivector<T*>& rhs)
{
return !(lhs == rhs);
return pvoidvector_not_equal(lhs, rhs);
}
//***************************************************************************
@ -482,7 +482,7 @@ namespace etl
template <typename T>
bool operator <(const etl::ivector<T*>& lhs, const etl::ivector<T*>& rhs)
{
return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
return pvoidvector_less_than(lhs, rhs);
}
//***************************************************************************
@ -495,7 +495,7 @@ namespace etl
template <typename T>
bool operator >(const etl::ivector<T*>& lhs, const etl::ivector<T*>& rhs)
{
return (rhs < lhs);
return pvoidvector_greater_than(lhs, rhs);
}
//***************************************************************************
@ -508,7 +508,7 @@ namespace etl
template <typename T>
bool operator <=(const etl::ivector<T*>& lhs, const etl::ivector<T*>& rhs)
{
return !(lhs > rhs);
return pvoidvector_less_than_equal(lhs, rhs);
}
//***************************************************************************
@ -521,7 +521,40 @@ namespace etl
template <typename T>
bool operator >=(const etl::ivector<T*>& lhs, const etl::ivector<T*>& rhs)
{
return !(lhs < rhs);
return pvoidvector_greater_than_equal(lhs, rhs);
}
//***************************************************************************
// Helper functions
//***************************************************************************
inline bool pvoidvector_equal(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs)
{
return operator ==(lhs, rhs);
}
inline bool pvoidvector_not_equal(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs)
{
return operator !=(lhs, rhs);
}
inline bool pvoidvector_less_than(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs)
{
return operator <(lhs, rhs);
}
inline bool pvoidvector_greater_than(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs)
{
return operator >(lhs, rhs);
}
inline bool pvoidvector_less_than_equal(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs)
{
return operator <=(lhs, rhs);
}
inline bool pvoidvector_greater_than_equal(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs)
{
return operator >=(lhs, rhs);
}
}

View File

@ -178,8 +178,8 @@ namespace etl
/// Constructor
//***********************************************************************
Node() :
weight(kNeither),
dir(kNeither)
weight(uint_least8_t(kNeither)),
dir(uint_least8_t(kNeither))
{
}
@ -188,15 +188,15 @@ namespace etl
//***********************************************************************
void mark_as_leaf()
{
weight = kNeither;
dir = kNeither;
weight = uint_least8_t(kNeither);
dir = uint_least8_t(kNeither);
children[0] = nullptr;
children[1] = nullptr;
}
Node* children[2];
uint8_t weight;
uint8_t dir;
uint_least8_t weight;
uint_least8_t dir;
};
//*************************************************************************
@ -222,12 +222,12 @@ namespace etl
while (weight_node)
{
// Keep going until we reach a terminal node (dir == kNeither)
if (kNeither != weight_node->dir)
if (uint_least8_t(kNeither) != weight_node->dir)
{
// Does this insert balance the previous weight factor value?
if (weight_node->weight == 1 - weight_node->dir)
{
weight_node->weight = kNeither;
weight_node->weight = uint_least8_t(kNeither);
}
else
{
@ -245,14 +245,14 @@ namespace etl
} // while(weight_node)
// Step 2: Update weight for critical_node or rotate tree to balance node
if (kNeither == critical_node->weight)
if (uint_least8_t(kNeither) == critical_node->weight)
{
critical_node->weight = critical_node->dir;
}
// If direction is different than weight, then it will now be balanced
else if (critical_node->dir != critical_node->weight)
{
critical_node->weight = kNeither;
critical_node->weight = uint_least8_t(kNeither);
}
// Rotate is required to balance the tree at the critical node
else
@ -276,7 +276,7 @@ namespace etl
//*************************************************************************
/// Rotate two nodes at the position provided the to balance the tree
//*************************************************************************
void rotate_2node(Node*& position, uint8_t dir)
void rotate_2node(Node*& position, uint_least8_t dir)
{
// A C A B
// B C -> A E OR B C -> D A
@ -296,17 +296,17 @@ namespace etl
// New root now becomes parent of current position
new_root->children[1 - dir] = position;
// Clear weight factor from current position
position->weight = kNeither;
position->weight = uint_least8_t(kNeither);
// Newly detached right now becomes current position
position = new_root;
// Clear weight factor from new root
position->weight = kNeither;
position->weight = uint_least8_t(kNeither);
}
//*************************************************************************
/// Rotate three nodes at the position provided the to balance the tree
//*************************************************************************
void rotate_3node(Node*& position, uint8_t dir, uint8_t third)
void rotate_3node(Node*& position, uint_least8_t dir, uint_least8_t third)
{
// __A__ __E__ __A__ __D__
// _B_ C -> B A OR B _C_ -> A C
@ -323,7 +323,7 @@ namespace etl
// Capture new root (either E or D depending on dir)
Node* new_root = position->children[dir]->children[1 - dir];
// Set weight factor for B or C based on F or G existing and being a different than dir
position->children[dir]->weight = third != kNeither && third != dir ? dir : kNeither;
position->children[dir]->weight = third != uint_least8_t(kNeither) && third != dir ? dir : uint_least8_t(kNeither);
// Detach new root from its tree (replace with new roots child)
position->children[dir]->children[1 - dir] =
@ -331,7 +331,7 @@ namespace etl
// Attach current left tree to new root
new_root->children[dir] = position->children[dir];
// Set weight factor for A based on F or G
position->weight = third != kNeither && third == dir ? 1 - dir : kNeither;
position->weight = third != uint_least8_t(kNeither) && third == dir ? 1 - dir : uint_least8_t(kNeither);
// Move new root's right tree to current roots left tree
position->children[dir] = new_root->children[1 - dir];
@ -340,7 +340,7 @@ namespace etl
// Replace current position with new root
position = new_root;
// Clear weight factor for new current position
position->weight = kNeither;
position->weight = uint_least8_t(kNeither);
}
//*************************************************************************

View File

@ -162,9 +162,9 @@ namespace etl
protected:
static const uint8_t kLeft = 0;
static const uint8_t kRight = 1;
static const uint8_t kNeither = 2;
static const uint_least8_t kLeft = 0;
static const uint_least8_t kRight = 1;
static const uint_least8_t kNeither = 2;
//*************************************************************************
/// The node element in the multimap.
@ -194,8 +194,8 @@ namespace etl
Node* parent;
Node* children[2];
uint8_t weight;
uint8_t dir;
uint_least8_t weight;
uint_least8_t dir;
};
//*************************************************************************
@ -275,7 +275,7 @@ namespace etl
//*************************************************************************
/// Rotate two nodes at the position provided the to balance the tree
//*************************************************************************
void rotate_2node(Node*& position, uint8_t dir)
void rotate_2node(Node*& position, uint_least8_t dir)
{
// A C A B
// B C -> A E OR B C -> D A
@ -316,7 +316,7 @@ namespace etl
//*************************************************************************
/// Rotate three nodes at the position provided the to balance the tree
//*************************************************************************
void rotate_3node(Node*& position, uint8_t dir, uint8_t third)
void rotate_3node(Node*& position, uint_least8_t dir, uint_least8_t third)
{
// __A__ __E__ __A__ __D__
// _B_ C -> B A OR B _C_ -> A C

View File

@ -162,9 +162,9 @@ namespace etl
protected:
static const uint8_t kLeft = 0;
static const uint8_t kRight = 1;
static const uint8_t kNeither = 2;
static const uint_least8_t kLeft = 0;
static const uint_least8_t kRight = 1;
static const uint_least8_t kNeither = 2;
//*************************************************************************
/// The node element in the multiset.
@ -194,8 +194,8 @@ namespace etl
Node* parent;
Node* children[2];
uint8_t weight;
uint8_t dir;
uint_least8_t weight;
uint_least8_t dir;
};
//*************************************************************************
@ -482,7 +482,7 @@ namespace etl
//*************************************************************************
/// Rotate two nodes at the position provided the to balance the tree
//*************************************************************************
void rotate_2node(Node*& position, uint8_t dir)
void rotate_2node(Node*& position, uint_least8_t dir)
{
// A C A B
// B C -> A E OR B C -> D A
@ -523,7 +523,7 @@ namespace etl
//*************************************************************************
/// Rotate three nodes at the position provided the to balance the tree
//*************************************************************************
void rotate_3node(Node*& position, uint8_t dir, uint8_t third)
void rotate_3node(Node*& position, uint_least8_t dir, uint_least8_t third)
{
// __A__ __E__ __A__ __D__
// _B_ C -> B A OR B _C_ -> A C

107
src/private/pvoidvector.cpp Normal file
View File

@ -0,0 +1,107 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
http://www.etlcpp.com
Copyright(c) 2016 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "pvoidvector.h"
namespace etl
{
//***************************************************************************
/// Equal operator.
///\param lhs Reference to the first vector.
///\param rhs Reference to the second vector.
///\return <b>true</b> if the arrays are equal, otherwise <b>false</b>
///\ingroup vector
//***************************************************************************
bool operator ==(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs)
{
return (lhs.size() == rhs.size()) && std::equal(lhs.begin(), lhs.end(), rhs.begin());
}
//***************************************************************************
/// Not equal operator.
///\param lhs Reference to the first vector.
///\param rhs Reference to the second vector.
///\return <b>true</b> if the arrays are not equal, otherwise <b>false</b>
///\ingroup vector
//***************************************************************************
bool operator !=(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs)
{
return !(lhs == rhs);
}
//***************************************************************************
/// Less than operator.
///\param lhs Reference to the first vector.
///\param rhs Reference to the second vector.
///\return <b>true</b> if the first vector is lexicographically less than the second, otherwise <b>false</b>
///\ingroup vector
//***************************************************************************
inline bool operator <(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs)
{
return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
}
//***************************************************************************
/// Greater than operator.
///\param lhs Reference to the first vector.
///\param rhs Reference to the second vector.
///\return <b>true</b> if the first vector is lexicographically greater than the second, otherwise <b>false</b>
///\ingroup vector
//***************************************************************************
bool operator >(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs)
{
return (rhs < lhs);
}
//***************************************************************************
/// Less than or equal operator.
///\param lhs Reference to the first vector.
///\param rhs Reference to the second vector.
///\return <b>true</b> if the first vector is lexicographically less than or equal to the second, otherwise <b>false</b>
///\ingroup vector
//***************************************************************************
bool operator <=(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs)
{
return !(lhs > rhs);
}
//***************************************************************************
/// Greater than or equal operator.
///\param lhs Reference to the first vector.
///\param rhs Reference to the second vector.
///\return <b>true</b> if the first vector is lexicographically greater than or equal to the second, otherwise <b>false</b>
///\ingroup vector
//***************************************************************************
bool operator >=(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs)
{
return !(lhs < rhs);
}
}

View File

@ -325,7 +325,7 @@ namespace etl
template <typename TIterator>
void assign(TIterator first, TIterator last)
{
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUG)
difference_type count = std::distance(first, last);
ETL_ASSERT(static_cast<size_t>(count) <= MAX_SIZE, ETL_ERROR(vector_full));
#endif
@ -616,6 +616,20 @@ namespace etl
// Disable copy construction.
pvoidvector(const pvoidvector&);
};
bool pvoidvector_equal(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs);
bool pvoidvector_not_equal(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs);
bool pvoidvector_less_than(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs);
bool pvoidvector_greater_than(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs);
bool pvoidvector_less_than_equal(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs);
bool pvoidvector_greater_than_equal(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs);
bool operator ==(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs);
bool operator !=(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs);
bool operator <(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs);
bool operator >(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs);
bool operator <=(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs);
bool operator >=(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs);
}
#ifdef ETL_COMPILER_MICROSOFT

View File

@ -194,8 +194,8 @@ namespace etl
}
Node* children[2];
uint8_t weight;
uint8_t dir;
uint_least8_t weight;
uint_least8_t dir;
};
//*************************************************************************
@ -260,12 +260,12 @@ namespace etl
while (weight_node)
{
// Keep going until we reach a terminal node (dir == kNeither)
if (kNeither != weight_node->dir)
if (uint_least8_t(kNeither) != weight_node->dir)
{
// Does this insert balance the previous weight factor value?
if (weight_node->weight == 1 - weight_node->dir)
{
weight_node->weight = kNeither;
weight_node->weight = uint_least8_t(kNeither);
}
else
{
@ -283,14 +283,14 @@ namespace etl
} // while(weight_node)
// Step 2: Update weight for critical_node or rotate tree to balance node
if (kNeither == critical_node->weight)
if (uint_least8_t(kNeither) == critical_node->weight)
{
critical_node->weight = critical_node->dir;
}
// If direction is different than weight, then it will now be balanced
else if (critical_node->dir != critical_node->weight)
{
critical_node->weight = kNeither;
critical_node->weight = uint_least8_t(kNeither);
}
// Rotate is required to balance the tree at the critical node
else
@ -348,7 +348,7 @@ namespace etl
//*************************************************************************
/// Rotate two nodes at the position provided the to balance the tree
//*************************************************************************
void rotate_2node(Node*& position, uint8_t dir)
void rotate_2node(Node*& position, uint_least8_t dir)
{
// A C A B
// B C -> A E OR B C -> D A
@ -368,17 +368,17 @@ namespace etl
// New root now becomes parent of current position
new_root->children[1 - dir] = position;
// Clear weight factor from current position
position->weight = kNeither;
position->weight = uint_least8_t(kNeither);
// Newly detached right now becomes current position
position = new_root;
// Clear weight factor from new root
position->weight = kNeither;
position->weight = uint_least8_t(kNeither);
}
//*************************************************************************
/// Rotate three nodes at the position provided the to balance the tree
//*************************************************************************
void rotate_3node(Node*& position, uint8_t dir, uint8_t third)
void rotate_3node(Node*& position, uint_least8_t dir, uint_least8_t third)
{
// __A__ __E__ __A__ __D__
// _B_ C -> B A OR B _C_ -> A C
@ -395,7 +395,7 @@ namespace etl
// Capture new root (either E or D depending on dir)
Node* new_root = position->children[dir]->children[1 - dir];
// Set weight factor for B or C based on F or G existing and being a different than dir
position->children[dir]->weight = third != kNeither && third != dir ? dir : kNeither;
position->children[dir]->weight = third != uint_least8_t(kNeither) && third != dir ? dir : uint_least8_t(kNeither);
// Detach new root from its tree (replace with new roots child)
position->children[dir]->children[1 - dir] =
@ -403,7 +403,7 @@ namespace etl
// Attach current left tree to new root
new_root->children[dir] = position->children[dir];
// Set weight factor for A based on F or G
position->weight = third != kNeither && third == dir ? 1 - dir : kNeither;
position->weight = third != uint_least8_t(kNeither) && third == dir ? 1 - dir : uint_least8_t(kNeither);
// Move new root's right tree to current roots left tree
position->children[dir] = new_root->children[1 - dir];
@ -412,7 +412,7 @@ namespace etl
// Replace current position with new root
position = new_root;
// Clear weight factor for new current position
position->weight = kNeither;
position->weight = uint_least8_t(kNeither);
}

View File

@ -42,7 +42,7 @@ SOFTWARE.
#include "../exception.h"
#include "../error_handler.h"
#define ETL_FILE "24"
#define ETL_FILE "27"
#ifdef ETL_COMPILER_MICROSOFT
#undef max
@ -116,7 +116,10 @@ namespace etl
typedef size_t size_type;
static const size_t npos = etl::integral_limits<size_t>::max;
enum
{
npos = etl::integral_limits<size_t>::max
};
//*************************************************************************
/// Gets the current size of the string.

View File

@ -53,7 +53,7 @@ namespace etl
hex = 16
};
DECLARE_ENUM_TYPE(radix, uint8_t)
DECLARE_ENUM_TYPE(radix, uint_least8_t)
ENUM_TYPE(undefined, "undefined")
ENUM_TYPE(binary, "binary")
ENUM_TYPE(octal, "octal")

94
src/ratio.h Normal file
View File

@ -0,0 +1,94 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
http://www.etlcpp.com
Copyright(c) 2016 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_RATIO__
#define __ETL_RATIO__
#include <stdint.h>
///\defgroup ratio ratio
///\ingroup utilities
namespace etl
{
template <const size_t NUM, const size_t DEN = 1>
struct ratio
{
static const std::intmax_t num = NUM;
static const std::intmax_t den = DEN;
};
#if INT_MAX > INT32_MAX
typedef ratio<1, 1000000000000000000000000> yocto;
typedef ratio<1, 1000000000000000000000> zepto;
typedef ratio<1, 1000000000000000000> atto
typedef ratio<1, 1000000000000000> femto
typedef ratio<1, 1000000000000> pico;
#endif
#if (INT_MAX >= INT32_MAX)
typedef ratio<1, 1000000000> nano;
typedef ratio<1, 1000000> micro;
#endif
#if (INT_MAX >= INT16_MAX)
typedef ratio<1, 1000> milli;
typedef ratio<1, 100> centi;
typedef ratio<1, 10> deci;
typedef ratio<10, 1> deca;
typedef ratio<100, 1> hecto
typedef ratio<1000, 1> kilo
#endif
#if (INT_MAX >= INT32_MAX)
typedef ratio<1000000, 1> mega;
typedef ratio<1000000000, 1> giga;
#endif
#if INT_MAX > INT32_MAX
typedef ratio<1000000000000, 1> tera;
typedef ratio<1000000000000000, 1> peta;
typedef ratio<1000000000000000000, 1> exa;
typedef ratio<1000000000000000000000, 1> zetta;
typedef ratio<1000000000000000000000000, 1> yotta;
#endif
/// An approximation of PI to 6 digits.
typedef ratio<355, 113> ratio_pi;
/// An approximation of root 2.
typedef ratio<239, 169> ratio_root2;
/// An approximation of e.
typedef ratio<326, 120> ratio_e;
}
#endif

View File

@ -154,6 +154,48 @@ namespace etl
{
typedef uint_least64_t type;
};
//*************************************************************************
// Determine the type to hold the number of bits based on the index.
//*************************************************************************
template <const int index>
struct best_fit_int_type;
//*************************************************************************
// Less than or equal to 8 bits.
//*************************************************************************
template <>
struct best_fit_int_type<0>
{
typedef int_least8_t type;
};
//*************************************************************************
// 9 to 16 bits.
//*************************************************************************
template <>
struct best_fit_int_type<1>
{
typedef int_least16_t type;
};
//*************************************************************************
// 17 to 31 bits.
//*************************************************************************
template <>
struct best_fit_int_type<2>
{
typedef int_least32_t type;
};
//*************************************************************************
// Greater than 32 bits.
//*************************************************************************
template <>
struct best_fit_int_type<3>
{
typedef int_least64_t type;
};
}
//***************************************************************************
@ -168,12 +210,77 @@ namespace etl
private:
// Determines the index of the best unsigned type for the required number of bits.
static const int TYPE_INDEX = ((NBITS > 8) ? 1 : 0) + ((NBITS > 16) ? 1 : 0) + ((NBITS > 32) ? 1 : 0);
static const int TYPE_INDEX = ((NBITS > 8) ? 1 : 0) +
((NBITS > 16) ? 1 : 0) +
((NBITS > 32) ? 1 : 0);
public:
typedef typename __private_smallest__::best_fit_uint_type<TYPE_INDEX>::type type;
};
//***************************************************************************
/// Template to determine the smallest signed int type that can contain a
/// value with the specified number of bits.
/// Defines 'type' which is the type of the smallest signed integer.
///\ingroup smallest
//***************************************************************************
template <const size_t NBITS>
struct smallest_int_for_bits
{
private:
// Determines the index of the best unsigned type for the required number of bits.
static const int TYPE_INDEX = ((NBITS > 8) ? 1 : 0) +
((NBITS > 16) ? 1 : 0) +
((NBITS > 32) ? 1 : 0);
public:
typedef typename __private_smallest__::best_fit_int_type<TYPE_INDEX>::type type;
};
//***************************************************************************
/// Template to determine the smallest unsigned int type that can contain the
/// specified unsigned value.
/// Defines 'type' which is the type of the smallest unsigned integer.
///\ingroup smallest
//***************************************************************************
template <const uintmax_t VALUE>
struct smallest_uint_for_value
{
private:
// Determines the index of the best unsigned type for the required value.
static const int TYPE_INDEX = ((VALUE > UINT8_MAX) ? 1 : 0) +
((VALUE > UINT16_MAX) ? 1 : 0) +
((VALUE > UINT32_MAX) ? 1 : 0);
public:
typedef typename __private_smallest__::best_fit_uint_type<TYPE_INDEX>::type type;
};
//***************************************************************************
/// Template to determine the smallest int type that can contain the
/// specified signed value.
/// Defines 'type' which is the type of the smallest signed integer.
///\ingroup smallest
//***************************************************************************
template <const intmax_t VALUE>
struct smallest_int_for_value
{
private:
// Determines the index of the best signed type for the required value.
static const int TYPE_INDEX = (((VALUE > INT8_MAX) || (VALUE < INT8_MIN)) ? 1 : 0) +
(((VALUE > INT16_MAX) || (VALUE < INT16_MIN)) ? 1 : 0) +
(((VALUE > INT32_MAX) || (VALUE < INT32_MIN)) ? 1 : 0);
public:
typedef typename __private_smallest__::best_fit_int_type<TYPE_INDEX>::type type;
};
}
#endif

View File

@ -31,9 +31,7 @@ SOFTWARE.
#include "platform.h"
#if defined(ETL_COMPILER_MICROSOFT)
#define STATIC_ASSERT(Condition, Message) static_assert(Condition, Message)
#elif defined(ETL_COMPILER_GCC)
#if defined(ETL_STATIC_ASSERT_SUPPORTED)
#define STATIC_ASSERT(Condition, Message) static_assert(Condition, Message)
#else
template <bool Condition>
@ -42,12 +40,13 @@ SOFTWARE.
template <>
struct STATIC_ASSERT_FAILED<true> {};
#define ETL_FCAT(a,b) a##b
#define ETL_ACAT(a,b) ETL_FCAT(a,b)
#define STATIC_ASSERT(cond,msg) \
enum \
{ ETL_ACAT(dummy,__LINE__)=sizeof(STATIC_ASSERT_FAILED<(bool)(cond)>) \
}
#define ETL_SA1(a,b) a##b
#define ETL_SA2(a,b) ETL_SA1(a,b)
#define STATIC_ASSERT(Condition, Message) \
enum \
{ \
ETL_SA2(dummy, __LINE__) = sizeof(STATIC_ASSERT_FAILED<(bool)(Condition)>) \
}
#endif
#endif

View File

@ -242,19 +242,16 @@ namespace etl
template <typename T> struct make_signed { typedef T type; };
template <> struct make_signed<char> { typedef signed char type; };
template <> struct make_signed<unsigned char> { typedef signed char type; };
#if defined(ETL_COMPILER_GCC)
template <> struct make_signed<wchar_t>
{
typedef wchar_t type;
typedef typename etl::conditional<sizeof(wchar_t) == sizeof(int16_t),
int16_t,
etl::conditional<sizeof(wchar_t) == sizeof(int32_t),
int32_t,
void>::type>::type type;
};
#else
template <> struct make_signed<wchar_t>
{
typedef etl::conditional<sizeof(wchar_t) == sizeof(short), short,
etl::conditional<sizeof(wchar_t) == sizeof(int), int,
etl::conditional<sizeof(wchar_t) == sizeof(long), long, void>::type>::type>::type type;
};
#endif
template <> struct make_signed<unsigned short> { typedef short type; };
template <> struct make_signed<unsigned int> { typedef int type; };
template <> struct make_signed<unsigned long> { typedef long type; };
@ -269,19 +266,16 @@ namespace etl
template <> struct make_unsigned<char> { typedef unsigned char type; };
template <> struct make_unsigned<signed char> { typedef unsigned char type; };
template <> struct make_unsigned<short> { typedef unsigned short type; };
#if defined(ETL_COMPILER_GCC) && !defined(ETL_PLATFORM_LINUX)
template <> struct make_unsigned<wchar_t>
{
typedef wchar_t type;
typedef typename etl::conditional<sizeof(wchar_t) == sizeof(uint16_t),
uint16_t,
etl::conditional<sizeof(wchar_t) == sizeof(uint32_t),
uint32_t,
void>::type>::type type;
};
#else
template <> struct make_unsigned<wchar_t>
{
typedef etl::conditional<sizeof(wchar_t) == sizeof(unsigned short), unsigned short,
etl::conditional<sizeof(wchar_t) == sizeof(unsigned int), unsigned int,
etl::conditional<sizeof(wchar_t) == sizeof(unsigned long), unsigned long, void>::type>::type>::type type;
};
#endif
template <> struct make_unsigned<int> { typedef unsigned int type; };
template <> struct make_unsigned<long> { typedef unsigned long type; };
template <> struct make_unsigned<long long> { typedef unsigned long long type; };

View File

@ -33,6 +33,7 @@ SOFTWARE.
#include "platform.h"
#include "basic_string.h"
#include "hash.h"
#if defined(ETL_COMPILER_MICROSOFT)
#undef min
@ -180,6 +181,19 @@ namespace etl
value_type buffer[MAX_SIZE + 1];
};
//*************************************************************************
/// Hash function.
//*************************************************************************
template <>
struct hash<etl::iu16string>
{
size_t operator()(const etl::iu16string& text) const
{
return etl::__private_hash__::generic_hash<>(reinterpret_cast<const uint8_t*>(&text[0]),
reinterpret_cast<const uint8_t*>(&text[text.size()]));
}
};
}
#if defined(ETL_COMPILER_MICROSOFT)

View File

@ -33,6 +33,7 @@ SOFTWARE.
#include "platform.h"
#include "basic_string.h"
#include "hash.h"
#if defined(ETL_COMPILER_MICROSOFT)
#undef min
@ -180,6 +181,19 @@ namespace etl
value_type buffer[MAX_SIZE + 1];
};
//*************************************************************************
/// Hash function.
//*************************************************************************
template <>
struct hash<etl::iu32string>
{
size_t operator()(const etl::iu32string& text) const
{
return etl::__private_hash__::generic_hash<>(reinterpret_cast<const uint8_t*>(&text[0]),
reinterpret_cast<const uint8_t*>(&text[text.size()]));
}
};
}
#if defined(ETL_COMPILER_MICROSOFT)

74
src/utility.h Normal file
View File

@ -0,0 +1,74 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
http://www.etlcpp.com
Copyright(c) 2016 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_UTILITY__
#define __ETL_UTILITY__
#include "type_traits.h"
///\defgroup utility utility
///\ingroup utilities
namespace etl
{
//***************************************************************************
/// exchange
//***************************************************************************
template <typename T, typename U = T>
T exchange(T& object, U& new_value)
{
T old_value = object;
object = new_value;
return old_value;
}
//***************************************************************************
/// exchange (const)
//***************************************************************************
template <typename T, typename U = T>
T exchange(T& object, const U& new_value)
{
T old_value = object;
object = new_value;
return old_value;
}
//***************************************************************************
/// as_const
//***************************************************************************
template <typename T>
typename etl::add_const<T>::type& as_const(T& t)
{
return t;
}
}
#endif

View File

@ -46,7 +46,7 @@ SOFTWARE.
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 940
#pragma diag_suppress 111
#pragma diag_suppress 111
#endif
#undef ETL_FILE
@ -132,7 +132,7 @@ namespace etl
//***************************************************************************
/// The type used for ids.
//***************************************************************************
typedef uint8_t type_id_t;
typedef uint_least8_t type_id_t;
//***************************************************************************
/// The id a unsupported types.
@ -196,15 +196,15 @@ namespace etl
template <typename T>
struct Type_Id_Lookup
{
static const uint8_t type_id = etl::is_same<T, T1>::value ? 0 :
etl::is_same<T, T2>::value ? 1 :
etl::is_same<T, T3>::value ? 2 :
etl::is_same<T, T4>::value ? 3 :
etl::is_same<T, T5>::value ? 4 :
etl::is_same<T, T6>::value ? 5 :
etl::is_same<T, T7>::value ? 6 :
etl::is_same<T, T8>::value ? 7 :
UNSUPPORTED_TYPE_ID;
static const uint_least8_t type_id = etl::is_same<T, T1>::value ? 0 :
etl::is_same<T, T2>::value ? 1 :
etl::is_same<T, T3>::value ? 2 :
etl::is_same<T, T4>::value ? 3 :
etl::is_same<T, T5>::value ? 4 :
etl::is_same<T, T6>::value ? 5 :
etl::is_same<T, T7>::value ? 6 :
etl::is_same<T, T8>::value ? 7 :
UNSUPPORTED_TYPE_ID;
};
//***************************************************************************
@ -225,6 +225,14 @@ namespace etl
public:
//***************************************************************************
/// Destructor.
//***************************************************************************
~variant()
{
destruct_current();
}
//*************************************************************************
//**** Reader types *******************************************************
//*************************************************************************
@ -424,7 +432,7 @@ namespace etl
{
public:
TBase& operator()(uint8_t* p_data, uint8_t typeId)
TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId)
{
switch (typeId)
{
@ -440,7 +448,7 @@ namespace etl
}
}
const TBase& operator()(uint8_t* p_data, uint8_t typeId) const
const TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) const
{
switch (typeId)
{
@ -465,7 +473,7 @@ namespace etl
{
public:
TBase& operator()(uint8_t* p_data, uint8_t typeId)
TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId)
{
switch (typeId)
{
@ -480,7 +488,7 @@ namespace etl
}
}
const TBase& operator()(uint8_t* p_data, uint8_t typeId) const
const TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) const
{
switch (typeId)
{
@ -504,7 +512,7 @@ namespace etl
{
public:
TBase& operator()(uint8_t* p_data, uint8_t typeId)
TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId)
{
switch (typeId)
{
@ -518,7 +526,7 @@ namespace etl
}
}
const TBase& operator()(uint8_t* p_data, uint8_t typeId) const
const TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) const
{
switch (typeId)
{
@ -541,7 +549,7 @@ namespace etl
{
public:
TBase& operator()(uint8_t* p_data, uint8_t typeId)
TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId)
{
switch (typeId)
{
@ -554,7 +562,7 @@ namespace etl
}
}
const TBase& operator()(uint8_t* p_data, uint8_t typeId) const
const TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) const
{
switch (typeId)
{
@ -576,7 +584,7 @@ namespace etl
{
public:
TBase& operator()(uint8_t* p_data, uint8_t typeId)
TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId)
{
switch (typeId)
{
@ -588,7 +596,7 @@ namespace etl
}
}
const TBase& operator()(uint8_t* p_data, uint8_t typeId) const
const TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) const
{
switch (typeId)
{
@ -609,7 +617,7 @@ namespace etl
{
public:
TBase& operator()(uint8_t* p_data, uint8_t typeId)
TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId)
{
switch (typeId)
{
@ -620,7 +628,7 @@ namespace etl
}
}
const TBase& operator()(uint8_t* p_data, uint8_t typeId) const
const TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) const
{
switch (typeId)
{
@ -640,7 +648,7 @@ namespace etl
{
public:
TBase& operator()(uint8_t* p_data, uint8_t typeId)
TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId)
{
switch (typeId)
{
@ -650,7 +658,7 @@ namespace etl
}
}
const TBase& operator()(uint8_t* p_data, uint8_t typeId) const
const TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) const
{
switch (typeId)
{
@ -669,12 +677,12 @@ namespace etl
{
public:
TBase& operator()(uint8_t* p_data, uint8_t typeId)
TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId)
{
return reinterpret_cast<U1&>(*p_data);
}
const TBase& operator()(uint8_t* p_data, uint8_t typeId) const
const TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) const
{
return reinterpret_cast<const U1&>(*p_data);
}
@ -712,9 +720,21 @@ namespace etl
///\param other The other variant object to copy.
//***************************************************************************
variant(const variant& other)
: data(other.data),
type_id(other.type_id)
{
switch (other.type_id)
{
case 0: new(static_cast<T1*>(data)) T1(other.get<T1>()); break;
case 1: new(static_cast<T2*>(data)) T2(other.get<T2>()); break;
case 2: new(static_cast<T3*>(data)) T3(other.get<T3>()); break;
case 3: new(static_cast<T4*>(data)) T4(other.get<T4>()); break;
case 4: new(static_cast<T5*>(data)) T5(other.get<T5>()); break;
case 5: new(static_cast<T6*>(data)) T6(other.get<T6>()); break;
case 6: new(static_cast<T7*>(data)) T7(other.get<T7>()); break;
case 7: new(static_cast<T8*>(data)) T8(other.get<T8>()); break;
default: break;
}
type_id = other.type_id;
}
//***************************************************************************
@ -726,18 +746,37 @@ namespace etl
{
STATIC_ASSERT(Type_Is_Supported<T>::value, "Unsupported type");
// Assigning the same type as last time?
if (type_id == Type_Id_Lookup<T>::type_id)
destruct_current();
new(static_cast<T*>(data)) T(value);
type_id = Type_Id_Lookup<T>::type_id;
return *this;
}
//***************************************************************************
/// Assignment operator for variant type.
///\param other The variant to assign.
//***************************************************************************
variant& operator =(const variant& other)
{
if (this != &other)
{
// Do a simple copy.
*static_cast<T*>(data) = value;
}
else
{
// We must destruct the old type, as the new one is different.
destruct_current();
new(static_cast<T*>(data)) T(value);
type_id = Type_Id_Lookup<T>::type_id;
switch (other.type_id)
{
case 0: new(static_cast<T1*>(data)) T1(other.get<T1>()); break;
case 1: new(static_cast<T2*>(data)) T2(other.get<T2>()); break;
case 2: new(static_cast<T3*>(data)) T3(other.get<T3>()); break;
case 3: new(static_cast<T4*>(data)) T4(other.get<T4>()); break;
case 4: new(static_cast<T5*>(data)) T5(other.get<T5>()); break;
case 5: new(static_cast<T6*>(data)) T6(other.get<T6>()); break;
case 6: new(static_cast<T7*>(data)) T7(other.get<T7>()); break;
case 7: new(static_cast<T8*>(data)) T8(other.get<T8>()); break;
default: break;
}
type_id = other.type_id;
}
return *this;
@ -915,6 +954,8 @@ namespace etl
case 7: { static_cast<T8*>(data)->~T8(); break; }
default: { break; }
}
type_id = UNSUPPORTED_TYPE_ID;
}
//***************************************************************************

View File

@ -115,6 +115,14 @@ namespace etl
ivector<T>::assign(other.begin(), other.end());
}
//*************************************************************************
/// Destructor.
//*************************************************************************
~vector()
{
ivector<T>::clear();
}
//*************************************************************************
/// Assignment operator.
//*************************************************************************

View File

@ -33,6 +33,7 @@ SOFTWARE.
#include "platform.h"
#include "basic_string.h"
#include "hash.h"
#if defined(ETL_COMPILER_MICROSOFT)
#undef min
@ -181,6 +182,19 @@ namespace etl
value_type buffer[MAX_SIZE + 1];
};
//*************************************************************************
/// Hash function.
//*************************************************************************
template <>
struct hash<etl::iwstring>
{
size_t operator()(const etl::iwstring& text) const
{
return etl::__private_hash__::generic_hash<>(reinterpret_cast<const uint8_t*>(&text[0]),
reinterpret_cast<const uint8_t*>(&text[text.size()]));
}
};
}
#if defined(ETL_COMPILER_MICROSOFT)

View File

@ -19,6 +19,9 @@
<Add option="-DETL_VERBOSE_ERRORS" />
<Add option="-DETL_CHECK_PUSH_POP" />
</Compiler>
<ExtraCommands>
<Add after="${TARGET_OUTPUT_DIR}${TARGET_OUTPUT_BASENAME}" />
</ExtraCommands>
</Target>
<Target title="Linux">
<Option output="bin/Debug/ETL" prefix_auto="1" extension_auto="1" />
@ -34,7 +37,7 @@
<Add option="-DETL_CHECK_PUSH_POP" />
</Compiler>
<ExtraCommands>
<Add after="bin/Debug/ETL" />
<Add after="${TARGET_OUTPUT_DIR}${TARGET_OUTPUT_BASENAME}" />
<Mode after="always" />
</ExtraCommands>
</Target>
@ -84,6 +87,8 @@
<Unit filename="../../../unittest-cpp/UnitTest++/ReportAssert.cpp" />
<Unit filename="../../../unittest-cpp/UnitTest++/ReportAssert.h" />
<Unit filename="../../../unittest-cpp/UnitTest++/ReportAssertImpl.h" />
<Unit filename="../../../unittest-cpp/UnitTest++/RequiredCheckException.cpp" />
<Unit filename="../../../unittest-cpp/UnitTest++/RequiredCheckTestReporter.cpp" />
<Unit filename="../../../unittest-cpp/UnitTest++/Test.cpp" />
<Unit filename="../../../unittest-cpp/UnitTest++/Test.h" />
<Unit filename="../../../unittest-cpp/UnitTest++/TestDetails.cpp" />
@ -100,6 +105,7 @@
<Unit filename="../../../unittest-cpp/UnitTest++/TestRunner.cpp" />
<Unit filename="../../../unittest-cpp/UnitTest++/TestRunner.h" />
<Unit filename="../../../unittest-cpp/UnitTest++/TestSuite.h" />
<Unit filename="../../../unittest-cpp/UnitTest++/ThrowingTestReporter.cpp" />
<Unit filename="../../../unittest-cpp/UnitTest++/TimeConstraint.cpp" />
<Unit filename="../../../unittest-cpp/UnitTest++/TimeConstraint.h" />
<Unit filename="../../../unittest-cpp/UnitTest++/TimeHelpers.h" />
@ -114,6 +120,7 @@
<Unit filename="../../src/algorithm.h" />
<Unit filename="../../src/alignment.h" />
<Unit filename="../../src/array.h" />
<Unit filename="../../src/basic_string.h" />
<Unit filename="../../src/binary.h" />
<Unit filename="../../src/bitset.h" />
<Unit filename="../../src/bloom_filter.h" />
@ -132,8 +139,10 @@
<Unit filename="../../src/crc64_ecma.h" />
<Unit filename="../../src/crc8_ccitt.cpp" />
<Unit filename="../../src/crc8_ccitt.h" />
<Unit filename="../../src/cstring.h" />
<Unit filename="../../src/cyclic_hash.h" />
<Unit filename="../../src/cyclic_value.h" />
<Unit filename="../../src/debounce.h" />
<Unit filename="../../src/deque.h" />
<Unit filename="../../src/endian.h" />
<Unit filename="../../src/enum_type.h" />
@ -172,6 +181,8 @@
<Unit filename="../../src/intrusive_forward_list_link.h" />
<Unit filename="../../src/intrusive_links.h" />
<Unit filename="../../src/intrusive_list.h" />
<Unit filename="../../src/intrusive_queue.h" />
<Unit filename="../../src/intrusive_stack.h" />
<Unit filename="../../src/io_port.h" />
<Unit filename="../../src/ipool.h" />
<Unit filename="../../src/ipriority_queue.h" />
@ -183,6 +194,7 @@
<Unit filename="../../src/iunordered_multiset.h" />
<Unit filename="../../src/iunordered_set.h" />
<Unit filename="../../src/ivector.h" />
<Unit filename="../../src/ivectorpointer.h" />
<Unit filename="../../src/jenkins.h" />
<Unit filename="../../src/largest.h" />
<Unit filename="../../src/list.h" />
@ -202,6 +214,7 @@
<Unit filename="../../src/pool.h" />
<Unit filename="../../src/power.h" />
<Unit filename="../../src/priority_queue.h" />
<Unit filename="../../src/private/pvoidvector.cpp" />
<Unit filename="../../src/queue.h" />
<Unit filename="../../src/radix.h" />
<Unit filename="../../src/set.h" />
@ -215,14 +228,19 @@
<Unit filename="../../src/test2.h">
<Option target="Windows" />
</Unit>
<Unit filename="../../src/type_def.h" />
<Unit filename="../../src/type_traits.h" />
<Unit filename="../../src/u16string.h" />
<Unit filename="../../src/u32string.h" />
<Unit filename="../../src/unordered_map.h" />
<Unit filename="../../src/unordered_multimap.h" />
<Unit filename="../../src/unordered_multiset.h" />
<Unit filename="../../src/unordered_set.h" />
<Unit filename="../../src/utility.h" />
<Unit filename="../../src/variant.h" />
<Unit filename="../../src/vector.h" />
<Unit filename="../../src/visitor.h" />
<Unit filename="../../src/wstring.h" />
<Unit filename="../ExtraCheckMacros.h" />
<Unit filename="../data.h" />
<Unit filename="../main.cpp" />
@ -239,6 +257,7 @@
<Unit filename="../test_container.cpp" />
<Unit filename="../test_crc.cpp" />
<Unit filename="../test_cyclic_value.cpp" />
<Unit filename="../test_debounce.cpp" />
<Unit filename="../test_deque.cpp" />
<Unit filename="../test_endian.cpp" />
<Unit filename="../test_enum_type.cpp" />
@ -259,6 +278,8 @@
<Unit filename="../test_intrusive_forward_list.cpp" />
<Unit filename="../test_intrusive_links.cpp" />
<Unit filename="../test_intrusive_list.cpp" />
<Unit filename="../test_intrusive_queue.cpp" />
<Unit filename="../test_intrusive_stack.cpp" />
<Unit filename="../test_io_port.cpp" />
<Unit filename="../test_jenkins.cpp" />
<Unit filename="../test_largest.cpp" />
@ -278,13 +299,20 @@
<Unit filename="../test_set.cpp" />
<Unit filename="../test_smallest.cpp" />
<Unit filename="../test_stack.cpp" />
<Unit filename="../test_string_char.cpp" />
<Unit filename="../test_string_u16.cpp" />
<Unit filename="../test_string_u32.cpp" />
<Unit filename="../test_string_wchar_t.cpp" />
<Unit filename="../test_type_def.cpp" />
<Unit filename="../test_type_traits.cpp" />
<Unit filename="../test_unordered_map.cpp" />
<Unit filename="../test_unordered_multimap.cpp" />
<Unit filename="../test_unordered_multiset.cpp" />
<Unit filename="../test_unordered_set.cpp" />
<Unit filename="../test_utility.cpp" />
<Unit filename="../test_variant.cpp" />
<Unit filename="../test_vector.cpp" />
<Unit filename="../test_vector_pointer.cpp" />
<Unit filename="../test_visitor.cpp" />
<Unit filename="../test_xor_checksum.cpp" />
<Extensions>

File diff suppressed because it is too large Load Diff

View File

@ -1,355 +1,419 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Windows" />
<File name="..\..\..\unittest-cpp\UnitTest++\Config.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<ActiveTarget name="Linux" />
<File name="../../src/iflat_multimap.h" open="1" top="0" tabpos="27" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="792" topLine="7" />
<Cursor1 position="9858" topLine="204" />
</Cursor>
</File>
<File name="..\..\src\crc64_ecma.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3458" topLine="44" />
</Cursor>
</File>
<File name="..\test_set.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5885" topLine="199" />
</Cursor>
</File>
<File name="..\..\src\imultimap.h" open="0" top="0" tabpos="16" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="24110" topLine="684" />
</Cursor>
</File>
<File name="..\..\src\bloom_filter.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3800" topLine="75" />
</Cursor>
</File>
<File name="..\..\src\intrusive_list.h" open="0" top="0" tabpos="15" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="34228" topLine="1040" />
</Cursor>
</File>
<File name="..\test_list.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="9856" topLine="244" />
</Cursor>
</File>
<File name="..\test_binary.cpp" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1534" topLine="0" />
</Cursor>
</File>
<File name="..\..\src\binary.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="19509" topLine="464" />
</Cursor>
</File>
<File name="..\..\src\intrusive_links.h" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="8444" topLine="117" />
</Cursor>
</File>
<File name="..\..\..\unittest-cpp\UnitTest++\Test.cpp" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="662" topLine="0" />
</Cursor>
</File>
<File name="..\..\..\unittest-cpp\UnitTest++\TestMacros.h" open="0" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1865" topLine="28" />
</Cursor>
</File>
<File name="..\..\src\ideque.h" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="9257" topLine="291" />
</Cursor>
</File>
<File name="..\..\src\algorithm.h" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1652" topLine="12" />
</Cursor>
</File>
<File name="..\..\src\multiset.h" open="0" top="0" tabpos="18" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2054" topLine="21" />
</Cursor>
</File>
<File name="..\test_bloom_filter.cpp" open="0" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="6486" topLine="208" />
</Cursor>
</File>
<File name="..\..\src\crc16.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3363" topLine="44" />
</Cursor>
</File>
<File name="..\test_map.cpp" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4405" topLine="112" />
</Cursor>
</File>
<File name="..\..\src\crc16_kermit.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3458" topLine="44" />
</Cursor>
</File>
<File name="..\..\src\variant.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="36593" topLine="842" />
</Cursor>
</File>
<File name="..\test_array.cpp" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1346" topLine="0" />
</Cursor>
</File>
<File name="..\..\src\vector.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3110" topLine="24" />
</Cursor>
</File>
<File name="..\..\..\unittest-cpp\UnitTest++\TestRunner.cpp" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2020" topLine="25" />
</Cursor>
</File>
<File name="..\..\src\pearson.h" open="0" top="0" tabpos="19" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4475" topLine="108" />
</Cursor>
</File>
<File name="..\..\src\imultiset.h" open="0" top="0" tabpos="17" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="23623" topLine="665" />
</Cursor>
</File>
<File name="..\..\..\unittest-cpp\UnitTest++\ExecuteTest.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1247" topLine="2" />
</Cursor>
</File>
<File name="..\..\src\iqueue.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5008" topLine="60" />
</Cursor>
</File>
<File name="..\test_bitset.cpp" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="20468" topLine="697" />
</Cursor>
</File>
<File name="..\..\src\test1.h" open="1" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4" topLine="0" />
</Cursor>
</File>
<File name="..\..\src\crc8_ccitt.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2436" topLine="15" />
</Cursor>
</File>
<File name="..\..\src\intrusive_forward_list.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="35062" topLine="1044" />
</Cursor>
</File>
<File name="..\..\src\frame_check_sequence.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="76" />
</Cursor>
</File>
<File name="..\test_hash.cpp" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4733" topLine="114" />
</Cursor>
</File>
<File name="..\..\src\optional.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="8753" topLine="220" />
</Cursor>
</File>
<File name="..\test_variant.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="11763" topLine="384" />
</Cursor>
</File>
<File name="..\..\src\imap.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="22839" topLine="636" />
</Cursor>
</File>
<File name="..\test_vector.cpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../test_vector.cpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="9922" topLine="258" />
</Cursor>
</File>
<File name="..\..\src\istack.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../../../unittest-cpp/UnitTest++/TestMacros.h" open="0" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2266" topLine="38" />
<Cursor1 position="1865" topLine="28" />
</Cursor>
</File>
<File name="..\..\src\crc16_ccitt.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3464" topLine="44" />
</Cursor>
</File>
<File name="..\test_alignment.cpp" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1554" topLine="0" />
</Cursor>
</File>
<File name="..\..\src\observer.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4997" topLine="66" />
</Cursor>
</File>
<File name="..\..\src\iunordered_map.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="25812" topLine="704" />
</Cursor>
</File>
<File name="..\..\..\unittest-cpp\UnitTest++\Win32\TimeHelpers.cpp" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="257" topLine="0" />
</Cursor>
</File>
<File name="..\..\src\ivector.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="10520" topLine="236" />
</Cursor>
</File>
<File name="..\test_algorithm.cpp" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1524" topLine="0" />
</Cursor>
</File>
<File name="..\..\src\checksum.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="6114" topLine="139" />
</Cursor>
</File>
<File name="..\test_error_handler.cpp" open="0" top="0" tabpos="14" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2501" topLine="42" />
</Cursor>
</File>
<File name="..\test_fnv_1.cpp" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1767" topLine="0" />
</Cursor>
</File>
<File name="..\..\src\crc32.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3389" topLine="44" />
</Cursor>
</File>
<File name="..\..\src\test2.h" open="1" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="98" topLine="0" />
</Cursor>
</File>
<File name="..\test_io_port.cpp" open="0" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2392" topLine="58" />
</Cursor>
</File>
<File name="..\test_integral_limits.cpp" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1416" topLine="13" />
</Cursor>
</File>
<File name="..\..\src\platform.h" open="1" top="1" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1716" topLine="0" />
</Cursor>
</File>
<File name="..\test_exception.cpp" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2419" topLine="15" />
</Cursor>
</File>
<File name="..\..\..\unittest-cpp\UnitTest++\TestRunner.h" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="692" topLine="0" />
</Cursor>
</File>
<File name="..\..\src\ilist.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="16337" topLine="489" />
</Cursor>
</File>
<File name="..\test_pool.cpp" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4944" topLine="150" />
</Cursor>
</File>
<File name="..\test_bsd_checksum.cpp" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1752" topLine="24" />
</Cursor>
</File>
<File name="..\test_optional.cpp" open="0" top="0" tabpos="23" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3050" topLine="59" />
</Cursor>
</File>
<File name="..\test_deque.cpp" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../test_deque.cpp" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="25407" topLine="743" />
</Cursor>
</File>
<File name="..\..\src\ipool.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../test_error_handler.cpp" open="0" top="0" tabpos="14" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="12290" topLine="320" />
<Cursor1 position="2501" topLine="42" />
</Cursor>
</File>
<File name="..\..\src\type_traits.h" open="1" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../../../unittest-cpp/UnitTest++/Config.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
<Cursor1 position="792" topLine="7" />
</Cursor>
</File>
<File name="..\test_type_traits.cpp" open="0" top="0" tabpos="20" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../../../unittest-cpp/UnitTest++/TestReporterStdout.cpp" open="0" top="0" tabpos="25" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="30352" topLine="381" />
<Cursor1 position="883" topLine="0" />
</Cursor>
</File>
<File name="..\test_forward_list.cpp" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../../src/frame_check_sequence.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3941" topLine="77" />
<Cursor1 position="0" topLine="76" />
</Cursor>
</File>
<File name="..\..\src\iset.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../../src/imultiset.h" open="0" top="0" tabpos="17" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="20665" topLine="581" />
<Cursor1 position="23623" topLine="665" />
</Cursor>
</File>
<File name="..\..\..\unittest-cpp\UnitTest++\Checks.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../test_bsd_checksum.cpp" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1752" topLine="24" />
</Cursor>
</File>
<File name="../../src/istack.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2266" topLine="38" />
</Cursor>
</File>
<File name="../test_string_char.cpp" open="1" top="0" tabpos="17" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="107350" topLine="2964" />
</Cursor>
</File>
<File name="../../src/test1.h" open="1" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4" topLine="0" />
</Cursor>
</File>
<File name="../../src/imap.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="22839" topLine="636" />
</Cursor>
</File>
<File name="../../src/array.h" open="1" top="0" tabpos="23" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4314" topLine="78" />
</Cursor>
</File>
<File name="../../../unittest-cpp/UnitTest++/Checks.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="469" topLine="0" />
</Cursor>
</File>
<File name="..\test_intrusive_forward_list.cpp" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../test_forward_list.cpp" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="22881" topLine="590" />
<Cursor1 position="3941" topLine="77" />
</Cursor>
</File>
<File name="..\..\src\nullptr.h" open="1" top="0" tabpos="14" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../../src/iqueue.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5008" topLine="60" />
</Cursor>
</File>
<File name="../test_variant.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="11763" topLine="384" />
</Cursor>
</File>
<File name="../test_binary.cpp" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1534" topLine="0" />
</Cursor>
</File>
<File name="../../src/checksum.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="6114" topLine="139" />
</Cursor>
</File>
<File name="../../src/crc32.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3389" topLine="44" />
</Cursor>
</File>
<File name="../../src/ideque.h" open="1" top="0" tabpos="24" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="37812" topLine="1110" />
</Cursor>
</File>
<File name="../test_intrusive_list.cpp" open="1" top="0" tabpos="15" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="33210" topLine="873" />
</Cursor>
</File>
<File name="../test_bloom_filter.cpp" open="0" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="6486" topLine="208" />
</Cursor>
</File>
<File name="../../src/binary.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="19509" topLine="464" />
</Cursor>
</File>
<File name="../../src/variant.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="36593" topLine="842" />
</Cursor>
</File>
<File name="../../src/multiset.h" open="0" top="0" tabpos="18" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2054" topLine="21" />
</Cursor>
</File>
<File name="../../src/nullptr.h" open="1" top="0" tabpos="14" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2454" topLine="10" />
</Cursor>
</File>
<File name="..\test_queue.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../../src/optional.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="8753" topLine="220" />
</Cursor>
</File>
<File name="../../src/iforward_list.h" open="1" top="0" tabpos="30" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="13854" topLine="410" />
</Cursor>
</File>
<File name="../test_fnv_1.cpp" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1767" topLine="0" />
</Cursor>
</File>
<File name="../../src/iflat_set.h" open="1" top="0" tabpos="29" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="9048" topLine="182" />
</Cursor>
</File>
<File name="../../src/crc16_kermit.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3458" topLine="44" />
</Cursor>
</File>
<File name="../test_algorithm.cpp" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1524" topLine="0" />
</Cursor>
</File>
<File name="../test_exception.cpp" open="1" top="0" tabpos="25" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1446" topLine="15" />
</Cursor>
</File>
<File name="../../../unittest-cpp/UnitTest++/CurrentTest.cpp" open="0" top="0" tabpos="26" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="368" topLine="0" />
</Cursor>
</File>
<File name="../test_map.cpp" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4405" topLine="112" />
</Cursor>
</File>
<File name="../../src/intrusive_links.h" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="8444" topLine="117" />
</Cursor>
</File>
<File name="../test_optional.cpp" open="0" top="0" tabpos="23" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3050" topLine="59" />
</Cursor>
</File>
<File name="../../../unittest-cpp/UnitTest++/TestRunner.h" open="1" top="0" tabpos="21" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="156" topLine="0" />
</Cursor>
</File>
<File name="../test_hash.cpp" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4733" topLine="114" />
</Cursor>
</File>
<File name="../../src/vector.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3110" topLine="24" />
</Cursor>
</File>
<File name="../test_type_traits.cpp" open="1" top="1" tabpos="31" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="32554" topLine="432" />
</Cursor>
</File>
<File name="../test_string_u16.cpp" open="0" top="0" tabpos="23" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3121" topLine="57" />
</Cursor>
</File>
<File name="../../../unittest-cpp/UnitTest++/TestRunner.cpp" open="1" top="0" tabpos="20" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2279" topLine="25" />
</Cursor>
</File>
<File name="../test_stack.cpp" open="1" top="0" tabpos="22" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3081" topLine="53" />
</Cursor>
</File>
<File name="../../src/crc16_ccitt.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3464" topLine="44" />
</Cursor>
</File>
<File name="../test_integral_limits.cpp" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1416" topLine="13" />
</Cursor>
</File>
<File name="../test_bitset.cpp" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="20468" topLine="697" />
</Cursor>
</File>
<File name="../../../unittest-cpp/UnitTest++/ExecuteTest.h" open="1" top="0" tabpos="18" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="426" topLine="0" />
</Cursor>
</File>
<File name="../test_intrusive_forward_list.cpp" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="30469" topLine="772" />
</Cursor>
</File>
<File name="../../src/ivector.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="10520" topLine="236" />
</Cursor>
</File>
<File name="../../src/type_traits.h" open="1" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="14568" topLine="285" />
</Cursor>
</File>
<File name="../../src/pearson.h" open="0" top="0" tabpos="19" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4475" topLine="108" />
</Cursor>
</File>
<File name="../../src/ilist.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="16337" topLine="489" />
</Cursor>
</File>
<File name="../../src/intrusive_forward_list.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="33277" topLine="978" />
</Cursor>
</File>
<File name="../../src/observer.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4997" topLine="66" />
</Cursor>
</File>
<File name="../test_alignment.cpp" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1554" topLine="0" />
</Cursor>
</File>
<File name="../../src/iset.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="20665" topLine="581" />
</Cursor>
</File>
<File name="../../src/intrusive_list.h" open="1" top="0" tabpos="16" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="9297" topLine="313" />
</Cursor>
</File>
<File name="../../src/iflat_map.h" open="1" top="0" tabpos="26" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="11795" topLine="260" />
</Cursor>
</File>
<File name="../../src/bloom_filter.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3800" topLine="75" />
</Cursor>
</File>
<File name="../../src/algorithm.h" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1652" topLine="12" />
</Cursor>
</File>
<File name="../../../unittest-cpp/UnitTest++/Win32/TimeHelpers.cpp" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="103" topLine="6" />
</Cursor>
</File>
<File name="../test_array.cpp" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1346" topLine="0" />
</Cursor>
</File>
<File name="../../../unittest-cpp/UnitTest++/TestResults.cpp" open="0" top="0" tabpos="24" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="537" topLine="0" />
</Cursor>
</File>
<File name="../test_set.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5885" topLine="199" />
</Cursor>
</File>
<File name="../test_pool.cpp" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4944" topLine="150" />
</Cursor>
</File>
<File name="../../src/ipool.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="12290" topLine="320" />
</Cursor>
</File>
<File name="../../src/imultimap.h" open="0" top="0" tabpos="16" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="24110" topLine="684" />
</Cursor>
</File>
<File name="../../src/iflat_multiset.h" open="1" top="0" tabpos="28" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="9256" topLine="182" />
</Cursor>
</File>
<File name="../test_queue.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1603" topLine="28" />
</Cursor>
</File>
<File name="..\test_cyclic_value.cpp" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../../src/test2.h" open="1" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="98" topLine="0" />
</Cursor>
</File>
<File name="../../src/crc64_ecma.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3458" topLine="44" />
</Cursor>
</File>
<File name="../test_io_port.cpp" open="0" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2392" topLine="58" />
</Cursor>
</File>
<File name="../test_cyclic_value.cpp" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1365" topLine="12" />
</Cursor>
</File>
<File name="../../src/crc16.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3363" topLine="44" />
</Cursor>
</File>
<File name="../../src/platform.h" open="1" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1356" topLine="30" />
</Cursor>
</File>
<File name="../../../unittest-cpp/UnitTest++/Test.cpp" open="1" top="0" tabpos="19" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="699" topLine="0" />
</Cursor>
</File>
<File name="../../src/iunordered_map.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="25812" topLine="704" />
</Cursor>
</File>
<File name="../../src/crc8_ccitt.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2436" topLine="15" />
</Cursor>
</File>
<File name="../test_list.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="9856" topLine="244" />
</Cursor>
</File>
</CodeBlocks_layout_file>

View File

@ -40,7 +40,7 @@ class TestDataDC
public:
TestDataDC()
: value(T())
: value(T())
{
}
@ -90,7 +90,7 @@ class TestDataNDC
public:
TestDataNDC()
: value(T())
: value(T())
{}
TestDataNDC(const T& value)

View File

@ -7,7 +7,7 @@
// compile and run any of them on any platform, but your performance with the
// non-native version will be less than optimal.
#include "MurmurHash3.h"
#include "murmurhash3.h"
//-----------------------------------------------------------------------------
// Platform-specific functions and macros

View File

@ -36,7 +36,7 @@ SOFTWARE.
#include <string>
#include <ostream>
void f(int a)
void f(int)
{
}

View File

@ -432,6 +432,8 @@ namespace
bool bc = ~compare[3];
bool bd = ~data[3];
CHECK_EQUAL(bc, bd);
for (size_t i = 0; i < data.size(); ++i)
{
CHECK_EQUAL(compare.test(i), data.test(i));
@ -593,7 +595,7 @@ namespace
etl::bitset<60> data2(0x23456789);
etl::bitset<60> data3(0x12345678 & 0x23456789);
etl::bitset<60>& rdata = data2 &= data1;
data2 &= data1;
CHECK(data2 == data3);
}
@ -616,7 +618,7 @@ namespace
etl::bitset<60> data2(0x23456789);
etl::bitset<60> data3(0x12345678 | 0x23456789);
etl::bitset<60>& rdata = data2 |= data1;
data2 |= data1;
CHECK(data2 == data3);
}
@ -639,7 +641,7 @@ namespace
etl::bitset<60> data2(0x23456789);
etl::bitset<60> data3(0x12345678 ^ 0x23456789);
etl::bitset<60>& rdata = data2 ^= data1;
data2 ^= data1;
CHECK(data2 == data3);
}
@ -723,32 +725,32 @@ namespace
etl::bitset<6> data;
data.set("000000");
CHECK_EQUAL(0, data.find_first(false));
CHECK_EQUAL(0U, data.find_first(false));
CHECK_EQUAL(etl::ibitset::npos, data.find_first(true));
data.set("111111");
CHECK_EQUAL(etl::ibitset::npos, data.find_first(false));
CHECK_EQUAL(0, data.find_first(true));
CHECK_EQUAL(0U, data.find_first(true));
data.set("000001");
CHECK_EQUAL(1, data.find_first(false));
CHECK_EQUAL(0, data.find_first(true));
CHECK_EQUAL(1U, data.find_first(false));
CHECK_EQUAL(0U, data.find_first(true));
data.set("100000");
CHECK_EQUAL(0, data.find_first(false));
CHECK_EQUAL(5, data.find_first(true));
CHECK_EQUAL(0U, data.find_first(false));
CHECK_EQUAL(5U, data.find_first(true));
data.set("100001");
CHECK_EQUAL(1, data.find_first(false));
CHECK_EQUAL(0, data.find_first(true));
CHECK_EQUAL(1U, data.find_first(false));
CHECK_EQUAL(0U, data.find_first(true));
data.set("001110");
CHECK_EQUAL(0, data.find_first(false));
CHECK_EQUAL(1, data.find_first(true));
CHECK_EQUAL(0U, data.find_first(false));
CHECK_EQUAL(1U, data.find_first(true));
data.set("110001");
CHECK_EQUAL(1, data.find_first(false));
CHECK_EQUAL(0, data.find_first(true));
CHECK_EQUAL(1U, data.find_first(false));
CHECK_EQUAL(0U, data.find_first(true));
}
//*************************************************************************
@ -757,24 +759,24 @@ namespace
etl::bitset<6> data;
data.set("000000");
CHECK_EQUAL(0, data.find_next(false, 0));
CHECK_EQUAL(1, data.find_next(false, 1));
CHECK_EQUAL(0U, data.find_next(false, 0));
CHECK_EQUAL(1U, data.find_next(false, 1));
CHECK_EQUAL(etl::ibitset::npos, data.find_next(true, 2));
data.set("111111");
CHECK_EQUAL(0, data.find_next(true, 0));
CHECK_EQUAL(1, data.find_next(true, 1));
CHECK_EQUAL(0U, data.find_next(true, 0));
CHECK_EQUAL(1U, data.find_next(true, 1));
CHECK_EQUAL(etl::ibitset::npos, data.find_next(false, 2));
data.set("001110");
CHECK_EQUAL(0, data.find_next(false, 0));
CHECK_EQUAL(1, data.find_next(true, 0));
CHECK_EQUAL(4, data.find_next(false, 1));
CHECK_EQUAL(0U, data.find_next(false, 0));
CHECK_EQUAL(1U, data.find_next(true, 0));
CHECK_EQUAL(4U, data.find_next(false, 1));
data.set("110001");
CHECK_EQUAL(0, data.find_next(true, 0));
CHECK_EQUAL(1, data.find_next(false, 0));
CHECK_EQUAL(4, data.find_next(true, 1));
CHECK_EQUAL(0U, data.find_next(true, 0));
CHECK_EQUAL(1U, data.find_next(false, 0));
CHECK_EQUAL(4U, data.find_next(true, 1));
}

View File

@ -28,8 +28,8 @@ SOFTWARE.
#include <UnitTest++/UnitTest++.h>
#include <stdlib.h>
#include <vector>
#include <string.h>
#include "../src/bloom_filter.h"
@ -38,13 +38,15 @@ SOFTWARE.
#include "../src/crc16_ccitt.h"
#include "../src/crc32.h"
#include "../src/char_traits.h"
struct hash1_t
{
typedef const char* argument_type;
size_t operator ()(argument_type text) const
{
return etl::fnv_1a_32(text, text + strlen(text));
return etl::fnv_1a_32(text, text + etl::char_traits<char>::length(text));
}
};
@ -54,7 +56,7 @@ struct hash2_t
size_t operator ()(argument_type text) const
{
return etl::crc32(text, text + strlen(text));
return etl::crc32(text, text + etl::char_traits<char>::length(text));
}
};
@ -64,7 +66,7 @@ struct hash3_t
size_t operator ()(argument_type text) const
{
return etl::crc16(text, text + strlen(text)) | (etl::crc16_ccitt(text, text + strlen(text)) << 16);
return etl::crc16(text, text + etl::char_traits<char>::length(text)) | (etl::crc16_ccitt(text, text + etl::char_traits<char>::length(text)) << 16);
}
};
@ -106,7 +108,7 @@ namespace
CHECK(!any_exist);
size_t usage = bloom.usage();
CHECK(usage >= 0);
CHECK(usage > 0);
CHECK(usage < 100);
size_t count = bloom.count();
@ -145,7 +147,6 @@ namespace
CHECK(!any_exist);
size_t usage = bloom.usage();
CHECK(usage >= 0);
CHECK(usage < 100);
size_t count = bloom.count();
@ -184,7 +185,6 @@ namespace
CHECK(!any_exist);
size_t usage = bloom.usage();
CHECK(usage >= 0);
CHECK(usage < 100);
size_t count = bloom.count();

View File

@ -40,10 +40,6 @@ namespace
{
etl::exception e("An exception", "Some file", 123);
std::string what(e.what());
std::string file(e.file_name());
int line(e.line_number());
CHECK_EQUAL(std::string("An exception"), std::string(e.what()));
CHECK_EQUAL(std::string("Some file"), std::string(e.file_name()));
CHECK_EQUAL(123, e.line_number());
@ -60,14 +56,10 @@ namespace
}
catch (etl::exception& c)
{
std::string what(c.what());
std::string file(c.file_name());
int line(c.line_number());
CHECK_EQUAL(std::string("An exception"), std::string(c.what()));
CHECK_EQUAL(std::string("Some file"), std::string(c.file_name()));
CHECK_EQUAL(123, c.line_number());
}
}
};
}
}

View File

@ -46,7 +46,7 @@ namespace
uint32_t hash = etl::fnv_1_32(data.begin(), data.end());
CHECK_EQUAL(0x24148816, hash);
CHECK_EQUAL(0x24148816U, hash);
}
//*************************************************************************
@ -63,7 +63,7 @@ namespace
uint32_t hash = fnv_1_32_calculator.value();
CHECK_EQUAL(0x24148816, hash);
CHECK_EQUAL(0x24148816U, hash);
}
//*************************************************************************
@ -77,7 +77,7 @@ namespace
uint32_t hash = fnv_1_32_calculator.value();
CHECK_EQUAL(0x24148816, hash);
CHECK_EQUAL(0x24148816U, hash);
}
//*************************************************************************
@ -102,7 +102,7 @@ namespace
uint32_t hash = etl::fnv_1a_32(data.begin(), data.end());
CHECK_EQUAL(0xBB86B11C, hash);
CHECK_EQUAL(0xBB86B11CU, hash);
}
//*************************************************************************
@ -119,7 +119,7 @@ namespace
uint32_t hash = fnv_1a_32_calculator.value();
CHECK_EQUAL(0xBB86B11C, hash);
CHECK_EQUAL(0xBB86B11CU, hash);
}
//*************************************************************************
@ -133,7 +133,7 @@ namespace
uint32_t hash = fnv_1a_32_calculator.value();
CHECK_EQUAL(0xBB86B11C, hash);
CHECK_EQUAL(0xBB86B11CU, hash);
}
//*************************************************************************
@ -158,7 +158,7 @@ namespace
uint64_t hash = etl::fnv_1_64(data.begin(), data.end());
CHECK_EQUAL(0xA72FFC362BF916D6, hash);
CHECK_EQUAL(0xA72FFC362BF916D6U, hash);
}
//*************************************************************************
@ -175,7 +175,7 @@ namespace
uint64_t hash = fnv_1_64_calculator;
CHECK_EQUAL(0xA72FFC362BF916D6, hash);
CHECK_EQUAL(0xA72FFC362BF916D6U, hash);
}
//*************************************************************************
@ -189,7 +189,7 @@ namespace
uint64_t hash = fnv_1_64_calculator.value();
CHECK_EQUAL(0xA72FFC362BF916D6, hash);
CHECK_EQUAL(0xA72FFC362BF916D6U, hash);
}
//*************************************************************************
@ -214,7 +214,7 @@ namespace
uint64_t hash = etl::fnv_1a_64(data.begin(), data.end());
CHECK_EQUAL(0x06D5573923C6CDFC, hash);
CHECK_EQUAL(0x06D5573923C6CDFCU, hash);
}
//*************************************************************************
@ -231,7 +231,7 @@ namespace
uint64_t hash = fnv_1a_64_calculator;
CHECK_EQUAL(0x06D5573923C6CDFC, hash);
CHECK_EQUAL(0x06D5573923C6CDFCU, hash);
}
//*************************************************************************
@ -245,7 +245,7 @@ namespace
uint64_t hash = fnv_1a_64_calculator.value();
CHECK_EQUAL(0x06D5573923C6CDFC, hash);
CHECK_EQUAL(0x06D5573923C6CDFCU, hash);
}
//*************************************************************************

View File

@ -423,7 +423,7 @@ namespace
CHECK_NO_THROW(data.push_front(ItemNDC("5")));
CHECK_NO_THROW(data.push_front(ItemNDC("6")));
CHECK_EQUAL(6, data.size());
CHECK_EQUAL(6U, data.size());
CHECK_EQUAL(6, std::distance(data.begin(), data.end()));
are_equal = std::equal(data.begin(), data.end(), compare_data.begin());
@ -457,7 +457,7 @@ namespace
CHECK_NO_THROW(data.push_front());
data.front() = ItemNDC("6");
CHECK_EQUAL(6, data.size());
CHECK_EQUAL(6U, data.size());
CHECK_EQUAL(6, std::distance(data.begin(), data.end()));
are_equal = std::equal(data.begin(), data.end(), compare_data.begin());

View File

@ -43,10 +43,10 @@ namespace
TEST(test_hash_bool)
{
size_t hash = etl::hash<bool>()(false);
CHECK_EQUAL(0, hash);
CHECK_EQUAL(0U, hash);
hash = etl::hash<bool>()(true);
CHECK_EQUAL(1, hash);
CHECK_EQUAL(1U, hash);
}
//*************************************************************************
@ -54,7 +54,7 @@ namespace
{
size_t hash = etl::hash<char>()((char)(0x5A));
CHECK_EQUAL(0x5A, hash);
CHECK_EQUAL(0x5AU, hash);
}
//*************************************************************************
@ -62,7 +62,7 @@ namespace
{
size_t hash = etl::hash<signed char>()((signed char)(0x5A));
CHECK_EQUAL(0x5A, hash);
CHECK_EQUAL(0x5AU, hash);
}
//*************************************************************************
@ -70,7 +70,7 @@ namespace
{
size_t hash = etl::hash<unsigned char>()((unsigned char)(0x5A));
CHECK_EQUAL(0x5A, hash);
CHECK_EQUAL(0x5AU, hash);
}
//*************************************************************************
@ -78,7 +78,7 @@ namespace
{
size_t hash = etl::hash<short>()((short)(0x5AA5));
CHECK_EQUAL(0x5AA5, hash);
CHECK_EQUAL(0x5AA5U, hash);
}
//*************************************************************************
@ -86,7 +86,7 @@ namespace
{
size_t hash = etl::hash<unsigned short>()((unsigned short)(0x5AA5));
CHECK_EQUAL(0x5AA5, hash);
CHECK_EQUAL(0x5AA5U, hash);
}
//*************************************************************************
@ -94,7 +94,7 @@ namespace
{
size_t hash = etl::hash<int>()((int)(0x5AA555AA));
CHECK_EQUAL(0x5AA555AA, hash);
CHECK_EQUAL(0x5AA555AAU, hash);
}
//*************************************************************************
@ -102,7 +102,7 @@ namespace
{
size_t hash = etl::hash<unsigned int>()((unsigned int)(0x5AA555AA));
CHECK_EQUAL(0x5AA555AA, hash);
CHECK_EQUAL(0x5AA555AAU, hash);
}
//*************************************************************************
@ -110,7 +110,7 @@ namespace
{
size_t hash = etl::hash<long>()((long)(0x5AA555AA));
CHECK_EQUAL(0x5AA555AA, hash);
CHECK_EQUAL(0x5AA555AAU, hash);
}
//*************************************************************************
@ -118,7 +118,7 @@ namespace
{
size_t hash = etl::hash<unsigned long>()((unsigned long)(0x5AA555AA));
CHECK_EQUAL(0x5AA555AA, hash);
CHECK_EQUAL(0x5AA555AAU, hash);
}
//*************************************************************************
@ -127,9 +127,9 @@ namespace
size_t hash = etl::hash<long long>()((long long)(0x5AA555AA3CC333CC));
if (sizeof(size_t) == sizeof(long long))
CHECK_EQUAL(0x5AA555AA3CC333CC, hash);
CHECK_EQUAL(0x5AA555AA3CC333CCU, hash);
else
CHECK_EQUAL(0xEC6A8D69, hash);
CHECK_EQUAL(0xEC6A8D69U, hash);
}
//*************************************************************************
@ -138,9 +138,9 @@ namespace
size_t hash = etl::hash<unsigned long long>()((unsigned long long)(0x5AA555AA3CC333CC));
if (sizeof(size_t) == sizeof(unsigned long long))
CHECK_EQUAL(0x5AA555AA3CC333CC, hash);
CHECK_EQUAL(0x5AA555AA3CC333CCU, hash);
else
CHECK_EQUAL(0xEC6A8D69, hash);
CHECK_EQUAL(0xEC6A8D69U, hash);
}
//*************************************************************************
@ -148,7 +148,7 @@ namespace
{
size_t hash = etl::hash<float>()((float)(1.2345));
CHECK_EQUAL(0X3F9E0419, hash);
CHECK_EQUAL(0X3F9E0419U, hash);
}
//*************************************************************************
@ -157,9 +157,9 @@ namespace
size_t hash = etl::hash<double>()((double)(1.2345));
if (sizeof(size_t) == sizeof(double))
CHECK_EQUAL(0X3FF3C083126E978D, hash);
CHECK_EQUAL(0X3FF3C083126E978DU, hash);
else
CHECK_EQUAL(0x86FBF224, hash);
CHECK_EQUAL(0x86FBF224U, hash);
}
//*************************************************************************

View File

@ -47,25 +47,25 @@ namespace
struct Test2 : public etl::instance_count<Test2>
{};
CHECK_EQUAL(0, Test1::get_instance_count());
CHECK_EQUAL(0, Test2::get_instance_count());
CHECK_EQUAL(0U, Test1::get_instance_count());
CHECK_EQUAL(0U, Test2::get_instance_count());
//Test1 test1a;
//CHECK_EQUAL(1, Test1::get_instance_count());
//CHECK_EQUAL(0, Test2::get_instance_count());
Test1 test1a;
CHECK_EQUAL(1U, Test1::get_instance_count());
CHECK_EQUAL(0U, Test2::get_instance_count());
//Test1 test1b;
//Test2 test2a;
//CHECK_EQUAL(2, Test1::get_instance_count());
//CHECK_EQUAL(1, Test2::get_instance_count());
Test1 test1b;
Test2 test2a;
CHECK_EQUAL(2U, Test1::get_instance_count());
CHECK_EQUAL(1U, Test2::get_instance_count());
//Test2* ptest2b = new Test2;
//CHECK_EQUAL(2, Test1::get_instance_count());
//CHECK_EQUAL(2, Test2::get_instance_count());
Test2* ptest2b = new Test2;
CHECK_EQUAL(2U, Test1::get_instance_count());
CHECK_EQUAL(2U, Test2::get_instance_count());
//delete ptest2b;
//CHECK_EQUAL(2, Test1::get_instance_count());
//CHECK_EQUAL(1, Test2::get_instance_count());
delete ptest2b;
CHECK_EQUAL(2U, Test1::get_instance_count());
CHECK_EQUAL(1U, Test2::get_instance_count());
}
};
}
}

View File

@ -45,8 +45,8 @@ typedef TestDataNDC<std::string> ItemNDC;
namespace
{
typedef etl::forward_link<0, etl::link_option::AUTO> FirstLink;
typedef etl::forward_link<1> SecondLink;
typedef etl::forward_link<0> FirstLink;
typedef etl::bidirectional_link<1> SecondLink;
//***************************************************************************
class ItemDCNode : public FirstLink, public SecondLink
@ -259,12 +259,6 @@ namespace
////*************************************************************************
TEST_FIXTURE(SetupFixture, test_two_lists_different)
{
std::list<ItemNDCNode> compare0;
std::list<ItemNDCNode> compare1;
DataNDC0 data0;
DataNDC1 data1;
ItemNDCNode node0("0");
ItemNDCNode node1("1");
ItemNDCNode node2("2");
@ -274,43 +268,51 @@ namespace
ItemNDCNode node6("6");
ItemNDCNode node7("7");
compare0.push_front(node0);
compare0.push_front(node1);
compare0.push_front(node2);
compare0.push_front(node4);
compare0.push_front(node6);
compare0.push_front(node7);
data0.push_front(node0);
data0.push_front(node1);
data0.push_front(node2);
data0.push_front(node4);
data0.push_front(node6);
data0.push_front(node7);
{
std::list<ItemNDCNode> compare0;
std::list<ItemNDCNode> compare1;
are_equal = std::equal(data0.begin(), data0.end(), compare0.begin());
CHECK(are_equal);
CHECK_EQUAL(6, data0.size());
CHECK_EQUAL(6, std::distance(data0.begin(), data0.end()));
DataNDC0 data0;
DataNDC1 data1;
compare1.push_front(node0);
compare1.push_front(node1);
compare1.push_front(node3);
compare1.push_front(node4);
compare1.push_front(node5);
compare1.push_front(node7);
compare0.push_front(node0);
compare0.push_front(node1);
compare0.push_front(node2);
compare0.push_front(node4);
compare0.push_front(node6);
compare0.push_front(node7);
data1.push_front(node0);
data1.push_front(node1);
data1.push_front(node3);
data1.push_front(node4);
data1.push_front(node5);
data1.push_front(node7);
compare1.push_front(node0);
compare1.push_front(node1);
compare1.push_front(node3);
compare1.push_front(node4);
compare1.push_front(node5);
compare1.push_front(node7);
are_equal = std::equal(data1.begin(), data1.end(), compare1.begin());
CHECK(are_equal);
CHECK_EQUAL(6, data1.size());
CHECK_EQUAL(6, std::distance(data1.begin(), data1.end()));
data0.push_front(node0);
data0.push_front(node1);
data0.push_front(node2);
data0.push_front(node4);
data0.push_front(node6);
data0.push_front(node7);
are_equal = std::equal(data0.begin(), data0.end(), compare0.begin());
CHECK(are_equal);
CHECK_EQUAL(6U, data0.size());
CHECK_EQUAL(6, std::distance(data0.begin(), data0.end()));
data1.push_front(node0);
data1.push_front(node1);
data1.push_front(node3);
data1.push_front(node4);
data1.push_front(node5);
data1.push_front(node7);
are_equal = std::equal(data1.begin(), data1.end(), compare1.begin());
CHECK(are_equal);
CHECK_EQUAL(6U, data1.size());
CHECK_EQUAL(6, std::distance(data1.begin(), data1.end()));
}
}
//*************************************************************************
@ -336,13 +338,13 @@ namespace
are_equal = std::equal(data0.begin(), data0.end(), compare_data.begin());
CHECK(are_equal);
CHECK_EQUAL(std::distance(compare_data.begin(), compare_data.end()), data0.size());
CHECK_EQUAL(size_t(std::distance(compare_data.begin(), compare_data.end())), data0.size());
CHECK_EQUAL(std::distance(compare_data.begin(), compare_data.end()), std::distance(data0.begin(), data0.end()));
are_equal = std::equal(data1.begin(), data1.end(), sorted_data.begin());
CHECK(are_equal);
CHECK_EQUAL(sorted_data.size(), data1.size());
CHECK_EQUAL(sorted_data.size(), std::distance(data1.begin(), data1.end()));
CHECK_EQUAL(sorted_data.size(), size_t(std::distance(data1.begin(), data1.end())));
offset = 0;
@ -352,22 +354,18 @@ namespace
i_compare_data = compare_data.begin();
std::advance(i_compare_data, offset);
std::forward_list<ItemNDCNode> temp(data0.begin(), data0.end());
data0.insert_after(i_data, INSERT_VALUE2);
compare_data.insert_after(i_compare_data, INSERT_VALUE2);
temp.assign(data0.begin(), data0.end());
are_equal = std::equal(data0.begin(), data0.end(), compare_data.begin());
CHECK(are_equal);
CHECK_EQUAL(std::distance(compare_data.begin(), compare_data.end()), data0.size());
CHECK_EQUAL(size_t(std::distance(compare_data.begin(), compare_data.end())), data0.size());
CHECK_EQUAL(std::distance(compare_data.begin(), compare_data.end()), std::distance(data0.begin(), data0.end()));
are_equal = std::equal(data1.begin(), data1.end(), sorted_data.begin());
CHECK(are_equal);
CHECK_EQUAL(sorted_data.size(), data1.size());
CHECK_EQUAL(sorted_data.size(), std::distance(data1.begin(), data1.end()));
CHECK_EQUAL(sorted_data.size(), size_t(std::distance(data1.begin(), data1.end())));
}
//*************************************************************************
@ -389,7 +387,7 @@ namespace
are_equal = std::equal(data1.begin(), data1.end(), test1.begin());
CHECK(are_equal);
CHECK_EQUAL(test1.size(), data1.size());
CHECK_EQUAL(test1.size(), std::distance(data1.begin(), data1.end()));
CHECK_EQUAL(test1.size(), size_t(std::distance(data1.begin(), data1.end())));
compare.assign(test1.begin(), test1.end());
data0.assign(test1.begin(), test1.end());
@ -411,15 +409,12 @@ namespace
are_equal = std::equal(data1.begin(), data1.end(), test1.begin());
CHECK(are_equal);
CHECK_EQUAL(test1.size(), data1.size());
CHECK_EQUAL(test1.size(), std::distance(data1.begin(), data1.end()));
CHECK_EQUAL(test1.size(), size_t(std::distance(data1.begin(), data1.end())));
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_push_front)
{
std::list<ItemNDCNode> compare_data;
DataNDC0 data0;
ItemNDCNode node1("1");
ItemNDCNode node2("2");
ItemNDCNode node3("3");
@ -427,32 +422,34 @@ namespace
ItemNDCNode node5("5");
ItemNDCNode node6("6");
compare_data.push_front(node1);
compare_data.push_front(node2);
compare_data.push_front(node3);
compare_data.push_front(node4);
compare_data.push_front(node5);
compare_data.push_front(node6);
{
std::list<ItemNDCNode> compare_data;
DataNDC0 data0;
CHECK_NO_THROW(data0.push_front(node1));
CHECK_NO_THROW(data0.push_front(node2));
CHECK_NO_THROW(data0.push_front(node3));
CHECK_NO_THROW(data0.push_front(node4));
CHECK_NO_THROW(data0.push_front(node5));
CHECK_NO_THROW(data0.push_front(node6));
compare_data.push_front(node1);
compare_data.push_front(node2);
compare_data.push_front(node3);
compare_data.push_front(node4);
compare_data.push_front(node5);
compare_data.push_front(node6);
are_equal = std::equal(data0.begin(), data0.end(), compare_data.begin());
CHECK(are_equal);
CHECK_EQUAL(6, data0.size());
CHECK_EQUAL(6, std::distance(data0.begin(), data0.end()));
CHECK_NO_THROW(data0.push_front(node1));
CHECK_NO_THROW(data0.push_front(node2));
CHECK_NO_THROW(data0.push_front(node3));
CHECK_NO_THROW(data0.push_front(node4));
CHECK_NO_THROW(data0.push_front(node5));
CHECK_NO_THROW(data0.push_front(node6));
are_equal = std::equal(data0.begin(), data0.end(), compare_data.begin());
CHECK(are_equal);
CHECK_EQUAL(6U, data0.size());
CHECK_EQUAL(6, std::distance(data0.begin(), data0.end()));
}
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_push_front_pop_front)
{
DataNDC0 data0;
DataNDC1 data1;
ItemNDCNode node1("1");
ItemNDCNode node2("2");
ItemNDCNode node3("3");
@ -460,43 +457,48 @@ namespace
ItemNDCNode node5("5");
ItemNDCNode node6("6");
data0.push_front(node1);
data0.push_front(node2);
data0.push_front(node3);
data0.push_front(node4);
data0.push_front(node5);
data0.push_front(node6);
{
DataNDC0 data0;
DataNDC1 data1;
data1.push_front(node1);
data1.push_front(node2);
data1.push_front(node3);
data1.push_front(node4);
data1.push_front(node5);
data1.push_front(node6);
data0.push_front(node1);
data0.push_front(node2);
data0.push_front(node3);
data0.push_front(node4);
data0.push_front(node5);
data0.push_front(node6);
CHECK_EQUAL(6, data0.size());
CHECK_EQUAL(6, std::distance(data0.begin(), data0.end()));
CHECK(!data0.empty());
data1.push_front(node1);
data1.push_front(node2);
data1.push_front(node3);
data1.push_front(node4);
data1.push_front(node5);
data1.push_front(node6);
data0.pop_front();
data0.pop_front();
data0.pop_front();
data0.pop_front();
data0.pop_front();
CHECK_EQUAL(6U, data0.size());
CHECK_EQUAL(6, std::distance(data0.begin(), data0.end()));
CHECK(!data0.empty());
CHECK_EQUAL(1, data0.size());
CHECK_EQUAL(1, std::distance(data0.begin(), data0.end()));
CHECK(!data0.empty());
data0.pop_front();
data0.pop_front();
data0.pop_front();
data0.pop_front();
data0.pop_front();
data0.pop_front();
CHECK_EQUAL(1U, data0.size());
CHECK_EQUAL(1, std::distance(data0.begin(), data0.end()));
CHECK(!data0.empty());
CHECK_EQUAL(0, data0.size());
CHECK_EQUAL(0, std::distance(data0.begin(), data0.end()));
CHECK(data0.empty());
data0.pop_front();
CHECK_EQUAL(6, data1.size());
CHECK_EQUAL(6, std::distance(data1.begin(), data1.end()));
CHECK(!data1.empty());
CHECK_EQUAL(0U, data0.size());
CHECK_EQUAL(0, std::distance(data0.begin(), data0.end()));
CHECK(data0.empty());
CHECK_EQUAL(6U, data1.size());
CHECK_EQUAL(6, std::distance(data1.begin(), data1.end()));
CHECK(!data1.empty());
}
}
//*************************************************************************
@ -526,13 +528,13 @@ namespace
are_equal = std::equal(data0.begin(), data0.end(), compare_data.begin());
CHECK(are_equal);
CHECK_EQUAL(std::distance(compare_data.begin(), compare_data.end()), data0.size());
CHECK_EQUAL(size_t(std::distance(compare_data.begin(), compare_data.end())), data0.size());
CHECK_EQUAL(std::distance(compare_data.begin(), compare_data.end()), std::distance(data0.begin(), data0.end()));
are_equal = std::equal(data1.begin(), data1.end(), sorted_data.begin());
CHECK(are_equal);
CHECK_EQUAL(sorted_data.size(), data1.size());
CHECK_EQUAL(sorted_data.size(), std::distance(data1.begin(), data1.end()));
CHECK_EQUAL(sorted_data.size(), size_t(std::distance(data1.begin(), data1.end())));
are_equal = *i_data == *i_compare_data;
CHECK(are_equal);
@ -547,13 +549,13 @@ namespace
are_equal = std::equal(data0.begin(), data0.end(), compare_data.begin());
CHECK(are_equal);
CHECK_EQUAL(std::distance(compare_data.begin(), compare_data.end()), data0.size());
CHECK_EQUAL(size_t(std::distance(compare_data.begin(), compare_data.end())), data0.size());
CHECK_EQUAL(std::distance(compare_data.begin(), compare_data.end()), std::distance(data0.begin(), data0.end()));
are_equal = std::equal(data1.begin(), data1.end(), sorted_data.begin());
CHECK(are_equal);
CHECK_EQUAL(sorted_data.size(), data1.size());
CHECK_EQUAL(sorted_data.size(), std::distance(data1.begin(), data1.end()));
CHECK_EQUAL(sorted_data.size(), size_t(std::distance(data1.begin(), data1.end())));
are_equal = *i_data == *i_compare_data;
CHECK(are_equal);
@ -586,13 +588,13 @@ namespace
are_equal = std::equal(data0.begin(), data0.end(), compare_data.begin());
CHECK(are_equal);
CHECK_EQUAL(std::distance(compare_data.begin(), compare_data.end()), data0.size());
CHECK_EQUAL(size_t(std::distance(compare_data.begin(), compare_data.end())), data0.size());
CHECK_EQUAL(std::distance(compare_data.begin(), compare_data.end()), std::distance(data0.begin(), data0.end()));
are_equal = std::equal(data1.begin(), data1.end(), sorted_data.begin());
CHECK(are_equal);
CHECK_EQUAL(sorted_data.size(), data1.size());
CHECK_EQUAL(sorted_data.size(), std::distance(data1.begin(), data1.end()));
CHECK_EQUAL(sorted_data.size(), size_t(std::distance(data1.begin(), data1.end())));
}
//*************************************************************************
@ -616,13 +618,13 @@ namespace
are_equal = std::equal(data0.begin(), data0.end(), compare_data.begin());
CHECK(are_equal);
CHECK_EQUAL(std::distance(compare_data.begin(), compare_data.end()), data0.size());
CHECK_EQUAL(size_t(std::distance(compare_data.begin(), compare_data.end())), data0.size());
CHECK_EQUAL(std::distance(compare_data.begin(), compare_data.end()), std::distance(data0.begin(), data0.end()));
are_equal = std::equal(data1.begin(), data1.end(), sorted_data.begin());
CHECK(are_equal);
CHECK_EQUAL(sorted_data.size(), data1.size());
CHECK_EQUAL(sorted_data.size(), std::distance(data1.begin(), data1.end()));
CHECK_EQUAL(sorted_data.size(), size_t(std::distance(data1.begin(), data1.end())));
}
//*************************************************************************
@ -655,13 +657,13 @@ namespace
are_equal = std::equal(data0.begin(), data0.end(), unique_data.begin());
CHECK(are_equal);
CHECK_EQUAL(unique_data.size(), data0.size());
CHECK_EQUAL(unique_data.size(), std::distance(data0.begin(), data0.end()));
CHECK_EQUAL(unique_data.size(), size_t(std::distance(data0.begin(), data0.end())));
// data1 should not have changed.
are_equal = std::equal(data1.begin(), data1.end(), non_unique_data.begin());
CHECK(are_equal);
CHECK_EQUAL(non_unique_data.size(), data1.size());
CHECK_EQUAL(non_unique_data.size(), std::distance(data1.begin(), data1.end()));
CHECK_EQUAL(non_unique_data.size(), size_t(std::distance(data1.begin(), data1.end())));
}
//*************************************************************************
@ -677,13 +679,13 @@ namespace
are_equal = std::equal(data0.begin(), data0.end(), compare_data.begin());
CHECK(are_equal);
CHECK_EQUAL(std::distance(compare_data.begin(), compare_data.end()), data0.size());
CHECK_EQUAL(size_t(std::distance(compare_data.begin(), compare_data.end())), data0.size());
CHECK_EQUAL(std::distance(compare_data.begin(), compare_data.end()), std::distance(data0.begin(), data0.end()));
are_equal = std::equal(data1.begin(), data1.end(), sorted_data.begin());
CHECK(are_equal);
CHECK_EQUAL(sorted_data.size(), data1.size());
CHECK_EQUAL(sorted_data.size(), std::distance(data1.begin(), data1.end()));
CHECK_EQUAL(sorted_data.size(), size_t(std::distance(data1.begin(), data1.end())));
}
//*************************************************************************
@ -699,13 +701,13 @@ namespace
are_equal = std::equal(data0.begin(), data0.end(), compare_data.begin());
CHECK(are_equal);
CHECK_EQUAL(std::distance(compare_data.begin(), compare_data.end()), data0.size());
CHECK_EQUAL(size_t(std::distance(compare_data.begin(), compare_data.end())), data0.size());
CHECK_EQUAL(std::distance(compare_data.begin(), compare_data.end()), std::distance(data0.begin(), data0.end()));
are_equal = std::equal(data1.begin(), data1.end(), sorted_data.begin());
CHECK(are_equal);
CHECK_EQUAL(sorted_data.size(), data1.size());
CHECK_EQUAL(sorted_data.size(), std::distance(data1.begin(), data1.end()));
CHECK_EQUAL(sorted_data.size(), size_t(std::distance(data1.begin(), data1.end())));
}
//*************************************************************************
@ -776,8 +778,8 @@ namespace
are_equal = std::equal(data0.begin(), data0.end(), compare0.begin());
CHECK(are_equal);
CHECK_EQUAL(std::distance(compare0.begin(), compare0.end()), data0.size());
CHECK_EQUAL(std::distance(compare1.begin(), compare1.end()), data1.size());
CHECK_EQUAL(size_t(std::distance(compare0.begin(), compare0.end())), data0.size());
CHECK_EQUAL(size_t(std::distance(compare1.begin(), compare1.end())), data1.size());
}
//*************************************************************************
@ -790,18 +792,14 @@ namespace
DataNDC0::iterator idata_destination = data0.begin();
std::advance(idata_destination, 3);
std::forward_list<ItemNDCNode> compare0(data0.begin(), data0.end());
std::forward_list<ItemNDCNode>::iterator icompare_destination = compare0.begin();
std::advance(icompare_destination, 3);
std::forward_list<ItemNDCNode> compare0(sorted_data2.begin(), sorted_data2.end());
data0.splice_after(idata_destination, data0);
compare0.splice_after(icompare_destination, compare0);
are_equal = std::equal(data0.begin(), data0.end(), compare0.begin());
CHECK(are_equal);
CHECK_EQUAL(std::distance(compare0.begin(), compare0.end()), data0.size());
CHECK_EQUAL(size_t(std::distance(compare0.begin(), compare0.end())), data0.size());
}
//*************************************************************************
@ -839,8 +837,8 @@ namespace
are_equal = std::equal(data0.begin(), data0.end(), compare0.begin());
CHECK(are_equal);
CHECK_EQUAL(std::distance(compare0.begin(), compare0.end()), data0.size());
CHECK_EQUAL(std::distance(compare1.begin(), compare1.end()), data1.size());
CHECK_EQUAL(size_t(std::distance(compare0.begin(), compare0.end())), data0.size());
CHECK_EQUAL(size_t(std::distance(compare1.begin(), compare1.end())), data1.size());
}
//*************************************************************************
@ -859,7 +857,7 @@ namespace
DataNDC0::iterator idata_end = data0.begin();
std::advance(idata_end, 7);
std::forward_list<ItemNDCNode> compare0(data0.begin(), data0.end());
std::forward_list<ItemNDCNode> compare0(sorted_data2.begin(), sorted_data2.end());
std::forward_list<ItemNDCNode>::iterator icompare_destination = compare0.begin();
std::advance(icompare_destination, 2);
@ -872,11 +870,11 @@ namespace
data0.splice_after(idata_destination, data0, idata_begin, idata_end);
compare0.splice_after(icompare_destination, compare0, icompare_begin, icompare_end);
are_equal = std::equal(data0.begin(), data0.end(), compare0.begin());
CHECK(are_equal);
CHECK_EQUAL(std::distance(compare0.begin(), compare0.end()), data0.size());
CHECK_EQUAL(size_t(std::distance(compare0.begin(), compare0.end())), data0.size());
}
//*************************************************************************
@ -896,8 +894,8 @@ namespace
are_equal = std::equal(data0.begin(), data0.end(), compare0.begin());
CHECK(are_equal);
CHECK_EQUAL(std::distance(compare0.begin(), compare0.end()), data0.size());
CHECK_EQUAL(std::distance(compare1.begin(), compare1.end()), data1.size());
CHECK_EQUAL(size_t(std::distance(compare0.begin(), compare0.end())), data0.size());
CHECK_EQUAL(size_t(std::distance(compare1.begin(), compare1.end())), data1.size());
}
//*************************************************************************
@ -917,8 +915,8 @@ namespace
are_equal = std::equal(data0.begin(), data0.end(), compare0.begin());
CHECK(are_equal);
CHECK_EQUAL(std::distance(compare0.begin(), compare0.end()), data0.size());
CHECK_EQUAL(std::distance(compare2.begin(), compare2.end()), data2.size());
CHECK_EQUAL(size_t(std::distance(compare0.begin(), compare0.end())), data0.size());
CHECK_EQUAL(size_t(std::distance(compare2.begin(), compare2.end())), data2.size());
}
//*************************************************************************
@ -938,8 +936,8 @@ namespace
are_equal = std::equal(data0.begin(), data0.end(), compare0.begin());
CHECK(are_equal);
CHECK_EQUAL(std::distance(compare0.begin(), compare0.end()), data0.size());
CHECK_EQUAL(std::distance(compare3.begin(), compare3.end()), data3.size());
CHECK_EQUAL(size_t(std::distance(compare0.begin(), compare0.end())), data0.size());
CHECK_EQUAL(size_t(std::distance(compare3.begin(), compare3.end())), data3.size());
}
//*************************************************************************
@ -959,8 +957,8 @@ namespace
are_equal = std::equal(data0.begin(), data0.end(), compare0.begin());
CHECK(are_equal);
CHECK_EQUAL(std::distance(compare0.begin(), compare0.end()), data0.size());
CHECK_EQUAL(std::distance(compare4.begin(), compare4.end()), data4.size());
CHECK_EQUAL(size_t(std::distance(compare0.begin(), compare0.end())), data0.size());
CHECK_EQUAL(size_t(std::distance(compare4.begin(), compare4.end())), data4.size());
}
//*************************************************************************
@ -986,8 +984,8 @@ namespace
are_equal = std::equal(data0.begin(), data0.end(), compare0.begin());
CHECK(are_equal);
CHECK_EQUAL(std::distance(compare0.begin(), compare0.end()), data0.size());
CHECK_EQUAL(std::distance(compare1.begin(), compare1.end()), data1.size());
CHECK_EQUAL(size_t(std::distance(compare0.begin(), compare0.end())), data0.size());
CHECK_EQUAL(size_t(std::distance(compare1.begin(), compare1.end())), data1.size());
}
};
}

File diff suppressed because it is too large Load Diff

View File

@ -84,25 +84,25 @@ namespace
};
//***************************************************************************
bool operator ==(const ItemDCNode& lhs, const ItemDCNode& rhs)
{
return lhs.data == rhs.data;
}
// bool operator ==(const ItemDCNode& lhs, const ItemDCNode& rhs)
// {
// return lhs.data == rhs.data;
// }
bool operator ==(const ItemNDCNode& lhs, const ItemNDCNode& rhs)
{
return lhs.data == rhs.data;
}
bool operator !=(const ItemDCNode& lhs, const ItemDCNode& rhs)
{
return lhs.data != rhs.data;
}
// bool operator !=(const ItemDCNode& lhs, const ItemDCNode& rhs)
// {
// return lhs.data != rhs.data;
// }
bool operator !=(const ItemNDCNode& lhs, const ItemNDCNode& rhs)
{
return lhs.data != rhs.data;
}
// bool operator !=(const ItemNDCNode& lhs, const ItemNDCNode& rhs)
// {
// return lhs.data != rhs.data;
// }
std::ostream& operator << (std::ostream& os, const ItemNDCNode& node)
{
@ -136,10 +136,10 @@ namespace
typedef std::vector<ItemNDCNode> InitialDataNDC;
}
namespace
{
namespace
{
SUITE(test_intrusive_list)
{
{
InitialDataNDC unsorted_data;
InitialDataNDC sorted_data;
InitialDataNDC sorted_data2;
@ -151,7 +151,7 @@ namespace
InitialDataNDC merge_data2;
InitialDataNDC merge_data3;
InitialDataNDC merge_data4;
//*************************************************************************
struct SetupFixture
{
@ -200,11 +200,11 @@ namespace
DataNDC0 data0;
CHECK(data0.begin() == data0.end());
DataNDC0::const_iterator begin = data0.begin();
DataNDC0::const_iterator end = data0.end();
CHECK(begin == end);
CHECK(data0.cbegin() == data0.cend());
}
@ -224,7 +224,7 @@ namespace
TEST_FIXTURE(SetupFixture, test_const_iterator)
{
bool are_equal;
DataNDC0 data0(sorted_data.begin(), sorted_data.end());
are_equal = std::equal(data0.cbegin(), data0.cend(), sorted_data.begin());
@ -282,7 +282,7 @@ namespace
std::list<ItemNDCNode> compare0;
std::list<ItemNDCNode> compare1;
DataNDC0 data0;
DataNDC1 data1;
@ -301,7 +301,7 @@ namespace
compare0.push_front(node4);
compare0.push_front(node6);
compare0.push_front(node7);
data0.push_front(node0);
data0.push_front(node1);
data0.push_front(node2);
@ -311,7 +311,7 @@ namespace
are_equal = std::equal(data0.begin(), data0.end(), compare0.begin());
CHECK(are_equal);
CHECK_EQUAL(6, data0.size());
CHECK_EQUAL(6U, data0.size());
CHECK_EQUAL(6, std::distance(data0.begin(), data0.end()));
compare1.push_front(node0);
@ -330,7 +330,7 @@ namespace
are_equal = std::equal(data1.begin(), data1.end(), compare1.begin());
CHECK(are_equal);
CHECK_EQUAL(6, data1.size());
CHECK_EQUAL(6U, data1.size());
CHECK_EQUAL(6, std::distance(data1.begin(), data1.end()));
}
@ -360,12 +360,12 @@ namespace
are_equal = std::equal(data0.begin(), data0.end(), compare_data.begin());
CHECK(are_equal);
CHECK_EQUAL(compare_data.size(), data0.size());
CHECK_EQUAL(compare_data.size(), std::distance(data0.begin(), data0.end()));
CHECK_EQUAL(compare_data.size(), size_t(std::distance(data0.begin(), data0.end())));
are_equal = std::equal(data1.begin(), data1.end(), sorted_data.begin());
CHECK(are_equal);
CHECK_EQUAL(sorted_data.size(), data1.size());
CHECK_EQUAL(sorted_data.size(), std::distance(data1.begin(), data1.end()));
CHECK_EQUAL(sorted_data.size(), size_t(std::distance(data1.begin(), data1.end())));
offset = 0;
@ -385,12 +385,12 @@ namespace
are_equal = std::equal(data0.begin(), data0.end(), compare_data.begin());
CHECK(are_equal);
CHECK_EQUAL(compare_data.size(), data0.size());
CHECK_EQUAL(compare_data.size(), std::distance(data0.begin(), data0.end()));
CHECK_EQUAL(compare_data.size(), size_t(std::distance(data0.begin(), data0.end())));
are_equal = std::equal(data1.begin(), data1.end(), sorted_data.begin());
CHECK(are_equal);
CHECK_EQUAL(sorted_data.size(), data1.size());
CHECK_EQUAL(sorted_data.size(), std::distance(data1.begin(), data1.end()));
CHECK_EQUAL(sorted_data.size(), size_t(std::distance(data1.begin(), data1.end())));
}
//*************************************************************************
@ -414,7 +414,7 @@ namespace
are_equal = std::equal(data1.begin(), data1.end(), test1.begin());
CHECK(are_equal);
CHECK_EQUAL(test1.size(), data1.size());
CHECK_EQUAL(test1.size(), std::distance(data1.begin(), data1.end()));
CHECK_EQUAL(test1.size(), size_t(std::distance(data1.begin(), data1.end())));
compare.assign(test1.begin(), test1.end());
data0.assign(test1.begin(), test1.end());
@ -437,7 +437,7 @@ namespace
are_equal = std::equal(data1.begin(), data1.end(), test1.begin());
CHECK(are_equal);
CHECK_EQUAL(test1.size(), data1.size());
CHECK_EQUAL(test1.size(), std::distance(data1.begin(), data1.end()));
CHECK_EQUAL(test1.size(), size_t(std::distance(data1.begin(), data1.end())));
}
//*************************************************************************
@ -471,7 +471,7 @@ namespace
are_equal = std::equal(data0.begin(), data0.end(), compare_data.begin());
CHECK(are_equal);
CHECK_EQUAL(6, data0.size());
CHECK_EQUAL(6U, data0.size());
CHECK_EQUAL(6, std::distance(data0.begin(), data0.end()));
}
@ -502,7 +502,7 @@ namespace
data1.push_front(node5);
data1.push_front(node6);
CHECK_EQUAL(6, data0.size());
CHECK_EQUAL(6U, data0.size());
CHECK_EQUAL(6, std::distance(data0.begin(), data0.end()));
CHECK(!data0.empty());
@ -512,17 +512,17 @@ namespace
data0.pop_front();
data0.pop_front();
CHECK_EQUAL(1, data0.size());
CHECK_EQUAL(1U, data0.size());
CHECK_EQUAL(1, std::distance(data0.begin(), data0.end()));
CHECK(!data0.empty());
data0.pop_front();
CHECK_EQUAL(0, data0.size());
CHECK_EQUAL(0U, data0.size());
CHECK_EQUAL(0, std::distance(data0.begin(), data0.end()));
CHECK(data0.empty());
CHECK_EQUAL(6, data1.size());
CHECK_EQUAL(6U, data1.size());
CHECK_EQUAL(6, std::distance(data1.begin(), data1.end()));
CHECK(!data1.empty());
}
@ -557,12 +557,12 @@ namespace
CHECK(are_equal);
CHECK_EQUAL(compare_data.size(), data0.size());
CHECK_EQUAL(compare_data.size(), std::distance(data0.begin(), data0.end()));
CHECK_EQUAL(compare_data.size(), size_t(std::distance(data0.begin(), data0.end())));
are_equal = std::equal(data1.begin(), data1.end(), sorted_data.begin());
CHECK(are_equal);
CHECK_EQUAL(sorted_data.size(), data1.size());
CHECK_EQUAL(sorted_data.size(), std::distance(data1.begin(), data1.end()));
CHECK_EQUAL(sorted_data.size(), size_t(std::distance(data1.begin(), data1.end())));
are_equal = *i_data == *i_compare_data;
CHECK(are_equal);
@ -578,12 +578,12 @@ namespace
CHECK(are_equal);
CHECK_EQUAL(compare_data.size(), data0.size());
CHECK_EQUAL(compare_data.size(), std::distance(data0.begin(), data0.end()));
CHECK_EQUAL(compare_data.size(), size_t(std::distance(data0.begin(), data0.end())));
are_equal = std::equal(data1.begin(), data1.end(), sorted_data.begin());
CHECK(are_equal);
CHECK_EQUAL(sorted_data.size(), data1.size());
CHECK_EQUAL(sorted_data.size(), std::distance(data1.begin(), data1.end()));
CHECK_EQUAL(sorted_data.size(), size_t(std::distance(data1.begin(), data1.end())));
are_equal = *i_data == *i_compare_data;
CHECK(are_equal);
@ -619,12 +619,12 @@ namespace
are_equal = std::equal(data0.begin(), data0.end(), compare_data.begin());
CHECK(are_equal);
CHECK_EQUAL(compare_data.size(), data0.size());
CHECK_EQUAL(compare_data.size(), std::distance(data0.begin(), data0.end()));
CHECK_EQUAL(compare_data.size(), size_t(std::distance(data0.begin(), data0.end())));
are_equal = std::equal(data1.begin(), data1.end(), sorted_data.begin());
CHECK(are_equal);
CHECK_EQUAL(sorted_data.size(), data1.size());
CHECK_EQUAL(sorted_data.size(), std::distance(data1.begin(), data1.end()));
CHECK_EQUAL(sorted_data.size(), size_t(std::distance(data1.begin(), data1.end())));
}
//*************************************************************************
@ -651,12 +651,12 @@ namespace
are_equal = std::equal(data0.begin(), data0.end(), compare_data.begin());
CHECK(are_equal);
CHECK_EQUAL(compare_data.size(), data0.size());
CHECK_EQUAL(compare_data.size(), std::distance(data0.begin(), data0.end()));
CHECK_EQUAL(compare_data.size(), size_t(std::distance(data0.begin(), data0.end())));
are_equal = std::equal(data1.begin(), data1.end(), sorted_data.begin());
CHECK(are_equal);
CHECK_EQUAL(sorted_data.size(), data1.size());
CHECK_EQUAL(sorted_data.size(), std::distance(data1.begin(), data1.end()));
CHECK_EQUAL(sorted_data.size(), size_t(std::distance(data1.begin(), data1.end())));
}
//*************************************************************************
@ -691,13 +691,13 @@ namespace
are_equal = std::equal(data0.begin(), data0.end(), unique_data.begin());
CHECK(are_equal);
CHECK_EQUAL(unique_data.size(), data0.size());
CHECK_EQUAL(unique_data.size(), std::distance(data0.begin(), data0.end()));
CHECK_EQUAL(unique_data.size(), size_t(std::distance(data0.begin(), data0.end())));
// data1 should not have changed.
are_equal = std::equal(data1.begin(), data1.end(), non_unique_data.begin());
CHECK(are_equal);
CHECK_EQUAL(non_unique_data.size(), data1.size());
CHECK_EQUAL(non_unique_data.size(), std::distance(data1.begin(), data1.end()));
CHECK_EQUAL(non_unique_data.size(), size_t(std::distance(data1.begin(), data1.end())));
}
//*************************************************************************
@ -717,12 +717,12 @@ namespace
CHECK(are_equal);
CHECK_EQUAL(compare_data.size(), data0.size());
CHECK_EQUAL(compare_data.size(), std::distance(data0.begin(), data0.end()));
CHECK_EQUAL(compare_data.size(), size_t(std::distance(data0.begin(), data0.end())));
are_equal = std::equal(data1.begin(), data1.end(), sorted_data.begin());
CHECK(are_equal);
CHECK_EQUAL(sorted_data.size(), data1.size());
CHECK_EQUAL(sorted_data.size(), std::distance(data1.begin(), data1.end()));
CHECK_EQUAL(sorted_data.size(), size_t(std::distance(data1.begin(), data1.end())));
}
//*************************************************************************
@ -742,12 +742,12 @@ namespace
CHECK(are_equal);
CHECK_EQUAL(compare_data.size(), data0.size());
CHECK_EQUAL(compare_data.size(), std::distance(data0.begin(), data0.end()));
CHECK_EQUAL(compare_data.size(), size_t(std::distance(data0.begin(), data0.end())));
are_equal = std::equal(data1.begin(), data1.end(), sorted_data.begin());
CHECK(are_equal);
CHECK_EQUAL(sorted_data.size(), data1.size());
CHECK_EQUAL(sorted_data.size(), std::distance(data1.begin(), data1.end()));
CHECK_EQUAL(sorted_data.size(), size_t(std::distance(data1.begin(), data1.end())));
}
//*************************************************************************
@ -899,13 +899,9 @@ namespace
DataNDC0::iterator idata_destination = data0.begin();
std::advance(idata_destination, 3);
std::list<ItemNDCNode> compare0(data0.begin(), data0.end());
std::list<ItemNDCNode>::iterator icompare_destination = compare0.begin();
std::advance(icompare_destination, 3);
std::list<ItemNDCNode> compare0(sorted_data2.begin(), sorted_data2.end());
data0.splice(idata_destination, data0);
compare0.splice(icompare_destination, compare0);
are_equal = std::equal(data0.begin(), data0.end(), compare0.begin());
CHECK(are_equal);

View File

@ -0,0 +1,259 @@
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
http://www.etlcpp.com
Copyright(c) 2016 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include <UnitTest++/UnitTest++.h>
#include "../src/intrusive_queue.h"
#include "../src/intrusive_links.h"
#include <vector>
namespace
{
typedef etl::forward_link<0> link0;
typedef etl::bidirectional_link<1> link1;
struct Data : public link0, public link1
{
Data(int i)
: i(i)
{
}
int i;
};
bool operator ==(const Data& lhs, const Data& rhs)
{
return lhs.i == rhs.i;
}
std::ostream& operator << (std::ostream& os, const Data& data)
{
os << data.i;
return os;
}
std::vector<Data> data =
{
Data(1), Data(2), Data(3), Data(4), Data(5), Data(6), Data(7), Data(8)
};
SUITE(test_intrusive_queue)
{
//*************************************************************************
TEST(test_constructor)
{
etl::intrusive_queue<Data, link0> queueD;
etl::intrusive_queue<Data, link1> queueC;
CHECK(queueD.empty());
CHECK(queueC.empty());
CHECK_EQUAL(0U, queueD.size());
CHECK_EQUAL(0U, queueC.size());
}
//*************************************************************************
TEST(test_empty)
{
etl::intrusive_queue<Data, link0> queueD;
etl::intrusive_queue<Data, link1> queueC;
Data data1(1);
Data data2(2);
CHECK(queueD.empty());
CHECK(queueC.empty());
queueD.push(data1);
queueC.push(data2);
CHECK(!queueD.empty());
CHECK(!queueC.empty());
}
//*************************************************************************
TEST(test_size)
{
Data data1(1);
Data data2(2);
Data data3(3);
etl::intrusive_queue<Data, link0> queueD;
etl::intrusive_queue<Data, link1> queueC;
queueD.push(data1);
queueD.push(data2);
queueD.push(data3);
queueC.push(data1);
queueC.push(data2);
CHECK_EQUAL(3U, queueD.size());
CHECK_EQUAL(2U, queueC.size());
}
//*************************************************************************
TEST(test_clear)
{
Data data1(1);
Data data2(2);
Data data3(3);
etl::intrusive_queue<Data, link0> queueD;
etl::intrusive_queue<Data, link1> queueC;
queueD.push(data1);
queueD.push(data2);
queueD.push(data3);
queueC.push(data1);
queueC.push(data2);
queueD.clear();
queueC.clear();
CHECK(queueD.empty());
CHECK(queueC.empty());
}
//*************************************************************************
TEST(test_push)
{
Data data1(1);
Data data2(2);
Data data3(3);
etl::intrusive_queue<Data, link0> queueD;
etl::intrusive_queue<Data, link1> queueC;
queueD.push(data1);
CHECK_EQUAL(queueD.front(), data1);
CHECK_EQUAL(queueD.back(), data1);
queueD.push(data2);
CHECK_EQUAL(queueD.front(), data1);
CHECK_EQUAL(queueD.back(), data2);
queueD.push(data3);
CHECK_EQUAL(queueD.front(), data1);
CHECK_EQUAL(queueD.back(), data3);
queueC.push(data1);
CHECK_EQUAL(queueC.front(), data1);
CHECK_EQUAL(queueC.back(), data1);
queueC.push(data2);
CHECK_EQUAL(queueC.front(), data1);
CHECK_EQUAL(queueC.back(), data2);
}
//*************************************************************************
TEST(test_pop)
{
Data data1(1);
Data data2(2);
Data data3(3);
etl::intrusive_queue<Data, link0> queueD;
etl::intrusive_queue<Data, link1> queueC;
queueD.push(data1);
queueD.push(data2);
queueD.push(data3);
queueC.push(data1);
queueC.push(data2);
CHECK_EQUAL(queueD.front(), data1);
CHECK_EQUAL(queueD.back(), data3);
queueD.pop();
CHECK_EQUAL(queueD.front(), data2);
CHECK_EQUAL(queueD.back(), data3);
queueD.pop();
CHECK_EQUAL(queueD.front(), data3);
CHECK_EQUAL(queueD.back(), data3);
queueD.pop();
CHECK(queueD.empty());
CHECK_EQUAL(queueC.front(), data1);
CHECK_EQUAL(queueC.back(), data2);
queueC.pop();
CHECK_EQUAL(queueC.front(), data2);
CHECK_EQUAL(queueC.back(), data2);
queueC.pop();
CHECK(queueC.empty());
}
//*************************************************************************
TEST(test_front_const)
{
Data data1(1);
Data data2(2);
Data data3(3);
etl::intrusive_queue<Data, link0> queueD;
const etl::intrusive_queue<Data, link0>& queueDR = queueD;
queueD.push(data1);
queueD.push(data2);
queueD.push(data3);
CHECK_EQUAL(queueD.front(), queueDR.front());
queueD.pop();
CHECK_EQUAL(queueD.front(), queueDR.front());
queueD.pop();
CHECK_EQUAL(queueD.front(), queueDR.front());
}
//*************************************************************************
TEST(test_back_const)
{
Data data1(1);
Data data2(2);
Data data3(3);
etl::intrusive_queue<Data, link0> queueD;
const etl::intrusive_queue<Data, link0>& queueDR = queueD;
queueD.push(data1);
queueD.push(data2);
queueD.push(data3);
CHECK_EQUAL(queueD.back(), queueDR.back());
queueD.pop();
CHECK_EQUAL(queueD.back(), queueDR.back());
queueD.pop();
CHECK_EQUAL(queueD.back(), queueDR.back());
}
};
}

View File

@ -0,0 +1,226 @@
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
http://www.etlcpp.com
Copyright(c) 2016 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include <UnitTest++/UnitTest++.h>
#include "../src/intrusive_stack.h"
#include "../src/intrusive_links.h"
#include <vector>
namespace
{
typedef etl::forward_link<0> link0;
typedef etl::bidirectional_link<1> link1;
struct Data : public link0, public link1
{
Data(int i)
: i(i)
{
}
int i;
};
bool operator ==(const Data& lhs, const Data& rhs)
{
return lhs.i == rhs.i;
}
std::ostream& operator << (std::ostream& os, const Data& data)
{
os << data.i;
return os;
}
std::vector<Data> data =
{
Data(1), Data(2), Data(3), Data(4), Data(5), Data(6), Data(7), Data(8)
};
SUITE(test_intrusive_stack)
{
//*************************************************************************
TEST(test_constructor)
{
etl::intrusive_stack<Data, link0> stackD;
etl::intrusive_stack<Data, link1> stackC;
CHECK(stackD.empty());
CHECK(stackC.empty());
CHECK_EQUAL(0U, stackD.size());
CHECK_EQUAL(0U, stackC.size());
}
//*************************************************************************
TEST(test_empty)
{
Data data1(1);
Data data2(2);
etl::intrusive_stack<Data, link0> stackD;
etl::intrusive_stack<Data, link1> stackC;
CHECK(stackD.empty());
CHECK(stackC.empty());
stackD.push(data1);
stackC.push(data2);
CHECK(!stackD.empty());
CHECK(!stackC.empty());
}
//*************************************************************************
TEST(test_size)
{
Data data1(1);
Data data2(2);
Data data3(3);
etl::intrusive_stack<Data, link0> stackD;
etl::intrusive_stack<Data, link1> stackC;
stackD.push(data1);
stackD.push(data2);
stackD.push(data3);
stackC.push(data1);
stackC.push(data2);
CHECK_EQUAL(3U, stackD.size());
CHECK_EQUAL(2U, stackC.size());
}
//*************************************************************************
TEST(test_clear)
{
Data data1(1);
Data data2(2);
Data data3(3);
etl::intrusive_stack<Data, link0> stackD;
etl::intrusive_stack<Data, link1> stackC;
stackD.push(data1);
stackD.push(data2);
stackD.push(data3);
stackC.push(data1);
stackC.push(data2);
stackD.clear();
stackC.clear();
CHECK(stackD.empty());
CHECK(stackC.empty());
}
//*************************************************************************
TEST(test_push)
{
Data data1(1);
Data data2(2);
Data data3(3);
etl::intrusive_stack<Data, link0> stackD;
etl::intrusive_stack<Data, link1> stackC;
stackD.push(data1);
CHECK_EQUAL(stackD.top(), data1);
stackD.push(data2);
CHECK_EQUAL(stackD.top(), data2);
stackD.push(data3);
CHECK_EQUAL(stackD.top(), data3);
stackC.push(data1);
CHECK_EQUAL(stackC.top(), data1);
stackC.push(data2);
CHECK_EQUAL(stackC.top(), data2);
}
//*************************************************************************
TEST(test_pop)
{
Data data1(1);
Data data2(2);
Data data3(3);
etl::intrusive_stack<Data, link0> stackD;
etl::intrusive_stack<Data, link1> stackC;
stackD.push(data1);
stackD.push(data2);
stackD.push(data3);
stackC.push(data1);
stackC.push(data2);
CHECK_EQUAL(stackD.top(), data3);
stackD.pop();
CHECK_EQUAL(stackD.top(), data2);
stackD.pop();
CHECK_EQUAL(stackD.top(), data1);
stackD.pop();
CHECK(stackD.empty());
CHECK_EQUAL(stackC.top(), data2);
stackC.pop();
CHECK_EQUAL(stackC.top(), data1);
stackC.pop();
CHECK(stackC.empty());
}
//*************************************************************************
TEST(test_top_const)
{
Data data1(1);
Data data2(2);
Data data3(3);
etl::intrusive_stack<Data, link0> stackD;
const etl::intrusive_stack<Data, link0>& stackDR = stackD;
stackD.push(data1);
stackD.push(data2);
stackD.push(data3);
CHECK_EQUAL(stackD.top(), stackDR.top());
stackD.pop();
CHECK_EQUAL(stackD.top(), stackDR.top());
stackD.pop();
CHECK_EQUAL(stackD.top(), stackDR.top());
}
};
}

View File

@ -32,7 +32,12 @@ SOFTWARE.
#include <stdint.h>
#pragma warning(disable:4101) // Unused variable.
#if defined(ETL_COMPILER_GCC)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#else
#pragma warning(disable:4101) // Unused variable.
#endif
template <uintptr_t ADDRESS>
struct serial_port
@ -113,3 +118,7 @@ namespace
}
};
}
#if defined(ETL_COMPILER_GCC)
#pragma GCC diagnostic pop
#endif

View File

@ -85,7 +85,7 @@ namespace
{
std::string data("123456789");
uint32_t hash = etl::jenkins<uint32_t>(data.begin(), data.end());
uint32_t hash = etl::jenkins32(data.begin(), data.end());
uint32_t compare = jenkins32(data.begin(), data.end());
CHECK_EQUAL(compare, hash);
@ -96,7 +96,7 @@ namespace
{
std::string data("123456789");
etl::jenkins<uint32_t> jenkins_32_calculator;
etl::jenkins32 jenkins_32_calculator;
for (size_t i = 0; i < data.size(); ++i)
{
@ -114,7 +114,7 @@ namespace
{
std::string data("123456789");
etl::jenkins<uint32_t> jenkins_32_calculator;
etl::jenkins32 jenkins_32_calculator;
jenkins_32_calculator.add(data.begin(), data.end());
@ -132,9 +132,9 @@ namespace
std::vector<uint32_t> data2 = { 0x04030201, 0x08070605 };
std::vector<uint8_t> data3 = { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 };
uint32_t hash1 = etl::jenkins<uint32_t>(data1.begin(), data1.end());
uint32_t hash2 = etl::jenkins<uint32_t>((uint8_t*)&data2[0], (uint8_t*)&data2[0] + (data2.size() * sizeof(uint32_t)));
uint32_t hash3 = etl::jenkins<uint32_t>(data3.rbegin(), data3.rend());
uint32_t hash1 = etl::jenkins32(data1.begin(), data1.end());
uint32_t hash2 = etl::jenkins32((uint8_t*)&data2[0], (uint8_t*)&data2[0] + (data2.size() * sizeof(uint32_t)));
uint32_t hash3 = etl::jenkins32(data3.rbegin(), data3.rend());
CHECK_EQUAL(hash1, hash2);
CHECK_EQUAL(hash1, hash3);
@ -146,7 +146,7 @@ namespace
CHECK_EQUAL(compare2, hash2);
uint64_t compare3 = jenkins32(data3.rbegin(), data3.rend());
CHECK_EQUAL(compare2, hash3);
CHECK_EQUAL(compare3, hash3);
}
//*************************************************************************
@ -154,9 +154,10 @@ namespace
{
std::string data("123456789");
etl::jenkins<uint32_t> j32;
etl::jenkins32 j32;
j32.add(data.begin(), data.end());
uint32_t hash = j32;
j32.value();
CHECK_THROW(j32.add(0), etl::hash_finalised);
}
@ -166,7 +167,7 @@ namespace
{
std::string data("123456789");
uint64_t hash = etl::jenkins<uint64_t>(data.begin(), data.end());
uint64_t hash = etl::jenkins64(data.begin(), data.end());
uint64_t compare = jenkins64(data.begin(), data.end());
CHECK_EQUAL(compare, hash);
@ -177,7 +178,7 @@ namespace
{
std::string data("123456789");
etl::jenkins<uint64_t> jenkins_64_calculator;
etl::jenkins64 jenkins_64_calculator;
for (size_t i = 0; i < data.size(); ++i)
{
@ -195,7 +196,7 @@ namespace
{
std::string data("123456789");
etl::jenkins<uint64_t> jenkins_64_calculator;
etl::jenkins64 jenkins_64_calculator;
jenkins_64_calculator.add(data.begin(), data.end());
@ -213,9 +214,9 @@ namespace
std::vector<uint32_t> data2 = { 0x04030201, 0x08070605 };
std::vector<uint8_t> data3 = { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 };
uint64_t hash1 = etl::jenkins<uint64_t>(data1.begin(), data1.end());
uint64_t hash2 = etl::jenkins<uint64_t>((uint8_t*)&data2[0], (uint8_t*)&data2[0] + (data2.size() * sizeof(uint32_t)));
uint64_t hash3 = etl::jenkins<uint64_t>(data3.rbegin(), data3.rend());
uint64_t hash1 = etl::jenkins64(data1.begin(), data1.end());
uint64_t hash2 = etl::jenkins64((uint8_t*)&data2[0], (uint8_t*)&data2[0] + (data2.size() * sizeof(uint32_t)));
uint64_t hash3 = etl::jenkins64(data3.rbegin(), data3.rend());
CHECK_EQUAL(hash1, hash2);
CHECK_EQUAL(hash1, hash3);
@ -226,7 +227,7 @@ namespace
CHECK_EQUAL(compare2, hash2);
uint64_t compare3 = jenkins64(data3.rbegin(), data3.rend());
CHECK_EQUAL(compare2, hash3);
CHECK_EQUAL(compare3, hash3);
}
};
}

View File

@ -270,7 +270,7 @@ namespace
DataNDC data(sorted_data.begin(), sorted_data.end());
data.clear();
CHECK_EQUAL(data.size(), 0);
CHECK_EQUAL(0U, data.size());
}
//*************************************************************************
@ -678,7 +678,7 @@ namespace
// Check that it is still in a valid state.
data.push_back(ItemNDC("1"));
CHECK(!data.empty());
CHECK_EQUAL(1, data.size());
CHECK_EQUAL(1U, data.size());
}
//*************************************************************************

View File

@ -281,71 +281,71 @@ namespace
//*************************************************************************
TEST(test_fibbonacci)
{
CHECK_EQUAL(0, (size_t)etl::fibonacci<0>::value);
CHECK_EQUAL(1, (size_t)etl::fibonacci<1>::value);
CHECK_EQUAL(1, (size_t)etl::fibonacci<2>::value);
CHECK_EQUAL(2, (size_t)etl::fibonacci<3>::value);
CHECK_EQUAL(3, (size_t)etl::fibonacci<4>::value);
CHECK_EQUAL(5, (size_t)etl::fibonacci<5>::value);
CHECK_EQUAL(8, (size_t)etl::fibonacci<6>::value);
CHECK_EQUAL(13, (size_t)etl::fibonacci<7>::value);
CHECK_EQUAL(21, (size_t)etl::fibonacci<8>::value);
CHECK_EQUAL(34, (size_t)etl::fibonacci<9>::value);
CHECK_EQUAL(55, (size_t)etl::fibonacci<10>::value);
CHECK_EQUAL(89, (size_t)etl::fibonacci<11>::value);
CHECK_EQUAL(144, (size_t)etl::fibonacci<12>::value);
CHECK_EQUAL(233, (size_t)etl::fibonacci<13>::value);
CHECK_EQUAL(377, (size_t)etl::fibonacci<14>::value);
CHECK_EQUAL(610, (size_t)etl::fibonacci<15>::value);
CHECK_EQUAL(987, (size_t)etl::fibonacci<16>::value);
CHECK_EQUAL(1597, (size_t)etl::fibonacci<17>::value);
CHECK_EQUAL(2584, (size_t)etl::fibonacci<18>::value);
CHECK_EQUAL(4181, (size_t)etl::fibonacci<19>::value);
CHECK_EQUAL(6765, (size_t)etl::fibonacci<20>::value);
CHECK_EQUAL(10946, (size_t)etl::fibonacci<21>::value);
CHECK_EQUAL(17711, (size_t)etl::fibonacci<22>::value);
CHECK_EQUAL(28657, (size_t)etl::fibonacci<23>::value);
CHECK_EQUAL(46368, (size_t)etl::fibonacci<24>::value);
CHECK_EQUAL(75025, (size_t)etl::fibonacci<25>::value);
CHECK_EQUAL(121393, (size_t)etl::fibonacci<26>::value);
CHECK_EQUAL(196418, (size_t)etl::fibonacci<27>::value);
CHECK_EQUAL(317811, (size_t)etl::fibonacci<28>::value);
CHECK_EQUAL(514229, (size_t)etl::fibonacci<29>::value);
CHECK_EQUAL(832040, (size_t)etl::fibonacci<30>::value);
CHECK_EQUAL(1346269, (size_t)etl::fibonacci<31>::value);
CHECK_EQUAL(2178309, (size_t)etl::fibonacci<32>::value);
CHECK_EQUAL(3524578, (size_t)etl::fibonacci<33>::value);
CHECK_EQUAL(5702887, (size_t)etl::fibonacci<34>::value);
CHECK_EQUAL(9227465, (size_t)etl::fibonacci<35>::value);
CHECK_EQUAL(14930352, (size_t)etl::fibonacci<36>::value);
CHECK_EQUAL(24157817, (size_t)etl::fibonacci<37>::value);
CHECK_EQUAL(39088169, (size_t)etl::fibonacci<38>::value);
CHECK_EQUAL(63245986, (size_t)etl::fibonacci<39>::value);
CHECK_EQUAL(102334155, (size_t)etl::fibonacci<40>::value);
CHECK_EQUAL(165580141, (size_t)etl::fibonacci<41>::value);
CHECK_EQUAL(267914296, (size_t)etl::fibonacci<42>::value);
CHECK_EQUAL(433494437, (size_t)etl::fibonacci<43>::value);
CHECK_EQUAL(701408733, (size_t)etl::fibonacci<44>::value);
CHECK_EQUAL(1134903170, (size_t)etl::fibonacci<45>::value);
CHECK_EQUAL(1836311903, (size_t)etl::fibonacci<46>::value);
CHECK_EQUAL(0U, (size_t)etl::fibonacci<0>::value);
CHECK_EQUAL(1U, (size_t)etl::fibonacci<1>::value);
CHECK_EQUAL(1U, (size_t)etl::fibonacci<2>::value);
CHECK_EQUAL(2U, (size_t)etl::fibonacci<3>::value);
CHECK_EQUAL(3U, (size_t)etl::fibonacci<4>::value);
CHECK_EQUAL(5U, (size_t)etl::fibonacci<5>::value);
CHECK_EQUAL(8U, (size_t)etl::fibonacci<6>::value);
CHECK_EQUAL(13U, (size_t)etl::fibonacci<7>::value);
CHECK_EQUAL(21U, (size_t)etl::fibonacci<8>::value);
CHECK_EQUAL(34U, (size_t)etl::fibonacci<9>::value);
CHECK_EQUAL(55U, (size_t)etl::fibonacci<10>::value);
CHECK_EQUAL(89U, (size_t)etl::fibonacci<11>::value);
CHECK_EQUAL(144U, (size_t)etl::fibonacci<12>::value);
CHECK_EQUAL(233U, (size_t)etl::fibonacci<13>::value);
CHECK_EQUAL(377U, (size_t)etl::fibonacci<14>::value);
CHECK_EQUAL(610U, (size_t)etl::fibonacci<15>::value);
CHECK_EQUAL(987U, (size_t)etl::fibonacci<16>::value);
CHECK_EQUAL(1597U, (size_t)etl::fibonacci<17>::value);
CHECK_EQUAL(2584U, (size_t)etl::fibonacci<18>::value);
CHECK_EQUAL(4181U, (size_t)etl::fibonacci<19>::value);
CHECK_EQUAL(6765U, (size_t)etl::fibonacci<20>::value);
CHECK_EQUAL(10946U, (size_t)etl::fibonacci<21>::value);
CHECK_EQUAL(17711U, (size_t)etl::fibonacci<22>::value);
CHECK_EQUAL(28657U, (size_t)etl::fibonacci<23>::value);
CHECK_EQUAL(46368U, (size_t)etl::fibonacci<24>::value);
CHECK_EQUAL(75025U, (size_t)etl::fibonacci<25>::value);
CHECK_EQUAL(121393U, (size_t)etl::fibonacci<26>::value);
CHECK_EQUAL(196418U, (size_t)etl::fibonacci<27>::value);
CHECK_EQUAL(317811U, (size_t)etl::fibonacci<28>::value);
CHECK_EQUAL(514229U, (size_t)etl::fibonacci<29>::value);
CHECK_EQUAL(832040U, (size_t)etl::fibonacci<30>::value);
CHECK_EQUAL(1346269U, (size_t)etl::fibonacci<31>::value);
CHECK_EQUAL(2178309U, (size_t)etl::fibonacci<32>::value);
CHECK_EQUAL(3524578U, (size_t)etl::fibonacci<33>::value);
CHECK_EQUAL(5702887U, (size_t)etl::fibonacci<34>::value);
CHECK_EQUAL(9227465U, (size_t)etl::fibonacci<35>::value);
CHECK_EQUAL(14930352U, (size_t)etl::fibonacci<36>::value);
CHECK_EQUAL(24157817U, (size_t)etl::fibonacci<37>::value);
CHECK_EQUAL(39088169U, (size_t)etl::fibonacci<38>::value);
CHECK_EQUAL(63245986U, (size_t)etl::fibonacci<39>::value);
CHECK_EQUAL(102334155U, (size_t)etl::fibonacci<40>::value);
CHECK_EQUAL(165580141U, (size_t)etl::fibonacci<41>::value);
CHECK_EQUAL(267914296U, (size_t)etl::fibonacci<42>::value);
CHECK_EQUAL(433494437U, (size_t)etl::fibonacci<43>::value);
CHECK_EQUAL(701408733U, (size_t)etl::fibonacci<44>::value);
CHECK_EQUAL(1134903170U, (size_t)etl::fibonacci<45>::value);
CHECK_EQUAL(1836311903U, (size_t)etl::fibonacci<46>::value);
CHECK_EQUAL(2971215073U, (size_t)etl::fibonacci<47>::value);
}
TEST(test_factorial)
{
CHECK_EQUAL(1, (size_t)etl::factorial<0>::value);
CHECK_EQUAL(1, (size_t)etl::factorial<1>::value);
CHECK_EQUAL(2, (size_t)etl::factorial<2>::value);
CHECK_EQUAL(6, (size_t)etl::factorial<3>::value);
CHECK_EQUAL(24, (size_t)etl::factorial<4>::value);
CHECK_EQUAL(120, (size_t)etl::factorial<5>::value);
CHECK_EQUAL(720, (size_t)etl::factorial<6>::value);
CHECK_EQUAL(5040, (size_t)etl::factorial<7>::value);
CHECK_EQUAL(40320, (size_t)etl::factorial<8>::value);
CHECK_EQUAL(362880, (size_t)etl::factorial<9>::value);
CHECK_EQUAL(3628800, (size_t)etl::factorial<10>::value);
CHECK_EQUAL(39916800, (size_t)etl::factorial<11>::value);
CHECK_EQUAL(479001600, (size_t)etl::factorial<12>::value);
CHECK_EQUAL(1U, (size_t)etl::factorial<0>::value);
CHECK_EQUAL(1U, (size_t)etl::factorial<1>::value);
CHECK_EQUAL(2U, (size_t)etl::factorial<2>::value);
CHECK_EQUAL(6U, (size_t)etl::factorial<3>::value);
CHECK_EQUAL(24U, (size_t)etl::factorial<4>::value);
CHECK_EQUAL(120U, (size_t)etl::factorial<5>::value);
CHECK_EQUAL(720U, (size_t)etl::factorial<6>::value);
CHECK_EQUAL(5040U, (size_t)etl::factorial<7>::value);
CHECK_EQUAL(40320U, (size_t)etl::factorial<8>::value);
CHECK_EQUAL(362880U, (size_t)etl::factorial<9>::value);
CHECK_EQUAL(3628800U, (size_t)etl::factorial<10>::value);
CHECK_EQUAL(39916800U, (size_t)etl::factorial<11>::value);
CHECK_EQUAL(479001600U, (size_t)etl::factorial<12>::value);
}
};
}

View File

@ -125,7 +125,7 @@ public:
//*******************************************
// Notification1 is passed by value.
//*******************************************
void notification(Notification1 data1)
void notification(Notification1 /*data1*/)
{
++data1_count;
}
@ -133,7 +133,7 @@ public:
//*******************************************
// Notification2 is passed by reference.
//*******************************************
void notification(Notification2& data2)
void notification(Notification2& /*data2*/)
{
++data2_count;
}
@ -141,7 +141,7 @@ public:
//*******************************************
// Notification3 is passed by const reference.
//*******************************************
void notification(const Notification3& data3)
void notification(const Notification3& /*data3*/)
{
++data3_count;
}
@ -170,7 +170,7 @@ public:
//*******************************************
// Notification1 is passed by value.
//*******************************************
void notification(Notification1 data1)
void notification(Notification1 /*data1*/)
{
++data1_count;
}
@ -178,7 +178,7 @@ public:
//*******************************************
// Notification2 is passed by reference.
//*******************************************
void notification(Notification2& data2)
void notification(Notification2& /*data2*/)
{
++data2_count;
}
@ -186,7 +186,7 @@ public:
//*******************************************
// Notification3 is passed by const reference.
//*******************************************
void notification(const Notification3& data3)
void notification(const Notification3& /*data3*/)
{
++data3_count;
}

View File

@ -184,7 +184,7 @@ namespace
CHECK(bool(container));
container.value().resize(5, Data("1"));
CHECK_EQUAL(5, container.value().size());
CHECK_EQUAL(5U, container.value().size());
CHECK_EQUAL(Data("1"), container.value()[0]);
CHECK_EQUAL(Data("1"), container.value()[1]);

View File

@ -36,6 +36,11 @@ SOFTWARE.
#include "../src/pool.h"
#if defined(ETL_COMPILER_GCC)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
typedef TestDataDC<std::string> Test_Data;
typedef TestDataNDC<std::string> Test_Data2;
@ -145,7 +150,7 @@ namespace
TEST(test_available)
{
etl::pool<Test_Data, 4> pool;
CHECK_EQUAL(4, pool.available());
CHECK_EQUAL(4U, pool.available());
Test_Data* p;
@ -385,3 +390,7 @@ namespace
}
};
}
#if defined(ETL_COMPILER_GCC)
#pragma GCC diagnostic pop
#endif

View File

@ -97,7 +97,7 @@ namespace
priority_queue.push(2);
priority_queue.push(3);
CHECK_EQUAL(3, priority_queue.size());
CHECK_EQUAL(3U, priority_queue.size());
}
//*************************************************************************
@ -108,7 +108,7 @@ namespace
priority_queue.push(1);
priority_queue.push(2);
priority_queue.clear();
CHECK_EQUAL(0, priority_queue.size());
CHECK_EQUAL(0U, priority_queue.size());
}
//*************************************************************************
@ -294,10 +294,6 @@ namespace
priority_queue.pop();
compare_priority_queue.pop();
CHECK_EQUAL(compare_priority_queue.size(), priority_queue.size());
// Go one beyond (which we handle without throwing)
priority_queue.pop();
CHECK_EQUAL(compare_priority_queue.size(), priority_queue.size());
}
//*************************************************************************

View File

@ -79,44 +79,167 @@ namespace
}
//*************************************************************************
TEST(test_smallest_size_for_bits)
TEST(test_smallest_uint_for_bits)
{
bool type;
type = std::is_same<uint8_t, etl::smallest_uint_for_bits<7>::type>::value;
type = std::is_same<uint_least8_t, etl::smallest_uint_for_bits<7>::type>::value;
CHECK(type);
type = std::is_same<uint8_t, etl::smallest_uint_for_bits<8>::type>::value;
type = std::is_same<uint_least8_t, etl::smallest_uint_for_bits<8>::type>::value;
CHECK(type);
type = std::is_same<uint16_t, etl::smallest_uint_for_bits<9>::type>::value;
type = std::is_same<uint_least16_t, etl::smallest_uint_for_bits<9>::type>::value;
CHECK(type);
type = std::is_same<uint16_t, etl::smallest_uint_for_bits<15>::type>::value;
type = std::is_same<uint_least16_t, etl::smallest_uint_for_bits<15>::type>::value;
CHECK(type);
type = std::is_same<uint16_t, etl::smallest_uint_for_bits<16>::type>::value;
type = std::is_same<uint_least16_t, etl::smallest_uint_for_bits<16>::type>::value;
CHECK(type);
type = std::is_same<uint32_t, etl::smallest_uint_for_bits<17>::type>::value;
type = std::is_same<uint_least32_t, etl::smallest_uint_for_bits<17>::type>::value;
CHECK(type);
type = std::is_same<uint32_t, etl::smallest_uint_for_bits<31>::type>::value;
type = std::is_same<uint_least32_t, etl::smallest_uint_for_bits<31>::type>::value;
CHECK(type);
type = std::is_same<uint32_t, etl::smallest_uint_for_bits<32>::type>::value;
type = std::is_same<uint_least32_t, etl::smallest_uint_for_bits<32>::type>::value;
CHECK(type);
type = std::is_same<uint64_t, etl::smallest_uint_for_bits<33>::type>::value;
type = std::is_same<uint_least64_t, etl::smallest_uint_for_bits<33>::type>::value;
CHECK(type);
type = std::is_same<uint64_t, etl::smallest_uint_for_bits<63>::type>::value;
type = std::is_same<uint_least64_t, etl::smallest_uint_for_bits<63>::type>::value;
CHECK(type);
type = std::is_same<uint64_t, etl::smallest_uint_for_bits<64>::type>::value;
type = std::is_same<uint_least64_t, etl::smallest_uint_for_bits<64>::type>::value;
CHECK(type);
type = std::is_same<uint64_t, etl::smallest_uint_for_bits<65>::type>::value;
type = std::is_same<uint_least64_t, etl::smallest_uint_for_bits<65>::type>::value;
CHECK(type);
}
//*************************************************************************
TEST(test_smallest_int_for_bits)
{
bool type;
type = std::is_same<int_least8_t, etl::smallest_int_for_bits<7>::type>::value;
CHECK(type);
type = std::is_same<int_least8_t, etl::smallest_int_for_bits<8>::type>::value;
CHECK(type);
type = std::is_same<int_least16_t, etl::smallest_int_for_bits<9>::type>::value;
CHECK(type);
type = std::is_same<int_least16_t, etl::smallest_int_for_bits<15>::type>::value;
CHECK(type);
type = std::is_same<int_least16_t, etl::smallest_int_for_bits<16>::type>::value;
CHECK(type);
type = std::is_same<int_least32_t, etl::smallest_int_for_bits<17>::type>::value;
CHECK(type);
type = std::is_same<int_least32_t, etl::smallest_int_for_bits<31>::type>::value;
CHECK(type);
type = std::is_same<int_least32_t, etl::smallest_int_for_bits<32>::type>::value;
CHECK(type);
type = std::is_same<int_least64_t, etl::smallest_int_for_bits<33>::type>::value;
CHECK(type);
type = std::is_same<int_least64_t, etl::smallest_int_for_bits<63>::type>::value;
CHECK(type);
type = std::is_same<int_least64_t, etl::smallest_int_for_bits<64>::type>::value;
CHECK(type);
type = std::is_same<int_least64_t, etl::smallest_int_for_bits<65>::type>::value;
CHECK(type);
}
//*************************************************************************
TEST(test_smallest_uint_for_value)
{
bool type;
type = std::is_same<uint_least8_t, etl::smallest_uint_for_value<0>::type>::value;
CHECK(type);
type = std::is_same<uint_least8_t, etl::smallest_uint_for_value<UINT8_MAX>::type>::value;
CHECK(type);
type = std::is_same<uint_least16_t, etl::smallest_uint_for_value<UINT8_MAX + 1>::type>::value;
CHECK(type);
type = std::is_same<uint_least16_t, etl::smallest_uint_for_value<UINT16_MAX>::type>::value;
CHECK(type);
type = std::is_same<uint_least32_t, etl::smallest_uint_for_value<UINT16_MAX + 1>::type>::value;
CHECK(type);
type = std::is_same<uint_least32_t, etl::smallest_uint_for_value<UINT32_MAX>::type>::value;
CHECK(type);
type = std::is_same<uint_least64_t, etl::smallest_uint_for_value<uint64_t(UINT32_MAX) + 1>::type>::value;
CHECK(type);
type = std::is_same<uint_least64_t, etl::smallest_uint_for_value<UINT64_MAX>::type>::value;
CHECK(type);
}
//*************************************************************************
TEST(test_smallest_int_for_value)
{
bool type;
type = std::is_same<int_least8_t, etl::smallest_int_for_value<0>::type>::value;
CHECK(type);
type = std::is_same<int_least8_t, etl::smallest_int_for_value<INT8_MIN>::type>::value;
CHECK(type);
type = std::is_same<int_least8_t, etl::smallest_int_for_value<INT8_MAX>::type>::value;
CHECK(type);
type = std::is_same<int_least16_t, etl::smallest_int_for_value<INT8_MIN - 1>::type>::value;
CHECK(type);
type = std::is_same<int_least16_t, etl::smallest_int_for_value<INT8_MAX + 1>::type>::value;
CHECK(type);
type = std::is_same<int_least16_t, etl::smallest_int_for_value<INT16_MIN>::type>::value;
CHECK(type);
type = std::is_same<int_least16_t, etl::smallest_int_for_value<INT16_MAX>::type>::value;
CHECK(type);
type = std::is_same<int_least32_t, etl::smallest_int_for_value<INT16_MIN - 1>::type>::value;
CHECK(type);
type = std::is_same<int_least32_t, etl::smallest_int_for_value<INT16_MAX + 1>::type>::value;
CHECK(type);
type = std::is_same<int_least32_t, etl::smallest_int_for_value<INT32_MIN>::type>::value;
CHECK(type);
type = std::is_same<int_least32_t, etl::smallest_int_for_value<INT32_MAX>::type>::value;
CHECK(type);
type = std::is_same<int_least64_t, etl::smallest_int_for_value<intmax_t(INT32_MIN) - 1>::type>::value;
CHECK(type);
type = std::is_same<int_least64_t, etl::smallest_int_for_value<intmax_t(INT32_MAX) + 1>::type>::value;
CHECK(type);
type = std::is_same<int_least64_t, etl::smallest_int_for_value<INT64_MIN>::type>::value;
CHECK(type);
type = std::is_same<int_least64_t, etl::smallest_int_for_value<INT64_MAX>::type>::value;
CHECK(type);
}
};

View File

@ -32,7 +32,7 @@ SOFTWARE.
#include <array>
#include <algorithm>
#include "../src/string.h"
#include "../src/cstring.h"
#undef min
@ -635,20 +635,6 @@ namespace
CHECK(is_equal);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_pop_back_excess)
{
Text text;
text.resize(2);
text.pop_back();
text.pop_back();
text.pop_back();
CHECK(text.empty());
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_insert_position_value)
{
@ -983,8 +969,8 @@ namespace
Text append(insert_text.c_str());
// Whole string.
compare_text.append(insert_text, 0);
text.append(append, 0);
compare_text.append(insert_text, 0, std::string::npos);
text.append(append, 0, Text::npos);
bool is_equal = Equal(compare_text, text);
CHECK(is_equal);
@ -2081,7 +2067,7 @@ namespace
CHECK_EQUAL(position1, position2);
position2 = haystack.find(needle, position2 + 1);
CHECK_EQUAL(etl::istring::npos, position2);
CHECK_EQUAL(etl::string<50>::npos, position2);
etl::string<50> pin(STR("pin"));
position2 = haystack.find(pin);

View File

@ -635,20 +635,6 @@ namespace
CHECK(is_equal);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_pop_back_excess)
{
Text text;
text.resize(2);
text.pop_back();
text.pop_back();
text.pop_back();
CHECK(text.empty());
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_insert_position_value)
{
@ -983,8 +969,8 @@ namespace
Text append(insert_text.c_str());
// Whole string.
compare_text.append(insert_text, 0);
text.append(append, 0);
compare_text.append(insert_text, 0, std::u16string::npos);
text.append(append, 0, etl::iu16string::npos);
bool is_equal = Equal(compare_text, text);
CHECK(is_equal);

View File

@ -635,20 +635,6 @@ namespace
CHECK(is_equal);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_pop_back_excess)
{
Text text;
text.resize(2);
text.pop_back();
text.pop_back();
text.pop_back();
CHECK(text.empty());
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_insert_position_value)
{
@ -983,8 +969,8 @@ namespace
Text append(insert_text.c_str());
// Whole string.
compare_text.append(insert_text, 0);
text.append(append, 0);
compare_text.append(insert_text, 0, std::u32string::npos);
text.append(append, 0, etl::iu32string::npos);
bool is_equal = Equal(compare_text, text);
CHECK(is_equal);

View File

@ -635,20 +635,6 @@ namespace
CHECK(is_equal);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_pop_back_excess)
{
Text text;
text.resize(2);
text.pop_back();
text.pop_back();
text.pop_back();
CHECK(text.empty());
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_insert_position_value)
{
@ -983,8 +969,8 @@ namespace
Text append(insert_text.c_str());
// Whole string.
compare_text.append(insert_text, 0);
text.append(append, 0);
compare_text.append(insert_text, 0, std::wstring::npos);
text.append(append, 0, etl::iwstring::npos);
bool is_equal = Equal(compare_text, text);
CHECK(is_equal);

View File

@ -116,7 +116,7 @@ namespace
CHECK_EQUAL(i %= 23, t %= 23);
t = type_t(0x1234);
CHECK_EQUAL(0x1234, t);
CHECK_EQUAL(0x1234U, t);
}
//=========================================================================

View File

@ -425,7 +425,7 @@ namespace
CHECK((std::is_same<etl::make_signed<char>::type, std::make_signed<char>::type>::value));
CHECK((std::is_same<etl::make_signed<signed char>::type, std::make_signed<signed char>::type>::value));
CHECK((std::is_same<etl::make_signed<unsigned char>::type, std::make_signed<unsigned char>::type>::value));
CHECK((std::is_same<etl::make_signed<wchar_t>::type, std::make_signed<wchar_t>::type>::value));
CHECK(std::is_signed<etl::make_signed<wchar_t>::type>::value && (sizeof(wchar_t) == sizeof(etl::make_signed<wchar_t>::type)));
CHECK((std::is_same<etl::make_signed<short>::type, std::make_signed<short>::type>::value));
CHECK((std::is_same<etl::make_signed<signed short>::type, std::make_signed<signed short>::type>::value));
CHECK((std::is_same<etl::make_signed<unsigned short>::type, std::make_signed<unsigned short>::type>::value));
@ -450,7 +450,7 @@ namespace
CHECK((std::is_same<etl::make_unsigned<char>::type, std::make_unsigned<char>::type>::value));
CHECK((std::is_same<etl::make_unsigned<signed char>::type, std::make_unsigned<signed char>::type>::value));
CHECK((std::is_same<etl::make_unsigned<unsigned char>::type, std::make_unsigned<unsigned char>::type>::value));
CHECK((std::is_same<etl::make_unsigned<wchar_t>::type, std::make_unsigned<wchar_t>::type>::value));
CHECK(std::is_unsigned<etl::make_unsigned<wchar_t>::type>::value && (sizeof(wchar_t) == sizeof(etl::make_unsigned<wchar_t>::type)));
CHECK((std::is_same<etl::make_unsigned<short>::type, std::make_unsigned<short>::type>::value));
CHECK((std::is_same<etl::make_unsigned<signed short>::type, std::make_unsigned<signed short>::type>::value));
CHECK((std::is_same<etl::make_unsigned<unsigned short>::type, std::make_unsigned<unsigned short>::type>::value));

View File

@ -431,7 +431,7 @@ namespace
size_t count = data.erase(K5);
CHECK_EQUAL(1, count);
CHECK_EQUAL(1U, count);
DataNDC::iterator idata = data.find(K5);
CHECK(idata == data.end());
@ -511,10 +511,10 @@ namespace
DataNDC data(initial_data.begin(), initial_data.end());
size_t count = data.count(K5);
CHECK_EQUAL(1, count);
CHECK_EQUAL(1U, count);
count = data.count(K12);
CHECK_EQUAL(0, count);
CHECK_EQUAL(0U, count);
}
//*************************************************************************

Some files were not shown because too many files have changed in this diff Show More