From 31a22d93af4319211103a875c4e6ad963617c809 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 9 Jan 2016 10:05:14 +0000 Subject: [PATCH 01/43] Moved call to initialise() to after construction completed. --- deque.h | 6 +++++- forward_list.h | 4 ++++ ideque.h | 29 ++++++++++++++--------------- iforward_list.h | 29 ++++++++++++++--------------- ilist.h | 29 ++++++++++++++--------------- imap.h | 29 ++++++++++++++--------------- imultimap.h | 29 ++++++++++++++--------------- imultiset.h | 29 ++++++++++++++--------------- iset.h | 29 ++++++++++++++--------------- ivector.h | 5 ++--- list.h | 5 +++++ map.h | 3 +++ multimap.h | 3 +++ multiset.h | 3 +++ set.h | 3 +++ vector.h | 4 ++++ 16 files changed, 130 insertions(+), 109 deletions(-) diff --git a/deque.h b/deque.h index 227e4faa..805247cc 100644 --- a/deque.h +++ b/deque.h @@ -83,6 +83,7 @@ namespace etl deque() : ideque(reinterpret_cast(&buffer[0]), MAX_SIZE, BUFFER_SIZE) { + initialise(); } //************************************************************************* @@ -91,6 +92,7 @@ namespace etl deque(const deque& other) : ideque(reinterpret_cast(&buffer[0]), MAX_SIZE, BUFFER_SIZE) { + initialise(); ideque::assign(other.begin(), other.end()); } @@ -101,6 +103,7 @@ namespace etl deque(TIterator begin, TIterator end) : ideque(reinterpret_cast(&buffer[0]), MAX_SIZE, BUFFER_SIZE) { + initialise(); ideque::assign(begin, end); } @@ -110,6 +113,7 @@ namespace etl explicit deque(size_t n, typename ideque::parameter_t value = value_type()) : ideque(reinterpret_cast(&buffer[0]), MAX_SIZE, BUFFER_SIZE) { + initialise(); ideque::assign(n, value); } @@ -128,7 +132,7 @@ namespace etl private: - /// The unititialised buffer of T used in the deque. + /// The uninitialised buffer of T used in the deque. typename etl::aligned_storage::value>::type buffer[BUFFER_SIZE]; }; } diff --git a/forward_list.h b/forward_list.h index c27450e4..4bdffb2a 100644 --- a/forward_list.h +++ b/forward_list.h @@ -71,6 +71,7 @@ namespace etl forward_list() : iforward_list(node_pool, MAX_SIZE) { + initialise(); } //************************************************************************* @@ -79,6 +80,7 @@ namespace etl explicit forward_list(size_t initialSize, typename iforward_list::parameter_t value = T()) : iforward_list(node_pool, MAX_SIZE) { + initialise(); iforward_list::assign(initialSize, value); } @@ -88,6 +90,7 @@ namespace etl forward_list(const forward_list& other) : iforward_list(node_pool, MAX_SIZE) { + initialise(); iforward_list::assign(other.cbegin(), other.cend()); } @@ -98,6 +101,7 @@ namespace etl forward_list(TIterator first, TIterator last) : iforward_list(node_pool, MAX_SIZE) { + initialise(); iforward_list::assign(first, last); } diff --git a/ideque.h b/ideque.h index c983bbbe..ad80574a 100644 --- a/ideque.h +++ b/ideque.h @@ -1225,7 +1225,20 @@ namespace etl : deque_base(max_size, buffer_size), p_buffer(p_buffer) { - clear(); + } + + //********************************************************************* + /// Initialise the deque. + //********************************************************************* + void initialise() + { + while (current_size > 0) + { + destroy_element_back(); + } + + _begin = iterator(0, *this, p_buffer); + _end = iterator(0, *this, p_buffer); } iterator _begin; ///Iterator to the _begin item in the deque. @@ -1330,20 +1343,6 @@ namespace etl --current_size; } - //********************************************************************* - /// Initialise the deque. - //********************************************************************* - void initialise() - { - while (current_size > 0) - { - destroy_element_back(); - } - - _begin = iterator(0, *this, p_buffer); - _end = iterator(0, *this, p_buffer); - } - //************************************************************************* /// Measures the distance between two iterators. //************************************************************************* diff --git a/iforward_list.h b/iforward_list.h index 9782ae45..8281a1f8 100644 --- a/iforward_list.h +++ b/iforward_list.h @@ -804,7 +804,20 @@ namespace etl : forward_list_base(max_size_), p_node_pool(&node_pool) { - initialise(); + } + + //************************************************************************* + /// Initialise the forward_list. + //************************************************************************* + void initialise() + { + if (!empty()) + { + p_node_pool->release_all(); + } + + current_size = 0; + start_node.next = nullptr; } private: @@ -865,20 +878,6 @@ namespace etl } } - //************************************************************************* - /// Initialise the forward_list. - //************************************************************************* - void initialise() - { - if (!empty()) - { - p_node_pool->release_all(); - } - - current_size = 0; - start_node.next = nullptr; - } - //************************************************************************* /// Allocate a Data_Node. //************************************************************************* diff --git a/ilist.h b/ilist.h index 70f4bd40..8794d6f7 100644 --- a/ilist.h +++ b/ilist.h @@ -893,7 +893,20 @@ namespace etl : list_base(max_size_), p_node_pool(&node_pool) { - initialise(); + } + + //************************************************************************* + /// Initialise the list. + //************************************************************************* + void initialise() + { + if (!empty()) + { + p_node_pool->release_all(); + } + + current_size = 0; + join(terminal_node, terminal_node); } private: @@ -928,20 +941,6 @@ namespace etl { p_node_pool->release(&node); } - - //************************************************************************* - /// Initialise the list. - //************************************************************************* - void initialise() - { - if (!empty()) - { - p_node_pool->release_all(); - } - - current_size = 0; - join(terminal_node, terminal_node); - } }; } diff --git a/imap.h b/imap.h index b2fc7dc4..e1e50f36 100644 --- a/imap.h +++ b/imap.h @@ -819,7 +819,20 @@ namespace etl : map_base(max_size_) , p_node_pool(&node_pool) { - initialise(); + } + + //************************************************************************* + /// Initialise the map. + //************************************************************************* + void initialise() + { + if (!empty()) + { + p_node_pool->release_all(); + } + + current_size = 0; + root_node = nullptr; } private: @@ -840,20 +853,6 @@ namespace etl p_node_pool->release(&node); } - //************************************************************************* - /// Initialise the map. - //************************************************************************* - void initialise() - { - if (!empty()) - { - p_node_pool->release_all(); - } - - current_size = 0; - root_node = nullptr; - } - //************************************************************************* /// Find the value matching the node provided //************************************************************************* diff --git a/imultimap.h b/imultimap.h index 0d0842f5..3a27bf8d 100644 --- a/imultimap.h +++ b/imultimap.h @@ -766,7 +766,20 @@ namespace etl : multimap_base(max_size_) , p_node_pool(&node_pool) { - initialise(); + } + + //************************************************************************* + /// Initialise the multimap. + //************************************************************************* + void initialise() + { + if (!empty()) + { + p_node_pool->release_all(); + } + + current_size = 0; + root_node = nullptr; } private: @@ -787,20 +800,6 @@ namespace etl p_node_pool->release(&node); } - //************************************************************************* - /// Initialise the multimap. - //************************************************************************* - void initialise() - { - if (!empty()) - { - p_node_pool->release_all(); - } - - current_size = 0; - root_node = nullptr; - } - //************************************************************************* /// Count the nodes that match the key provided //************************************************************************* diff --git a/imultiset.h b/imultiset.h index 7002f0e6..5836d731 100644 --- a/imultiset.h +++ b/imultiset.h @@ -747,7 +747,20 @@ namespace etl : multiset_base(max_size_) , p_node_pool(&node_pool) { - initialise(); + } + + //************************************************************************* + /// Initialise the multiset. + //************************************************************************* + void initialise() + { + if (!empty()) + { + p_node_pool->release_all(); + } + + current_size = 0; + root_node = nullptr; } private: @@ -768,20 +781,6 @@ namespace etl p_node_pool->release(&node); } - //************************************************************************* - /// Initialise the multiset. - //************************************************************************* - void initialise() - { - if (!empty()) - { - p_node_pool->release_all(); - } - - current_size = 0; - root_node = nullptr; - } - //************************************************************************* /// Count the nodes that match the key provided //************************************************************************* diff --git a/iset.h b/iset.h index 1accb712..a575538e 100644 --- a/iset.h +++ b/iset.h @@ -761,7 +761,20 @@ namespace etl : set_base(max_size_) , p_node_pool(&node_pool) { - initialise(); + } + + //************************************************************************* + /// Initialise the set. + //************************************************************************* + void initialise() + { + if (!empty()) + { + p_node_pool->release_all(); + } + + current_size = 0; + root_node = nullptr; } private: @@ -782,20 +795,6 @@ namespace etl p_node_pool->release(&node); } - //************************************************************************* - /// Initialise the set. - //************************************************************************* - void initialise() - { - if (!empty()) - { - p_node_pool->release_all(); - } - - current_size = 0; - root_node = nullptr; - } - //************************************************************************* /// Find the value matching the node provided //************************************************************************* diff --git a/ivector.h b/ivector.h index 6c753f6f..1d82427b 100644 --- a/ivector.h +++ b/ivector.h @@ -619,11 +619,8 @@ namespace etl : vector_base(MAX_SIZE), p_buffer(p_buffer) { - initialise(); } - private: - //********************************************************************* /// Initialise the vector. //********************************************************************* @@ -635,6 +632,8 @@ namespace etl } } + private: + //********************************************************************* /// Create a new element with a default value at the back. //********************************************************************* diff --git a/list.h b/list.h index d162823a..3e9e5e7d 100644 --- a/list.h +++ b/list.h @@ -71,6 +71,7 @@ namespace etl list() : ilist(node_pool, MAX_SIZE) { + initialise(); } //************************************************************************* @@ -79,6 +80,7 @@ namespace etl explicit list(size_t initialSize) : ilist(node_pool, MAX_SIZE) { + initialise(); ilist::assign(initialSize, T()); } @@ -88,6 +90,7 @@ namespace etl list(size_t initialSize, typename ilist::parameter_t value) : ilist(node_pool, MAX_SIZE) { + initialise(); ilist::assign(initialSize, value); } @@ -97,6 +100,7 @@ namespace etl list(const list& other) : ilist(node_pool, MAX_SIZE) { + initialise(); ilist::assign(other.cbegin(), other.cend()); } @@ -107,6 +111,7 @@ namespace etl list(TIterator first, TIterator last) : ilist(node_pool, MAX_SIZE) { + initialise(); ilist::assign(first, last); } diff --git a/map.h b/map.h index f538dafc..c3b57782 100644 --- a/map.h +++ b/map.h @@ -63,6 +63,7 @@ namespace etl map() : imap(node_pool, MAX_SIZE) { + initialise(); } //************************************************************************* @@ -71,6 +72,7 @@ namespace etl map(const map& other) : imap(node_pool, MAX_SIZE) { + initialise(); imap::assign(other.cbegin(), other.cend()); } @@ -84,6 +86,7 @@ namespace etl map(TIterator first, TIterator last) : imap(node_pool, MAX_SIZE) { + initialise(); imap::insert(first, last); } diff --git a/multimap.h b/multimap.h index 3b091a34..f98b8431 100644 --- a/multimap.h +++ b/multimap.h @@ -62,6 +62,7 @@ namespace etl multimap() : imultimap(node_pool, MAX_SIZE) { + initialise(); } //************************************************************************* @@ -70,6 +71,7 @@ namespace etl explicit multimap(const multimap& other) : imultimap(node_pool, MAX_SIZE) { + initialise(); imultimap::assign(other.cbegin(), other.cend()); } @@ -83,6 +85,7 @@ namespace etl multimap(TIterator first, TIterator last) : imultimap(node_pool, MAX_SIZE) { + initialise(); imultimap::insert(first, last); } diff --git a/multiset.h b/multiset.h index d3d39183..3983caa8 100644 --- a/multiset.h +++ b/multiset.h @@ -62,6 +62,7 @@ namespace etl multiset() : imultiset(node_pool, MAX_SIZE) { + initialise(); } //************************************************************************* @@ -70,6 +71,7 @@ namespace etl explicit multiset(const multiset& other) : imultiset(node_pool, MAX_SIZE) { + initialise(); imultiset::assign(other.cbegin(), other.cend()); } @@ -83,6 +85,7 @@ namespace etl multiset(TIterator first, TIterator last) : imultiset(node_pool, MAX_SIZE) { + initialise(); imultiset::insert(first, last); } diff --git a/set.h b/set.h index edf68842..52f02600 100644 --- a/set.h +++ b/set.h @@ -63,6 +63,7 @@ namespace etl set() : iset(node_pool, MAX_SIZE) { + initialise(); } //************************************************************************* @@ -71,6 +72,7 @@ namespace etl explicit set(const set& other) : iset(node_pool, MAX_SIZE) { + initialise(); iset::assign(other.cbegin(), other.cend()); } @@ -84,6 +86,7 @@ namespace etl set(TIterator first, TIterator last) : iset(node_pool, MAX_SIZE) { + initialise(); iset::insert(first, last); } diff --git a/vector.h b/vector.h index 9043e874..468ac8d2 100644 --- a/vector.h +++ b/vector.h @@ -67,6 +67,7 @@ namespace etl vector() : ivector(reinterpret_cast(&buffer), MAX_SIZE) { + initialise(); } //************************************************************************* @@ -76,6 +77,7 @@ namespace etl explicit vector(size_t initialSize) : ivector(reinterpret_cast(&buffer), MAX_SIZE) { + initialise(); ivector::resize(initialSize); } @@ -87,6 +89,7 @@ namespace etl vector(size_t initialSize, typename ivector::parameter_t value) : ivector(reinterpret_cast(&buffer), MAX_SIZE) { + initialise(); ivector::resize(initialSize, value); } @@ -100,6 +103,7 @@ namespace etl vector(TIterator first, TIterator last) : ivector(reinterpret_cast(&buffer), MAX_SIZE) { + initialise(); ivector::assign(first, last); } From 0e1eaa3aefba919768cc0e74026afc6ad0fb6e32 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 9 Jan 2016 10:23:53 +0000 Subject: [PATCH 02/43] Removed unnecessary priority_queue_base --- ipriority_queue.h | 126 ++++++++++++++++++++++++++++++++++++++-------- priority_queue.h | 6 +-- 2 files changed, 107 insertions(+), 25 deletions(-) diff --git a/ipriority_queue.h b/ipriority_queue.h index 36a1c017..4aa824df 100644 --- a/ipriority_queue.h +++ b/ipriority_queue.h @@ -30,18 +30,64 @@ SOFTWARE. #ifndef __ETL_IPRIORITY_QUEUE__ #define __ETL_IPRIORITY_QUEUE__ -#define __ETL_IN_IPRIORITY_QUEUE_H__ #include #include -#include "private/priority_queue_base.h" #include "type_traits.h" #include "parameter_type.h" #include "error_handler.h" namespace etl { +#include "../exception.h" +#include "../error_handler.h" + +#undef ETL_FILE +#define ETL_FILE "12" + + //*************************************************************************** + /// The base class for priority_queue exceptions. + ///\ingroup queue + //*************************************************************************** + class priority_queue_exception : public exception + { + public: + + priority_queue_exception(string_type what, string_type file_name, numeric_type line_number) + : exception(what, file_name, line_number) + { + } + }; + + //*************************************************************************** + /// The exception thrown when the queue is full. + ///\ingroup queue + //*************************************************************************** + class priority_queue_full : public priority_queue_exception + { + public: + + priority_queue_full(string_type file_name, numeric_type line_number) + : priority_queue_exception(ETL_ERROR_TEXT("priority_queue:full", ETL_FILE"A"), file_name, line_number) + { + } + }; + + //*************************************************************************** + /// The priority queue iterator exception on reversed iterators + ///\ingroup queue + //*************************************************************************** + class priority_queue_iterator : public priority_queue_exception + { + public: + + priority_queue_iterator(string_type file_name, numeric_type line_number) + : priority_queue_exception(ETL_ERROR_TEXT("priority_queue:iterator", ETL_FILE"B"), file_name, line_number) + { + } + }; + //*************************************************************************** ///\ingroup queue ///\brief This is the base for all priority queues that contain a particular type. @@ -59,7 +105,7 @@ namespace etl /// \tparam TCompare to use in comparing T values //*************************************************************************** template - class ipriority_queue : public priority_queue_base + class ipriority_queue { public: @@ -68,7 +114,7 @@ namespace etl typedef TCompare compare_type; ///< The comparison type. typedef T& reference; ///< A reference to the type used in the queue. typedef const T& const_reference; ///< A const reference to the type used in the queue. - typedef priority_queue_base::size_type size_type; ///< The type used for determining the size of the queue. + typedef typename TContainer::size_type size_type; ///< The type used for determining the size of the queue. typedef typename std::iterator_traits::difference_type difference_type; private: @@ -107,21 +153,10 @@ namespace etl // Put element at end container.push_back(value); - // Pre-increment size - ++current_size; // Make elements in container into heap std::push_heap(container.begin(), container.end(), TCompare()); } - //************************************************************************* - /// Clears the queue to the empty state. - //************************************************************************* - void clear() - { - container.clear(); - current_size = 0; - } - //************************************************************************* /// Assigns values to the priority queue. /// If ETL_THROW_EXCEPTIONS is defined, emits priority_queue_full if @@ -137,13 +172,12 @@ namespace etl #ifdef _DEBUG difference_type count = std::distance(first, last); ETL_ASSERT(count >= 0, ETL_ERROR(priority_queue_iterator)); - ETL_ASSERT(static_cast(count) <= MAX_SIZE, ETL_ERROR(priority_queue_full)); + ETL_ASSERT(static_cast(count) <= max_size(), ETL_ERROR(priority_queue_full)); #endif clear(); container.assign(first, last); std::make_heap(container.begin(), container.end(), TCompare()); - current_size = container.size(); } //************************************************************************* @@ -158,11 +192,60 @@ namespace etl std::pop_heap(container.begin(), container.end(), TCompare()); // Actually remove largest element at end container.pop_back(); - // Decrement size - --current_size; } } + //************************************************************************* + /// Returns the current number of items in the priority queue. + //************************************************************************* + size_type size() const + { + return container.size(); + } + + //************************************************************************* + /// Returns the maximum number of items that can be queued. + //************************************************************************* + size_type max_size() const + { + return container.max_size(); + } + + //************************************************************************* + /// Checks to see if the priority queue is empty. + /// \return true if the queue is empty, otherwise false + //************************************************************************* + bool empty() const + { + return container.empty(); + } + + //************************************************************************* + /// Checks to see if the priority queue is full. + /// \return true if the priority queue is full, otherwise false + //************************************************************************* + bool full() const + { + return container.size() == container.max_size(); + } + + //************************************************************************* + /// Returns the remaining capacity. + ///\return The remaining capacity. + //************************************************************************* + size_t available() const + { + return container.max_size() - container.size(); + } + + //************************************************************************* + /// Clears the queue to the empty state. + //************************************************************************* + void clear() + { + container.clear(); + } + protected: //************************************************************************* @@ -176,8 +259,7 @@ namespace etl //************************************************************************* /// The constructor that is called from derived classes. //************************************************************************* - ipriority_queue(size_type max_size) - : priority_queue_base(max_size) + ipriority_queue() { } @@ -188,5 +270,5 @@ namespace etl }; } -#undef __ETL_IN_IPRIORITY_QUEUE_H__ +#undef ETL_FILE #endif diff --git a/priority_queue.h b/priority_queue.h index 2d017536..507c86c6 100644 --- a/priority_queue.h +++ b/priority_queue.h @@ -63,7 +63,7 @@ namespace etl /// Default constructor. //************************************************************************* priority_queue() - : ipriority_queue(SIZE) + : ipriority_queue() { } @@ -71,7 +71,7 @@ namespace etl /// Copy constructor //************************************************************************* priority_queue(const priority_queue& rhs) - : ipriority_queue(SIZE) + : ipriority_queue() { ipriority_queue::clone(rhs); } @@ -84,7 +84,7 @@ namespace etl //************************************************************************* template priority_queue(TIterator first, TIterator last) - : ipriority_queue(SIZE) + : ipriority_queue() { ipriority_queue::assign(first, last); } From 231721a9804f3db034652696c561eff3d9ee4692 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 9 Jan 2016 10:25:27 +0000 Subject: [PATCH 03/43] Changed node base pointer to more unique name --- basic_intrusive_forward_list.h | 44 ++++++++++++++--------------- basic_intrusive_forward_list_node.h | 7 ++++- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/basic_intrusive_forward_list.h b/basic_intrusive_forward_list.h index 399912c1..9af8c075 100644 --- a/basic_intrusive_forward_list.h +++ b/basic_intrusive_forward_list.h @@ -124,14 +124,14 @@ namespace etl iterator& operator ++() { - p_node = p_node->next; + p_node = p_node->bifln_next; return *this; } iterator operator ++(int) { iterator temp(*this); - p_node = p_node->next; + p_node = p_node->bifln_next; return temp; } @@ -234,14 +234,14 @@ namespace etl const_iterator& operator ++() { - p_node = p_node->next; + p_node = p_node->bifln_next; return *this; } const_iterator operator ++(int) { const_iterator temp(*this); - p_node = p_node->next; + p_node = p_node->bifln_next; return temp; } @@ -440,21 +440,21 @@ namespace etl //************************************************************************* void reverse() { - if ((start_node.next == nullptr) || (start_node.next->next == nullptr)) + if ((start_node.bifln_next == nullptr) || (start_node.bifln_next->bifln_next == nullptr)) { return; } node_t* first = nullptr; // To keep first node - node_t* second = start_node.next; // To keep second node - node_t* track = start_node.next; // Track the list + node_t* second = start_node.bifln_next; // To keep second node + node_t* track = start_node.bifln_next; // Track the list while (track != NULL) { - track = track->next; // Track point to next node; - second->next = first; // Second node point to first - first = second; // Move first node to next - second = track; // Move second node to next + track = track->bifln_next; // Track point to next node; + second->bifln_next = first; // Second node point to first + first = second; // Move first node to next + second = track; // Move second node to next } join(&start_node, first); @@ -505,7 +505,7 @@ namespace etl { node_t* p_first = first.p_node; node_t* p_last = last.p_node; - node_t* p_next = p_first->next; + node_t* p_next = p_first->bifln_next; // Join the ends. join(p_first, p_last); @@ -515,8 +515,8 @@ namespace etl // Erase the ones in between. while (p_first != p_last) { - p_next = p_first->next; // Remember the next node. - p_first = p_next; // Move to the next node. + p_next = p_first->bifln_next; // Remember the next node. + p_first = p_next; // Move to the next node. } if (p_next == nullptr) @@ -534,7 +534,7 @@ namespace etl //************************************************************************* bool empty() const { - return start_node.next == nullptr; + return start_node.bifln_next == nullptr; } private: @@ -546,7 +546,7 @@ namespace etl //************************************************************************* void join(node_t* left, node_t* right) { - left->next = right; + left->bifln_next = right; } //************************************************************************* @@ -555,7 +555,7 @@ namespace etl void insert_node_after(node_t& position, node_t& node) { // Connect to the basic_intrusive_forward_list. - join(&node, position.next); + join(&node, position.bifln_next); join(&position, &node); } @@ -565,12 +565,12 @@ namespace etl void remove_node_after(node_t& node) { // The node to erase. - node_t* p_node = node.next; + node_t* p_node = node.bifln_next; if (p_node != nullptr) { // Disconnect the node from the basic_intrusive_forward_list. - join(&node, p_node->next); + join(&node, p_node->bifln_next); } } @@ -579,7 +579,7 @@ namespace etl //************************************************************************* node_t& get_head() { - return *start_node.next; + return *start_node.bifln_next; } //************************************************************************* @@ -587,7 +587,7 @@ namespace etl //************************************************************************* const node_t& get_head() const { - return *start_node.next; + return *start_node.bifln_next; } //************************************************************************* @@ -595,7 +595,7 @@ namespace etl //************************************************************************* void initialise() { - start_node.next = nullptr; + start_node.bifln_next = nullptr; } // Disabled. diff --git a/basic_intrusive_forward_list_node.h b/basic_intrusive_forward_list_node.h index 60c1ca7d..a3728b40 100644 --- a/basic_intrusive_forward_list_node.h +++ b/basic_intrusive_forward_list_node.h @@ -39,7 +39,12 @@ namespace etl //*************************************************************************** struct basic_intrusive_forward_list_node { - basic_intrusive_forward_list_node* next; + basic_intrusive_forward_list_node() + : bifln_next(nullptr) + { + } + + basic_intrusive_forward_list_node* bifln_next; }; } From 2abef4aa4099713987ffb666f4cd7f4cbc5cb179 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 9 Jan 2016 10:27:08 +0000 Subject: [PATCH 04/43] Added a "No Unit Tests" debug configuration --- test/vs2015/etl.sln | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/vs2015/etl.sln b/test/vs2015/etl.sln index 1ea8c882..45f74e08 100644 --- a/test/vs2015/etl.sln +++ b/test/vs2015/etl.sln @@ -1,16 +1,19 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 +VisualStudioVersion = 14.0.24720.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "etl", "etl.vcxproj", "{C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug No Uint Tests|Win32 = Debug No Unit Tests|Win32 Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug No Unit Tests|Win32.ActiveCfg = Debug No Unit Tests|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug No Unit Tests|Win32.Build.0 = Debug No Unit Tests|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug|Win32.ActiveCfg = Debug|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug|Win32.Build.0 = Debug|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Release|Win32.ActiveCfg = Release|Win32 From 1c4dbac7595967fe0826340e91f21bc80a7bb2e6 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 9 Jan 2016 10:28:14 +0000 Subject: [PATCH 05/43] Added an etl::map test. --- test/TrueStudio/ETL/src/main.cpp | 33 +++ test/iar/etl.dep | 5 +- test/iar/settings/etl.dni | 3 +- test/iar/settings/etl.wsdt | 18 +- test/keil/Test1.uvguix.John | 23 +- test/keil/Test1.uvoptx | 398 +++++++++++++++++++++---------- test/keil/Test1.uvprojx | 130 +++++++--- test/test_compile.cpp | 21 +- 8 files changed, 442 insertions(+), 189 deletions(-) create mode 100644 test/TrueStudio/ETL/src/main.cpp diff --git a/test/TrueStudio/ETL/src/main.cpp b/test/TrueStudio/ETL/src/main.cpp new file mode 100644 index 00000000..d32de39c --- /dev/null +++ b/test/TrueStudio/ETL/src/main.cpp @@ -0,0 +1,33 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl + +Copyright(c) 2014 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 + +int main() +{ + return UnitTest::RunAllTests(); +} diff --git a/test/iar/etl.dep b/test/iar/etl.dep index 85a78030..0f77961d 100644 --- a/test/iar/etl.dep +++ b/test/iar/etl.dep @@ -199,6 +199,7 @@ $PROJ_DIR$\..\..\bitset.h $PROJ_DIR$\Debug\Obj\pearson.__cstat.et $PROJ_DIR$\Debug\Obj\md5.__cstat.et + $PROJ_DIR$\..\..\private\map_base.h $PROJ_DIR$\..\..\private\list_base.h $PROJ_DIR$\..\..\private\vector_base.h $PROJ_DIR$\..\..\private\pool_base.h @@ -503,11 +504,11 @@ BICOMP - 220 215 15 113 86 82 202 132 56 173 100 40 154 218 198 46 125 211 96 38 51 156 217 203 177 207 219 121 107 181 41 35 170 221 209 144 214 222 7 201 212 22 11 200 73 204 185 187 194 19 186 190 54 37 31 48 102 174 216 199 197 160 168 208 213 210 178 3 13 1 20 10 2 114 150 66 196 44 206 135 146 205 179 180 176 9 14 21 6 4 16 17 12 8 18 5 0 119 59 87 78 193 195 + 221 82 144 199 132 154 40 220 8 198 156 38 194 196 51 173 210 208 176 14 15 5 200 121 73 187 119 212 114 46 190 181 41 35 170 19 217 218 203 216 209 215 179 9 21 6 4 18 96 186 87 193 54 37 31 48 102 174 89 222 202 160 168 213 205 206 180 204 16 17 12 0 125 86 59 78 66 207 135 146 214 219 211 201 223 177 178 3 13 7 1 22 20 10 11 2 150 56 185 113 197 195 44 107 100 95 ICCARM - 187 220 216 201 199 132 154 135 160 144 168 146 197 214 206 207 208 217 211 209 198 202 221 215 203 218 210 212 204 205 213 200 219 222 179 180 176 177 178 3 14 9 21 6 13 15 4 7 16 17 22 20 10 2 11 8 1 18 5 12 0 19 156 173 125 186 121 181 73 114 46 150 56 190 96 86 66 185 119 113 38 54 41 37 40 31 35 48 51 59 196 102 170 87 194 174 78 82 44 193 107 100 195 + 187 221 217 202 200 132 154 135 160 144 168 146 198 215 207 208 209 218 212 210 199 203 222 216 204 219 211 213 205 206 214 201 220 223 179 180 176 177 178 3 14 9 21 6 13 15 4 7 16 17 22 20 10 2 11 8 1 18 5 12 0 19 156 173 125 186 121 181 73 114 46 150 56 190 96 86 66 185 119 113 38 54 41 37 40 31 35 48 51 59 197 102 170 87 195 174 78 82 44 194 107 100 196 89 95 193 diff --git a/test/iar/settings/etl.dni b/test/iar/settings/etl.dni index 574cabcb..105d00d2 100644 --- a/test/iar/settings/etl.dni +++ b/test/iar/settings/etl.dni @@ -24,7 +24,8 @@ ShowTimeSum=1 [Disassemble mode] mode=0 [Breakpoints2] -Count=0 +Bp0=_ 1 "STD_CODE2" "{$PROJ_DIR$\..\test_compile.cpp}.1.1" 0 0 1 "" 0 "" +Count=1 [Interrupts] Enabled=1 [MemConfig] diff --git a/test/iar/settings/etl.wsdt b/test/iar/settings/etl.wsdt index f45ad5ad..68c7277b 100644 --- a/test/iar/settings/etl.wsdt +++ b/test/iar/settings/etl.wsdt @@ -19,7 +19,7 @@ - 20139537293 + 201395372934194759 @@ -36,30 +36,20 @@ - 0 - - - TabID-15390-31123 - Build - Build - - - - - 0 + 0 - TextEditor$WS_DIR$\..\test_compile.cpp00000010100TextEditor$WS_DIR$\..\..\variant.h000007533108631086TextEditor$WS_DIR$\..\..\error_handler.h000006347434743TextEditor$WS_DIR$\..\..\md5.cpp0000010302130210100000010000001 + TextEditor$WS_DIR$\..\test_compile.cpp00000337953995390TextEditor$WS_DIR$\..\..\variant.h000007533108631086TextEditor$WS_DIR$\..\..\error_handler.h000006347434743TextEditor$WS_DIR$\..\..\md5.cpp000001030213021TextEditor$WS_DIR$\..\..\map.h0000027147814780100000010000001 - iaridepm.enu1-2-2952333-2-220020010416720060217447995687100-1432619621106902488-2-2193825124096819242001002083200602104167200602 + iaridepm.enu1-2-2952333-2-2200200104167200602174479956871 diff --git a/test/keil/Test1.uvguix.John b/test/keil/Test1.uvguix.John index 60941e9a..57589c9e 100644 --- a/test/keil/Test1.uvguix.John +++ b/test/keil/Test1.uvguix.John @@ -92,8 +92,8 @@ 0 - 693 - 01000000040000000100000001000000010000000100000000000000020000000000000001000000010000000000000028000000280000000100000006000000000000000100000044443A5C55736572735C4A6F686E5C446F63756D656E74735C50726F6772616D6D696E675C4769744875625C65746C5C746573745C746573745F636F6D70696C652E6370700000000010746573745F636F6D70696C652E63707000000000F7B88600FFFFFFFF3B443A5C55736572735C4A6F686E5C446F63756D656E74735C50726F6772616D6D696E675C4769744875625C65746C5C63726336345F65636D612E68000000000C63726336345F65636D612E68000000009CC1B600FFFFFFFF36443A5C55736572735C4A6F686E5C446F63756D656E74735C50726F6772616D6D696E675C4769744875625C65746C5C696C6973742E680000000007696C6973742E6800000000BCA8E100FFFFFFFF3A443A5C55736572735C4A6F686E5C446F63756D656E74735C50726F6772616D6D696E675C4769744875625C65746C5C616C676F726974686D2E68000000000B616C676F726974686D2E6800000000F0A0A100FFFFFFFF38443A5C55736572735C4A6F686E5C446F63756D656E74735C50726F6772616D6D696E675C4769744875625C65746C5C696269747365742E680000000009696269747365742E6800000000BECEA100FFFFFFFF37443A5C55736572735C4A6F686E5C446F63756D656E74735C50726F6772616D6D696E675C4769744875625C65746C5C6269747365742E6800000000086269747365742E6800000000FFDC7800FFFFFFFF0100000010000000C5D4F200FFDC7800BECEA100F0A0A100BCA8E1009CC1B600F7B88600D9ADC200A5C2D700B3A6BE00EAD6A300F6FA7D00B5E99D005FC3CF00C1838300CACAD500010000000000000002000000940100006600000080070000FD030000 + 788 + 0100000004000000010000000100000001000000010000000000000002000000000000000100000001000000000000002800000028000000010000000700000000000000010000003E443A5C55736572735C4A6F686E5C446F63756D656E74735C50726F6772616D6D696E675C4769744875625C65746C5C6572726F725F68616E646C65722E68000000000F6572726F725F68616E646C65722E6800000000D9ADC200FFFFFFFF44443A5C55736572735C4A6F686E5C446F63756D656E74735C50726F6772616D6D696E675C4769744875625C65746C5C746573745C746573745F636F6D70696C652E6370700000000010746573745F636F6D70696C652E63707000000000F7B88600FFFFFFFF3B443A5C55736572735C4A6F686E5C446F63756D656E74735C50726F6772616D6D696E675C4769744875625C65746C5C63726336345F65636D612E68000000000C63726336345F65636D612E68000000009CC1B600FFFFFFFF36443A5C55736572735C4A6F686E5C446F63756D656E74735C50726F6772616D6D696E675C4769744875625C65746C5C696C6973742E680000000007696C6973742E6800000000BCA8E100FFFFFFFF3A443A5C55736572735C4A6F686E5C446F63756D656E74735C50726F6772616D6D696E675C4769744875625C65746C5C616C676F726974686D2E68000000000B616C676F726974686D2E6800000000F0A0A100FFFFFFFF38443A5C55736572735C4A6F686E5C446F63756D656E74735C50726F6772616D6D696E675C4769744875625C65746C5C696269747365742E680000000009696269747365742E6800000000BECEA100FFFFFFFF37443A5C55736572735C4A6F686E5C446F63756D656E74735C50726F6772616D6D696E675C4769744875625C65746C5C6269747365742E6800000000086269747365742E6800000000FFDC7800FFFFFFFF0100000010000000C5D4F200FFDC7800BECEA100F0A0A100BCA8E1009CC1B600F7B88600D9ADC200A5C2D700B3A6BE00EAD6A300F6FA7D00B5E99D005FC3CF00C1838300CACAD500010000000000000002000000940100006600000080070000FD030000 @@ -116,7 +116,7 @@ 16 - 81070000430000007E0C00003A040000 + 81070000000000007E0C0000E9030000 @@ -1304,7 +1304,7 @@ Build 678 - 00200000010000001000FFFF01001100434D4643546F6F6C426172427574746F6ECF7F0000000000001C0000000000000000000000000000000001000000010000000180D07F0000000000001D000000000000000000000000000000000100000001000000018030800000000000001E00000000000000000000000000000000010000000100000001809E8A0000000000001F0000000000000000000000000000000001000000010000000180D17F0000000004002000000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001804C8A0000000000002100000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000FFFF01001900434D4643546F6F6C426172436F6D626F426F78427574746F6EBA000000000000000000000000000000000000000000000000010000000100000096000000030020500000000008546172676574203196000000000000000100085461726765742031000000000180EB880000000000002200000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180C07F000000000000230000000000000000000000000000000001000000010000000180B08A000000000400240000000000000000000000000000000001000000010000000180A8010000000000004E00000000000000000000000000000000010000000100000001807202000000000000530000000000000000000000000000000001000000010000000180BE010000000000005000000000000000000000000000000000010000000100000000000000054275696C64CF010000 + 00200000010000001000FFFF01001100434D4643546F6F6C426172427574746F6ECF7F0000000004001C0000000000000000000000000000000001000000010000000180D07F0000000000001D000000000000000000000000000000000100000001000000018030800000000000001E00000000000000000000000000000000010000000100000001809E8A0000000000001F0000000000000000000000000000000001000000010000000180D17F0000000004002000000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001804C8A0000000000002100000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000FFFF01001900434D4643546F6F6C426172436F6D626F426F78427574746F6EBA000000000000000000000000000000000000000000000000010000000100000096000000030020500000000008546172676574203196000000000000000100085461726765742031000000000180EB880000000000002200000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180C07F000000000000230000000000000000000000000000000001000000010000000180B08A000000000400240000000000000000000000000000000001000000010000000180A8010000000000004E00000000000000000000000000000000010000000100000001807202000000000000530000000000000000000000000000000001000000010000000180BE010000000000005000000000000000000000000000000000010000000100000000000000054275696C64CF010000 583 @@ -2586,11 +2586,20 @@ 100 0 + + ..\..\error_handler.h + 22 + 39 + 40 + 1 + + 0 + ..\test_compile.cpp - 0 - 137 - 161 + 23 + 1 + 30 1 0 diff --git a/test/keil/Test1.uvoptx b/test/keil/Test1.uvoptx index 441ecf35..3ad73b5c 100644 --- a/test/keil/Test1.uvoptx +++ b/test/keil/Test1.uvoptx @@ -275,7 +275,7 @@ ETL - 0 + 1 0 0 0 @@ -442,18 +442,6 @@ 0 0 0 - ..\..\deque_base.h - deque_base.h - 0 - 0 - - - 3 - 22 - 5 - 0 - 0 - 0 ..\..\doxygen.h doxygen.h 0 @@ -461,7 +449,7 @@ 3 - 23 + 22 5 0 0 @@ -473,7 +461,7 @@ 3 - 24 + 23 5 0 0 @@ -485,7 +473,7 @@ 3 - 25 + 24 5 0 0 @@ -497,7 +485,7 @@ 3 - 26 + 25 5 0 0 @@ -509,7 +497,7 @@ 3 - 27 + 26 5 0 0 @@ -521,7 +509,7 @@ 3 - 28 + 27 5 0 0 @@ -533,19 +521,7 @@ 3 - 29 - 5 - 0 - 0 - 0 - ..\..\forward_list_base.h - forward_list_base.h - 0 - 0 - - - 3 - 30 + 28 5 0 0 @@ -557,7 +533,7 @@ 3 - 31 + 29 5 0 0 @@ -569,7 +545,7 @@ 3 - 32 + 30 5 0 0 @@ -581,7 +557,7 @@ 3 - 33 + 31 5 0 0 @@ -593,7 +569,7 @@ 3 - 34 + 32 5 0 0 @@ -605,7 +581,7 @@ 3 - 35 + 33 5 0 0 @@ -617,7 +593,7 @@ 3 - 36 + 34 5 0 0 @@ -629,7 +605,7 @@ 3 - 37 + 35 5 0 0 @@ -641,7 +617,7 @@ 3 - 38 + 36 5 0 0 @@ -653,7 +629,7 @@ 3 - 39 + 37 5 0 0 @@ -665,7 +641,7 @@ 3 - 40 + 38 5 0 0 @@ -677,7 +653,7 @@ 3 - 41 + 39 5 0 0 @@ -689,7 +665,7 @@ 3 - 42 + 40 5 0 0 @@ -701,19 +677,7 @@ 3 - 43 - 5 - 0 - 0 - 0 - ..\..\list_base.h - list_base.h - 0 - 0 - - - 3 - 44 + 41 5 0 0 @@ -725,19 +689,7 @@ 3 - 45 - 5 - 0 - 0 - 0 - ..\..\map_base.h - map_base.h - 0 - 0 - - - 3 - 46 + 42 5 0 0 @@ -749,7 +701,7 @@ 3 - 47 + 43 5 0 0 @@ -761,7 +713,7 @@ 3 - 48 + 44 5 0 0 @@ -773,7 +725,7 @@ 3 - 49 + 45 5 0 0 @@ -785,7 +737,7 @@ 3 - 50 + 46 5 0 0 @@ -797,7 +749,7 @@ 3 - 51 + 47 5 0 0 @@ -809,7 +761,7 @@ 3 - 52 + 48 5 0 0 @@ -821,7 +773,7 @@ 3 - 53 + 49 5 0 0 @@ -833,19 +785,7 @@ 3 - 54 - 5 - 0 - 0 - 0 - ..\..\queue_base.h - queue_base.h - 0 - 0 - - - 3 - 55 + 50 5 0 0 @@ -857,7 +797,7 @@ 3 - 56 + 51 5 0 0 @@ -869,19 +809,7 @@ 3 - 57 - 5 - 0 - 0 - 0 - ..\..\stack_base.h - stack_base.h - 0 - 0 - - - 3 - 58 + 52 5 0 0 @@ -893,7 +821,7 @@ 3 - 59 + 53 5 0 0 @@ -905,7 +833,7 @@ 3 - 60 + 54 5 0 0 @@ -917,7 +845,7 @@ 3 - 61 + 55 5 0 0 @@ -929,19 +857,7 @@ 3 - 62 - 5 - 0 - 0 - 0 - ..\..\vector_base.h - vector_base.h - 0 - 0 - - - 3 - 63 + 56 5 0 0 @@ -953,7 +869,7 @@ 3 - 64 + 57 8 0 0 @@ -965,7 +881,7 @@ 3 - 65 + 58 8 0 0 @@ -977,7 +893,7 @@ 3 - 66 + 59 8 0 0 @@ -989,7 +905,7 @@ 3 - 67 + 60 8 0 0 @@ -1001,7 +917,7 @@ 3 - 68 + 61 8 0 0 @@ -1013,7 +929,7 @@ 3 - 69 + 62 8 0 0 @@ -1025,7 +941,7 @@ 3 - 70 + 63 5 0 0 @@ -1037,7 +953,7 @@ 3 - 71 + 64 5 0 0 @@ -1049,7 +965,7 @@ 3 - 72 + 65 5 0 0 @@ -1059,6 +975,230 @@ 0 0 + + 3 + 66 + 5 + 0 + 0 + 0 + ..\..\error_handler.h + error_handler.h + 0 + 0 + + + + + Private + 0 + 0 + 0 + 0 + + 4 + 67 + 5 + 0 + 0 + 0 + ..\..\private\deque_base.h + deque_base.h + 0 + 0 + + + 4 + 68 + 5 + 0 + 0 + 0 + ..\..\private\flat_map_base.h + flat_map_base.h + 0 + 0 + + + 4 + 69 + 5 + 0 + 0 + 0 + ..\..\private\flat_multimap_base.h + flat_multimap_base.h + 0 + 0 + + + 4 + 70 + 5 + 0 + 0 + 0 + ..\..\private\flat_multiset_base.h + flat_multiset_base.h + 0 + 0 + + + 4 + 71 + 5 + 0 + 0 + 0 + ..\..\private\flat_set_base.h + flat_set_base.h + 0 + 0 + + + 4 + 72 + 5 + 0 + 0 + 0 + ..\..\private\forward_list_base.h + forward_list_base.h + 0 + 0 + + + 4 + 73 + 5 + 0 + 0 + 0 + ..\..\private\list_base.h + list_base.h + 0 + 0 + + + 4 + 74 + 5 + 0 + 0 + 0 + ..\..\private\map_base.h + map_base.h + 0 + 0 + + + 4 + 75 + 5 + 0 + 0 + 0 + ..\..\private\multimap_base.h + multimap_base.h + 0 + 0 + + + 4 + 76 + 5 + 0 + 0 + 0 + ..\..\private\multiset_base.h + multiset_base.h + 0 + 0 + + + 4 + 77 + 5 + 0 + 0 + 0 + ..\..\private\pool_base.h + pool_base.h + 0 + 0 + + + 4 + 78 + 5 + 0 + 0 + 0 + ..\..\private\priority_queue_base.h + priority_queue_base.h + 0 + 0 + + + 4 + 79 + 5 + 0 + 0 + 0 + ..\..\private\queue_base.h + queue_base.h + 0 + 0 + + + 4 + 80 + 5 + 0 + 0 + 0 + ..\..\private\set_base.h + set_base.h + 0 + 0 + + + 4 + 81 + 5 + 0 + 0 + 0 + ..\..\private\stack_base.h + stack_base.h + 0 + 0 + + + 4 + 82 + 5 + 0 + 0 + 0 + ..\..\private\unordered_map_base.h + unordered_map_base.h + 0 + 0 + + + 4 + 83 + 5 + 0 + 0 + 0 + ..\..\private\vector_base.h + vector_base.h + 0 + 0 + diff --git a/test/keil/Test1.uvprojx b/test/keil/Test1.uvprojx index 2f2d7ec6..8f8d78b6 100644 --- a/test/keil/Test1.uvprojx +++ b/test/keil/Test1.uvprojx @@ -526,11 +526,6 @@ 5 ..\..\deque.h - - deque_base.h - 5 - ..\..\deque_base.h - doxygen.h 5 @@ -566,11 +561,6 @@ 5 ..\..\forward_list.h - - forward_list_base.h - 5 - ..\..\forward_list_base.h - function.h 5 @@ -636,21 +626,11 @@ 5 ..\..\list.h - - list_base.h - 5 - ..\..\list_base.h - map.h 5 ..\..\map.h - - map_base.h - 5 - ..\..\map_base.h - log.h 5 @@ -691,11 +671,6 @@ 5 ..\..\queue.h - - queue_base.h - 5 - ..\..\queue_base.h - smallest.h 5 @@ -706,11 +681,6 @@ 5 ..\..\stack.h - - stack_base.h - 5 - ..\..\stack_base.h - static_assert.h 5 @@ -731,11 +701,6 @@ 5 ..\..\vector.h - - vector_base.h - 5 - ..\..\vector_base.h - visitor.h 5 @@ -786,6 +751,101 @@ 5 ..\..\io_port.h + + error_handler.h + 5 + ..\..\error_handler.h + + + + + Private + + + deque_base.h + 5 + ..\..\private\deque_base.h + + + flat_map_base.h + 5 + ..\..\private\flat_map_base.h + + + flat_multimap_base.h + 5 + ..\..\private\flat_multimap_base.h + + + flat_multiset_base.h + 5 + ..\..\private\flat_multiset_base.h + + + flat_set_base.h + 5 + ..\..\private\flat_set_base.h + + + forward_list_base.h + 5 + ..\..\private\forward_list_base.h + + + list_base.h + 5 + ..\..\private\list_base.h + + + map_base.h + 5 + ..\..\private\map_base.h + + + multimap_base.h + 5 + ..\..\private\multimap_base.h + + + multiset_base.h + 5 + ..\..\private\multiset_base.h + + + pool_base.h + 5 + ..\..\private\pool_base.h + + + priority_queue_base.h + 5 + ..\..\private\priority_queue_base.h + + + queue_base.h + 5 + ..\..\private\queue_base.h + + + set_base.h + 5 + ..\..\private\set_base.h + + + stack_base.h + 5 + ..\..\private\stack_base.h + + + unordered_map_base.h + 5 + ..\..\private\unordered_map_base.h + + + vector_base.h + 5 + ..\..\private\vector_base.h + diff --git a/test/test_compile.cpp b/test/test_compile.cpp index ba418f68..e2dd17d8 100644 --- a/test/test_compile.cpp +++ b/test/test_compile.cpp @@ -15,6 +15,9 @@ #include "vector.h" #include "variant.h" #include "list.h" +#include "map.h" + +#include #if defined(COMPILER_KEIL) #pragma diag_suppress 550 @@ -51,7 +54,7 @@ void test_algorithm() int y = 1; int* p; bool b; - + // minmax_element result1 = etl::minmax_element(etl::begin(data), etl::end(data)); result1 = etl::minmax_element(etl::begin(data), etl::end(data), std::greater()); @@ -359,6 +362,22 @@ void test_list() data2.erase(it2); } +//***************************************************************************** +// map +//***************************************************************************** +void test_map() +{ + typedef etl::map Data; + + Data data; + + data.insert(std::pair(1, 2)); + data.insert(std::pair(3, 4)); + + Data::iterator it = data.begin(); + data.erase(it); +} + //***************************************************************************** // main //***************************************************************************** From b794ce623a90229bc1421ba22aeacab0f5f026c9 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 9 Jan 2016 10:28:56 +0000 Subject: [PATCH 06/43] Added iterator test for empty container --- test/test_basic_intrusive_forward_list.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/test_basic_intrusive_forward_list.cpp b/test/test_basic_intrusive_forward_list.cpp index 7d678a45..9c1f5712 100644 --- a/test/test_basic_intrusive_forward_list.cpp +++ b/test/test_basic_intrusive_forward_list.cpp @@ -155,6 +155,14 @@ namespace CHECK(!data.empty()); } + ////************************************************************************* + TEST_FIXTURE(SetupFixture, test_begin_end_empty) + { + DataNDC data; + + CHECK(data.begin() == data.end()); + } + ////************************************************************************* TEST_FIXTURE(SetupFixture, test_iterator) { From 737c1c8abd4c3c4efec1cc95e9c7db5fc12bdd37 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 9 Jan 2016 11:21:12 +0000 Subject: [PATCH 07/43] Removed unecessary base class --- private/priority_queue_base.h | 161 ---------------------------------- 1 file changed, 161 deletions(-) delete mode 100644 private/priority_queue_base.h diff --git a/private/priority_queue_base.h b/private/priority_queue_base.h deleted file mode 100644 index 9883663b..00000000 --- a/private/priority_queue_base.h +++ /dev/null @@ -1,161 +0,0 @@ -///\file - -/****************************************************************************** -The MIT License(MIT) - -Embedded Template Library. -https://github.com/ETLCPP/etl -http://www.etlcpp.com - -Copyright(c) 2015 jwellbelove, rlindeman - -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_IN_IPRIORITY_QUEUE_H__ -#error This header is a private element of etl::priority_queue & etl::ipriority_queue -#endif - -#ifndef __ETL_PRIORITY_QUEUE_BASE__ -#define __ETL_PRIORITY_QUEUE_BASE__ - -#include - -#include "../exception.h" -#include "../error_handler.h" - -#undef ETL_FILE -#define ETL_FILE "12" - -namespace etl -{ - //*************************************************************************** - /// The base class for priority_queue exceptions. - ///\ingroup queue - //*************************************************************************** - class priority_queue_exception : public exception - { - public: - - priority_queue_exception(string_type what, string_type file_name, numeric_type line_number) - : exception(what, file_name, line_number) - { - } - }; - - //*************************************************************************** - /// The exception thrown when the queue is full. - ///\ingroup queue - //*************************************************************************** - class priority_queue_full : public priority_queue_exception - { - public: - - priority_queue_full(string_type file_name, numeric_type line_number) - : priority_queue_exception(ETL_ERROR_TEXT("priority_queue:full", ETL_FILE"A"), file_name, line_number) - { - } - }; - - //*************************************************************************** - /// The priority queue iterator exception on reversed iterators - ///\ingroup queue - //*************************************************************************** - class priority_queue_iterator : public priority_queue_exception - { - public: - - priority_queue_iterator(string_type file_name, numeric_type line_number) - : priority_queue_exception(ETL_ERROR_TEXT("priority_queue:iterator", ETL_FILE"B"), file_name, line_number) - { - } - }; - - //*************************************************************************** - /// The base class for all priority queues. - ///\ingroup queue - //*************************************************************************** - class priority_queue_base - { - public: - - typedef size_t size_type; ///< The type used for determining the size of queue. - - //************************************************************************* - /// Returns the current number of items in the priority queue. - //************************************************************************* - size_type size() const - { - return current_size; - } - - //************************************************************************* - /// Returns the maximum number of items that can be queued. - //************************************************************************* - size_type max_size() const - { - return MAX_SIZE; - } - - //************************************************************************* - /// Checks to see if the priority queue is empty. - /// \return true if the queue is empty, otherwise false - //************************************************************************* - bool empty() const - { - return current_size == 0; - } - - //************************************************************************* - /// Checks to see if the priority queue is full. - /// \return true if the priority queue is full, otherwise false - //************************************************************************* - bool full() const - { - return current_size == MAX_SIZE; - } - - //************************************************************************* - /// Returns the remaining capacity. - ///\return The remaining capacity. - //************************************************************************* - size_t available() const - { - return max_size() - size(); - } - - protected: - - //************************************************************************* - /// The constructor that is called from derived classes. - //************************************************************************* - priority_queue_base(size_type max_size) - : current_size(0), - MAX_SIZE(max_size) - { - } - - size_type current_size; ///< The number of items in the priority queue. - const size_type MAX_SIZE; ///< The maximum number of items in the priority queue. - }; -} - -#undef ETL_FILE - -#endif From 760f08db0bc14fe15a24c3b0c5240c71444d7ddd Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 9 Jan 2016 11:21:45 +0000 Subject: [PATCH 08/43] Comment spelling --- bitset.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitset.h b/bitset.h index f3b06881..d873fcf3 100644 --- a/bitset.h +++ b/bitset.h @@ -59,7 +59,7 @@ namespace etl { //************************************************************************* /// The class emulates an array of bool elements, but optimized for space allocation. - /// Will accomodate any number of bits. + /// Will accommodate any number of bits. /// Does not use std::string. ///\tparam N The number of bits. ///\ingroup bitset From fff1b4d7d4457b898a0c3774f5ed9056d1dc1ef5 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 9 Jan 2016 11:22:31 +0000 Subject: [PATCH 09/43] Greater compliance with C++ spec. --- deque.h | 5 +---- forward_list.h | 5 +---- list.h | 6 +----- map.h | 6 ++---- multimap.h | 6 ++---- multiset.h | 6 ++---- set.h | 6 ++---- vector.h | 7 +++---- 8 files changed, 14 insertions(+), 33 deletions(-) diff --git a/deque.h b/deque.h index 805247cc..bf7cb736 100644 --- a/deque.h +++ b/deque.h @@ -83,7 +83,7 @@ namespace etl deque() : ideque(reinterpret_cast(&buffer[0]), MAX_SIZE, BUFFER_SIZE) { - initialise(); + ideque::initialise(); } //************************************************************************* @@ -92,7 +92,6 @@ namespace etl deque(const deque& other) : ideque(reinterpret_cast(&buffer[0]), MAX_SIZE, BUFFER_SIZE) { - initialise(); ideque::assign(other.begin(), other.end()); } @@ -103,7 +102,6 @@ namespace etl deque(TIterator begin, TIterator end) : ideque(reinterpret_cast(&buffer[0]), MAX_SIZE, BUFFER_SIZE) { - initialise(); ideque::assign(begin, end); } @@ -113,7 +111,6 @@ namespace etl explicit deque(size_t n, typename ideque::parameter_t value = value_type()) : ideque(reinterpret_cast(&buffer[0]), MAX_SIZE, BUFFER_SIZE) { - initialise(); ideque::assign(n, value); } diff --git a/forward_list.h b/forward_list.h index 4bdffb2a..ea61e215 100644 --- a/forward_list.h +++ b/forward_list.h @@ -71,7 +71,7 @@ namespace etl forward_list() : iforward_list(node_pool, MAX_SIZE) { - initialise(); + iforward_list::initialise(); } //************************************************************************* @@ -80,7 +80,6 @@ namespace etl explicit forward_list(size_t initialSize, typename iforward_list::parameter_t value = T()) : iforward_list(node_pool, MAX_SIZE) { - initialise(); iforward_list::assign(initialSize, value); } @@ -90,7 +89,6 @@ namespace etl forward_list(const forward_list& other) : iforward_list(node_pool, MAX_SIZE) { - initialise(); iforward_list::assign(other.cbegin(), other.cend()); } @@ -101,7 +99,6 @@ namespace etl forward_list(TIterator first, TIterator last) : iforward_list(node_pool, MAX_SIZE) { - initialise(); iforward_list::assign(first, last); } diff --git a/list.h b/list.h index 3e9e5e7d..b61e0f74 100644 --- a/list.h +++ b/list.h @@ -71,7 +71,7 @@ namespace etl list() : ilist(node_pool, MAX_SIZE) { - initialise(); + ilist::initialise(); } //************************************************************************* @@ -80,7 +80,6 @@ namespace etl explicit list(size_t initialSize) : ilist(node_pool, MAX_SIZE) { - initialise(); ilist::assign(initialSize, T()); } @@ -90,7 +89,6 @@ namespace etl list(size_t initialSize, typename ilist::parameter_t value) : ilist(node_pool, MAX_SIZE) { - initialise(); ilist::assign(initialSize, value); } @@ -100,7 +98,6 @@ namespace etl list(const list& other) : ilist(node_pool, MAX_SIZE) { - initialise(); ilist::assign(other.cbegin(), other.cend()); } @@ -111,7 +108,6 @@ namespace etl list(TIterator first, TIterator last) : ilist(node_pool, MAX_SIZE) { - initialise(); ilist::assign(first, last); } diff --git a/map.h b/map.h index c3b57782..9ec0c71e 100644 --- a/map.h +++ b/map.h @@ -63,7 +63,7 @@ namespace etl map() : imap(node_pool, MAX_SIZE) { - initialise(); + imap::initialise(); } //************************************************************************* @@ -72,7 +72,6 @@ namespace etl map(const map& other) : imap(node_pool, MAX_SIZE) { - initialise(); imap::assign(other.cbegin(), other.cend()); } @@ -86,8 +85,7 @@ namespace etl map(TIterator first, TIterator last) : imap(node_pool, MAX_SIZE) { - initialise(); - imap::insert(first, last); + imap::assign(first, last); } //************************************************************************* diff --git a/multimap.h b/multimap.h index f98b8431..06658b4b 100644 --- a/multimap.h +++ b/multimap.h @@ -62,7 +62,7 @@ namespace etl multimap() : imultimap(node_pool, MAX_SIZE) { - initialise(); + imultimap::initialise(); } //************************************************************************* @@ -71,7 +71,6 @@ namespace etl explicit multimap(const multimap& other) : imultimap(node_pool, MAX_SIZE) { - initialise(); imultimap::assign(other.cbegin(), other.cend()); } @@ -85,8 +84,7 @@ namespace etl multimap(TIterator first, TIterator last) : imultimap(node_pool, MAX_SIZE) { - initialise(); - imultimap::insert(first, last); + imultimap::assign(first, last); } //************************************************************************* diff --git a/multiset.h b/multiset.h index 3983caa8..e3ba00e0 100644 --- a/multiset.h +++ b/multiset.h @@ -62,7 +62,7 @@ namespace etl multiset() : imultiset(node_pool, MAX_SIZE) { - initialise(); + imultiset::initialise(); } //************************************************************************* @@ -71,7 +71,6 @@ namespace etl explicit multiset(const multiset& other) : imultiset(node_pool, MAX_SIZE) { - initialise(); imultiset::assign(other.cbegin(), other.cend()); } @@ -85,8 +84,7 @@ namespace etl multiset(TIterator first, TIterator last) : imultiset(node_pool, MAX_SIZE) { - initialise(); - imultiset::insert(first, last); + imultiset::assign(first, last); } //************************************************************************* diff --git a/set.h b/set.h index 52f02600..3fb2ec2f 100644 --- a/set.h +++ b/set.h @@ -63,7 +63,7 @@ namespace etl set() : iset(node_pool, MAX_SIZE) { - initialise(); + iset::initialise(); } //************************************************************************* @@ -72,7 +72,6 @@ namespace etl explicit set(const set& other) : iset(node_pool, MAX_SIZE) { - initialise(); iset::assign(other.cbegin(), other.cend()); } @@ -86,8 +85,7 @@ namespace etl set(TIterator first, TIterator last) : iset(node_pool, MAX_SIZE) { - initialise(); - iset::insert(first, last); + iset::assign(first, last); } //************************************************************************* diff --git a/vector.h b/vector.h index 468ac8d2..9dd0e38a 100644 --- a/vector.h +++ b/vector.h @@ -67,7 +67,7 @@ namespace etl vector() : ivector(reinterpret_cast(&buffer), MAX_SIZE) { - initialise(); + ivector::initialise(); } //************************************************************************* @@ -77,7 +77,7 @@ namespace etl explicit vector(size_t initialSize) : ivector(reinterpret_cast(&buffer), MAX_SIZE) { - initialise(); + ivector::initialise(); ivector::resize(initialSize); } @@ -89,7 +89,7 @@ namespace etl vector(size_t initialSize, typename ivector::parameter_t value) : ivector(reinterpret_cast(&buffer), MAX_SIZE) { - initialise(); + ivector::initialise(); ivector::resize(initialSize, value); } @@ -103,7 +103,6 @@ namespace etl vector(TIterator first, TIterator last) : ivector(reinterpret_cast(&buffer), MAX_SIZE) { - initialise(); ivector::assign(first, last); } From 1c9cf2246bccb4be09cf2d31c260ea8ee8242f5a Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 9 Jan 2016 13:06:38 +0000 Subject: [PATCH 10/43] Fixed insert overwriting existing value. --- iflat_map.h | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/iflat_map.h b/iflat_map.h index ff91ac5b..0899ac34 100644 --- a/iflat_map.h +++ b/iflat_map.h @@ -224,7 +224,7 @@ namespace etl if (i_element == end()) { // Doesn't exist, so create a new one. - value_type value(key, mapped_type()); + value_type value(key, mapped_type()); i_element = insert(value).first; } @@ -309,14 +309,7 @@ namespace etl { // Not at the end. // Existing element? - if (value.first == i_element->first) - { - // Yes. - i_element->second = value.second; - result.first = i_element; - result.second = false; - } - else + if (value.first != i_element->first) { // A new one. ETL_ASSERT(!buffer.full(), ETL_ERROR(flat_map_full)); From d1651535e1b950730d0ab7acdfb545093eaf220e Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 9 Jan 2016 13:07:14 +0000 Subject: [PATCH 11/43] Added tests to check for inserts overwriting existing values. --- test/test_flat_map.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++ test/test_map.cpp | 40 +++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/test/test_flat_map.cpp b/test/test_flat_map.cpp index bdcd006e..711a9566 100644 --- a/test/test_flat_map.cpp +++ b/test/test_flat_map.cpp @@ -259,6 +259,31 @@ namespace CHECK_EQUAL(compare_data[9], data[9]); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_index_value_changed) + { + Compare_DataNDC compare_data; + DataNDC data; + + data[0] = N0; + compare_data[0] = N0; + + bool isEqual = Check_Equal(data.begin(), + data.end(), + compare_data.begin()); + + CHECK(isEqual); + + data[0] = N2; + compare_data[0] = N2; + + isEqual = Check_Equal(data.begin(), + data.end(), + compare_data.begin()); + + CHECK(isEqual); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_at) { @@ -345,6 +370,31 @@ namespace CHECK(isEqual); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_value_changed) + { + Compare_DataNDC compare_data; + DataNDC data; + + data.insert(DataNDC::value_type(0, N0)); + compare_data.insert(std::make_pair(0, N0)); + + bool isEqual = Check_Equal(data.begin(), + data.end(), + compare_data.begin()); + + CHECK(isEqual); + + data.insert(std::make_pair(0, N2)); + compare_data.insert(std::make_pair(0, N2)); + + isEqual = Check_Equal(data.begin(), + data.end(), + compare_data.begin()); + + CHECK(isEqual); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_value_multiple) { diff --git a/test/test_map.cpp b/test/test_map.cpp index d783bcc0..4d5b67a9 100644 --- a/test/test_map.cpp +++ b/test/test_map.cpp @@ -265,6 +265,21 @@ namespace CHECK_EQUAL(data["9"], compare_data["9"]); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_index_value_changed) + { + Compare_Data compare_data; + Data data; + + data["0"] = 0; + compare_data["0"] = 0; + + data["0"] = 1; + compare_data["0"] = 1; + + CHECK_EQUAL(data["0"], compare_data["0"]); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_at) { @@ -365,6 +380,31 @@ namespace CHECK(isEqual); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_value_changed) + { + Compare_Data compare_data; + Data data; + + data.insert(Data::value_type(std::string("0"), 0)); + compare_data.insert(std::make_pair(std::string("0"), 0)); + + bool isEqual = Check_Equal(data.begin(), + data.end(), + compare_data.begin()); + + CHECK(isEqual); + + data.insert(std::make_pair(std::string("0"), 1)); + compare_data.insert(std::make_pair(std::string("0"), 1)); + + isEqual = Check_Equal(data.begin(), + data.end(), + compare_data.begin()); + + CHECK(isEqual); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_hint_value) { From bbf835a8a67d00668c322cc15158b478c5afeb39 Mon Sep 17 00:00:00 2001 From: jwellbelove Date: Mon, 11 Jan 2016 15:13:01 +0000 Subject: [PATCH 12/43] Initial parts of string support. Incomplete. --- basic_string.h | 139 ++++++++++++++++++++ char_traits.h | 336 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 475 insertions(+) create mode 100644 basic_string.h create mode 100644 char_traits.h diff --git a/basic_string.h b/basic_string.h new file mode 100644 index 00000000..7ba871e9 --- /dev/null +++ b/basic_string.h @@ -0,0 +1,139 @@ +///\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_BASIC_STRING__ +#define __ETL_BASIC_STRING__ + +#include +#include +#include + +#include "ibasic_string.h" +#include "container.h" +#include "alignment.h" +#include "array.h" + +//***************************************************************************** +///\defgroup basic_string basic_string +/// A basic_string with the capacity defined at compile time. +///\ingroup containers +//***************************************************************************** + +namespace etl +{ + template + //*************************************************************************** + /// A basic_string implementation that uses a fixed size buffer. + ///\tparam T The element type. + ///\tparam MAX_SIZE_ The maximum number of elements that can be stored. + ///\ingroup basic_string + //*************************************************************************** + class basic_string : public ibasic_string + { + public: + + static const size_t MAX_SIZE = MAX_SIZE_; + + //************************************************************************* + /// Constructor. + //************************************************************************* + basic_string() + : ibasic_string(reinterpret_cast(&buffer), MAX_SIZE) + { + ibasic_string::initialise(); + } + + //************************************************************************* + /// Constructor, with size. + ///\param initialSize The initial size of the basic_string. + //************************************************************************* + explicit basic_string(size_t initialSize) + : ibasic_string(reinterpret_cast(&buffer), MAX_SIZE) + { + ibasic_string::initialise(); + ibasic_string::resize(initialSize); + } + + //************************************************************************* + /// Constructor, from null terminated text. + ///\param text The initial text of the basic_string. + //************************************************************************* + basic_string(const T* text) + : ibasic_string(reinterpret_cast(&buffer), MAX_SIZE) + { + ibasic_string::initialise(); + ibasic_string::assign(text, text + strlen) + } + + //************************************************************************* + /// Constructor, from initial size and value. + ///\param initialSize The initial size of the basic_string. + ///\param value The value to fill the basic_string with. + //************************************************************************* + basic_string(size_t initialSize, typename ibasic_string::parameter_t value) + : ibasic_string(reinterpret_cast(&buffer), MAX_SIZE) + { + ibasic_string::initialise(); + ibasic_string::resize(initialSize, value); + } + + //************************************************************************* + /// Constructor, from an iterator range. + ///\tparam TIterator The iterator type. + ///\param first The iterator to the first element. + ///\param last The iterator to the last element + 1. + //************************************************************************* + template + basic_string(TIterator first, TIterator last) + : ibasic_string(reinterpret_cast(&buffer), MAX_SIZE) + { + ibasic_string::assign(first, last); + } + + //************************************************************************* + /// Assignment operator. + //************************************************************************* + basic_string& operator = (const basic_string& rhs) + { + if (&rhs != this) + { + ibasic_string::assign(rhs.cbegin(), rhs.cend()); + } + + return *this; + } + + private: + + typename etl::aligned_storage::value>::type buffer; + }; +} + +#endif diff --git a/char_traits.h b/char_traits.h new file mode 100644 index 00000000..98d65f22 --- /dev/null +++ b/char_traits.h @@ -0,0 +1,336 @@ +///\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_CHAR_TRAITS__ +#define __ETL_CHAR_TRAITS__ + +#include "stdint.h" +#include "algorithms.h" + +//***************************************************************************** +///\defgroup char_traits char_traits +/// Character traits +///\ingroup string +//***************************************************************************** + +namespace etl +{ + template struct char_traits; + + //*************************************************************************** + /// Specialisation for char. + //*************************************************************************** + template<> struct char_traits + { + typedef char char_type; + typedef int int_type; + typedef long long off_type; + typedef size_t pos_type; + typedef char state_type; + + //************************************************************************* + static bool eq(char_type a, char_type b) + { + return a == b; + } + + //************************************************************************* + static bool lt(char_type a, char_type b) + { + return a < b; + } + + //************************************************************************* + static size_t length(const char* str) + { + size_t count = 0; + + if (str != 0) + { + while (*str++ != 0) + { + ++count; + } + } + + return count; + } + + //************************************************************************* + static void assign(char_type& r, const char_type& c) + { + r = a; + } + + //************************************************************************* + static char_type* assign(char_type* p, size_t n, char_type c) + { + if (p != 0) + { + std::fill_n(p, n, c); + } + + return p; + } + + //************************************************************************* + static char_type* move(char_type* dest, const char_type* src, std::size_t count) + { + if ((dest < src) || (dest > (src + count)) + { + etl::copy_n(src, src + count, dest); + } + else + { + etl::copy_n(std::reverse_iterator(src + count), + std::reverse_iterator(src), + std::reverse_iterator(dest + count)); + } + } + }; + + //*************************************************************************** + /// Specialisation for wchar_t + //*************************************************************************** + template <> struct char_traits + { + typedef wchar_t char_type; + typedef wchar_t int_type; + typedef long long off_type; + typedef size_t pos_type; + typedef char state_type; + + //************************************************************************* + static bool eq(char_type a, char_type b) + { + return a == b; + } + + //************************************************************************* + static bool lt(char_type a, char_type b) + { + return a < b; + } + + //************************************************************************* + static size_t length(const wchar_t* str) + { + size_t count = 0; + + if (str != 0) + { + while (*str++ != 0) + { + ++count; + } + } + + return count; + } + + //************************************************************************* + static void assign(char_type& r, const char_type& c) + { + r = a; + } + + //************************************************************************* + static char_type* assign(char_type* p, size_t n, char_type c) + { + if (p != 0) + { + std::fill_n(p, n, c); + } + + return p; + } + + //************************************************************************* + static char_type* move(char_type* dest, const char_type* src, std::size_t count) + { + if ((dest < src) || (dest > (src + count)) + { + etl::copy_n(src, src + count, dest); + } + else + { + etl::copy_n(std::reverse_iterator(src + count), + std::reverse_iterator(src), + std::reverse_iterator(dest + count)); + } + } + }; + + //*************************************************************************** + /// Specialisation for char16_t. + //*************************************************************************** + template <> struct char_traits + { + typedef char16_t char_type; + typedef uint_least16_t int_type; + typedef long long off_type; + typedef size_t pos_type; + typedef char state_type; + + //************************************************************************* + static bool eq(char_type a, char_type b) + { + return a == b; + } + + //************************************************************************* + static bool lt(char_type a, char_type b) + { + return a < b; + } + + //************************************************************************* + static size_t length(const char16_t* str) + { + size_t count = 0; + + if (str != 0) + { + while (*str++ != 0) + { + ++count; + } + } + + return count; + } + + //************************************************************************* + static void assign(char_type& r, const char_type& c) + { + r = a; + } + + //************************************************************************* + static char_type* assign(char_type* p, size_t n, char_type c) + { + if (p != 0) + { + std::fill_n(p, n, c); + } + + return p; + } + + //************************************************************************* + static char_type* move(char_type* dest, const char_type* src, std::size_t count) + { + if ((dest < src) || (dest > (src + count)) + { + etl::copy_n(src, src + count, dest); + } + else + { + etl::copy_n(std::reverse_iterator(src + count), + std::reverse_iterator(src), + std::reverse_iterator(dest + count)); + } + } + } + + //*************************************************************************** + /// Specialisation for char32_t. + //*************************************************************************** + template <> struct char_traits + { + typedef char16_t char_type; + typedef uint_least32_t int_type; + typedef long long off_type; + typedef size_t pos_type; + typedef char state_type; + + //************************************************************************* + static bool eq(char_type a, char_type b) + { + return a == b; + } + + //************************************************************************* + static bool lt(char_type a, char_type b) + { + return a < b; + } + + //************************************************************************* + static size_t length(const char32_t* str) + { + size_t count = 0; + + if (str != 0) + { + while (*str++ != 0) + { + ++count; + } + } + + return count; + } + + //************************************************************************* + static void assign(char_type& r, const char_type& c) + { + r = a; + } + + //************************************************************************* + static char_type* assign(char_type* p, size_t n, char_type c) + { + if (p != 0) + { + std::fill_n(p, n, c); + } + + return p; + } + + //************************************************************************* + static char_type* move(char_type* dest, const char_type* src, std::size_t count) + { + if ((dest < src) || (dest > (src + count)) + { + etl::copy_n(src, src + count, dest); + } + else + { + etl::copy_n(std::reverse_iterator(src + count), + std::reverse_iterator(src), + std::reverse_iterator(dest + count)); + } + } + } +} + +#endif From ea12a093641782954ff04f4dae7d2c707e28c360 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 11 Jan 2016 23:56:09 +0000 Subject: [PATCH 13/43] Modified functions comments about exceptions. --- ideque.h | 26 +++++++++++++------------- iflat_map.h | 10 +++++----- iflat_multimap.h | 10 +++++----- iflat_multiset.h | 10 +++++----- iflat_set.h | 10 +++++----- iforward_list.h | 4 ++-- ilist.h | 2 +- imap.h | 16 ++++++++-------- imultimap.h | 12 ++++++------ imultiset.h | 12 ++++++------ ipool.h | 10 ++++------ ipriority_queue.h | 6 +++--- iqueue.h | 4 ++-- iset.h | 12 ++++++------ istack.h | 4 ++-- ivector.h | 24 ++++++++++++------------ observer.h | 2 +- 17 files changed, 86 insertions(+), 88 deletions(-) diff --git a/ideque.h b/ideque.h index ad80574a..f84f976f 100644 --- a/ideque.h +++ b/ideque.h @@ -486,7 +486,7 @@ namespace etl //************************************************************************* /// Assigns 'n' copies of a value to the deque. - /// If ETL_THROW_EXCEPTIONS is defined, throws an etl::deque_full is 'n' is too large. + /// If asserts or exceptions are enabled, throws an etl::deque_full is 'n' is too large. ///\param n The number of copies to assign. ///\param value The value to add.< //************************************************************************* @@ -508,7 +508,7 @@ namespace etl //************************************************************************* /// Gets a reference to the item at the index. - /// If ETL_THROW_EXCEPTIONS is defined, throws an etl::deque_out_of_bounds if the index is out of range. + /// If asserts or exceptions are enabled, throws an etl::deque_out_of_bounds if the index is out of range. ///\return A reference to the item at the index. //************************************************************************* reference at(size_t index) @@ -523,7 +523,7 @@ namespace etl //************************************************************************* /// Gets a const reference to the item at the index. - /// If ETL_THROW_EXCEPTIONS is defined, throws an etl::deque_out_of_bounds if the index is out of range. + /// If asserts or exceptions are enabled, throws an etl::deque_out_of_bounds if the index is out of range. ///\return A const reference to the item at the index. //************************************************************************* const_reference at(size_t index) const @@ -702,7 +702,7 @@ namespace etl //************************************************************************* /// Inserts data into the deque. - /// If ETL_THROW_EXCEPTIONS is defined, throws an etl::deque_full if the deque is full. + /// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is full. ///\param insert_position>The insert position. ///\param value>The value to insert. //************************************************************************* @@ -754,7 +754,7 @@ namespace etl //************************************************************************* /// Inserts 'n' copies of a value into the deque. - /// If ETL_THROW_EXCEPTIONS is defined, throws an etl::deque_full if the deque is full. + /// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is full. ///\param insert_position The insert position. ///\param n The number of values to insert. ///\param value The value to insert. @@ -863,7 +863,7 @@ namespace etl //************************************************************************* /// Inserts a range into the deque. - /// If ETL_THROW_EXCEPTIONS is defined, throws an etl::deque_empty if the deque is full. + /// If asserts or exceptions are enabled, throws an etl::deque_empty if the deque is full. ///\param insert_position>The insert position. ///\param range_begin The beginning of the range to insert. ///\param range_end The end of the range to insert. @@ -970,7 +970,7 @@ namespace etl //************************************************************************* /// Erase an item. - /// If ETL_THROW_EXCEPTIONS is defined, throws an etl::deque_out_of_bounds if the position is out of range. + /// If asserts or exceptions are enabled, throws an etl::deque_out_of_bounds if the position is out of range. ///\param erase_position The position to erase. //************************************************************************* iterator erase(const_iterator erase_position) @@ -1010,7 +1010,7 @@ namespace etl //************************************************************************* /// erase a range. - /// If ETL_THROW_EXCEPTIONS is defined, throws an etl::deque_out_of_bounds if the iterators are out of range. + /// If asserts or exceptions are enabled, throws an etl::deque_out_of_bounds if the iterators are out of range. ///\param range_begin The beginning of the range to erase. ///\param range_end The end of the range to erase. //************************************************************************* @@ -1077,7 +1077,7 @@ namespace etl //************************************************************************* /// Adds an item to the back of the deque. - /// If ETL_THROW_EXCEPTIONS is defined, throws an etl::deque_full is the deque is already full. + /// If asserts or exceptions are enabled, throws an etl::deque_full is the deque is already full. ///\param item The item to push to the deque. //************************************************************************* void push_back(parameter_t item) @@ -1090,7 +1090,7 @@ namespace etl //************************************************************************* /// Adds one to the front of the deque and returns a reference to the new element. - /// If ETL_THROW_EXCEPTIONS is defined, throws an etl::deque_full is the deque is already full. + /// If asserts or exceptions are enabled, throws an etl::deque_full is the deque is already full. ///\return A reference to the item to assign to. //************************************************************************* reference push_back() @@ -1117,7 +1117,7 @@ namespace etl //************************************************************************* /// Adds an item to the front of the deque. - /// If ETL_THROW_EXCEPTIONS is defined, throws an etl::deque_full is the deque is already full. + /// If asserts or exceptions are enabled, throws an etl::deque_full is the deque is already full. ///\param item The item to push to the deque. //************************************************************************* void push_front(parameter_t item) @@ -1130,7 +1130,7 @@ namespace etl //************************************************************************* /// Adds one to the front of the deque and returns a reference to the new element. - /// If ETL_THROW_EXCEPTIONS is defined, throws an etl::deque_full is the deque is already full. + /// If asserts or exceptions are enabled, throws an etl::deque_full is the deque is already full. ///\return A reference to the item to assign to. //************************************************************************* reference push_front() @@ -1156,7 +1156,7 @@ namespace etl //************************************************************************* /// Resizes the deque. - /// If ETL_THROW_EXCEPTIONS is defined, throws an etl::deque_full is 'new_size' is too large. + /// If asserts or exceptions are enabled, throws an etl::deque_full is 'new_size' is too large. ///\param new_size The new size of the deque. ///\param value The value to assign if the new size is larger. Default = Default constructed value. //************************************************************************* diff --git a/iflat_map.h b/iflat_map.h index 0899ac34..bb21571c 100644 --- a/iflat_map.h +++ b/iflat_map.h @@ -233,7 +233,7 @@ namespace etl //********************************************************************* /// Returns a reference to the value at index 'key' - /// If ETL_THROW_EXCEPTIONS is defined, emits an etl::flat_map_out_of_bounds if the key is not in the range. + /// If asserts or exceptions are enabled, emits an etl::flat_map_out_of_bounds if the key is not in the range. ///\param i The index. ///\return A reference to the value at index 'key' //********************************************************************* @@ -248,7 +248,7 @@ namespace etl //********************************************************************* /// Returns a const reference to the value at index 'key' - /// If ETL_THROW_EXCEPTIONS is defined, emits an etl::flat_map_out_of_bounds if the key is not in the range. + /// If asserts or exceptions are enabled, emits an etl::flat_map_out_of_bounds if the key is not in the range. ///\param i The index. ///\return A const reference to the value at index 'key' //********************************************************************* @@ -288,7 +288,7 @@ namespace etl //********************************************************************* /// Inserts a value to the flat_map. - /// If ETL_THROW_EXCEPTIONS is defined, emits flat_map_full if the flat_map is already full. + /// If asserts or exceptions are enabled, emits flat_map_full if the flat_map is already full. ///\param value The value to insert. //********************************************************************* std::pair insert(const value_type& value) @@ -324,7 +324,7 @@ namespace etl //********************************************************************* /// Inserts a value to the flat_map. - /// If ETL_THROW_EXCEPTIONS is defined, emits flat_map_full if the flat_map is already full. + /// If asserts or exceptions are enabled, emits flat_map_full if the flat_map is already full. ///\param position The position to insert at. ///\param value The value to insert. //********************************************************************* @@ -335,7 +335,7 @@ namespace etl //********************************************************************* /// Inserts a range of values to the flat_map. - /// If ETL_THROW_EXCEPTIONS is defined, emits flat_map_full if the flat_map does not have enough free space. + /// If asserts or exceptions are enabled, emits flat_map_full if the flat_map does not have enough free space. ///\param position The position to insert at. ///\param first The first element to add. ///\param last The last + 1 element to add. diff --git a/iflat_multimap.h b/iflat_multimap.h index 171710e0..7c28be2f 100644 --- a/iflat_multimap.h +++ b/iflat_multimap.h @@ -214,8 +214,8 @@ namespace etl //********************************************************************* /// Assigns values to the flat_multimap. - /// If ETL_THROW_EXCEPTIONS is defined, emits flat_multimap_full if the flat_multimap does not have enough free space. - /// If ETL_THROW_EXCEPTIONS is defined, emits flat_multimap_iterator if the iterators are reversed. + /// If asserts or exceptions are enabled, emits flat_multimap_full if the flat_multimap does not have enough free space. + /// If asserts or exceptions are enabled, emits flat_multimap_iterator if the iterators are reversed. ///\param first The iterator to the first element. ///\param last The iterator to the last element + 1. //********************************************************************* @@ -237,7 +237,7 @@ namespace etl //********************************************************************* /// Inserts a value to the flat_multimap. - /// If ETL_THROW_EXCEPTIONS is defined, emits flat_multimap_full if the flat_multimap is already full. + /// If asserts or exceptions are enabled, emits flat_multimap_full if the flat_multimap is already full. ///\param value The value to insert. //********************************************************************* std::pair insert(const value_type& value) @@ -268,7 +268,7 @@ namespace etl //********************************************************************* /// Inserts a value to the flast_multi. - /// If ETL_THROW_EXCEPTIONS is defined, emits flat_map_full if the flat_map is already full. + /// If asserts or exceptions are enabled, emits flat_map_full if the flat_map is already full. ///\param position The position to insert at. ///\param value The value to insert. //********************************************************************* @@ -279,7 +279,7 @@ namespace etl //********************************************************************* /// Inserts a range of values to the flat_multimap. - /// If ETL_THROW_EXCEPTIONS is defined, emits flat_multimap_full if the flat_multimap does not have enough free space. + /// If asserts or exceptions are enabled, emits flat_multimap_full if the flat_multimap does not have enough free space. ///\param position The position to insert at. ///\param first The first element to add. ///\param last The last + 1 element to add. diff --git a/iflat_multiset.h b/iflat_multiset.h index 72b488bf..17776e06 100644 --- a/iflat_multiset.h +++ b/iflat_multiset.h @@ -190,8 +190,8 @@ namespace etl //********************************************************************* /// Assigns values to the flat_multiset. - /// If ETL_THROW_EXCEPTIONS is defined, emits flat_multiset_full if the flat_multiset does not have enough free space. - /// If ETL_THROW_EXCEPTIONS is defined, emits flat_multiset_iterator if the iterators are reversed. + /// If asserts or exceptions are enabled, emits flat_multiset_full if the flat_multiset does not have enough free space. + /// If asserts or exceptions are enabled, emits flat_multiset_iterator if the iterators are reversed. ///\param first The iterator to the first element. ///\param last The iterator to the last element + 1. //********************************************************************* @@ -214,7 +214,7 @@ namespace etl //********************************************************************* /// Inserts a value to the flat_multiset. - /// If ETL_THROW_EXCEPTIONS is defined, emits flat_multiset_full if the flat_multiset is already full. + /// If asserts or exceptions are enabled, emits flat_multiset_full if the flat_multiset is already full. ///\param value The value to insert. //********************************************************************* std::pair insert(parameter_t value) @@ -245,7 +245,7 @@ namespace etl //********************************************************************* /// Inserts a value to the flat_multiset. - /// If ETL_THROW_EXCEPTIONS is defined, emits flat_multiset_full if the flat_multiset is already full. + /// If asserts or exceptions are enabled, emits flat_multiset_full if the flat_multiset is already full. ///\param position The position to insert at. ///\param value The value to insert. //********************************************************************* @@ -256,7 +256,7 @@ namespace etl //********************************************************************* /// Inserts a range of values to the flat_multiset. - /// If ETL_THROW_EXCEPTIONS is defined, emits flat_multiset_full if the flat_multiset does not have enough free space. + /// If asserts or exceptions are enabled, emits flat_multiset_full if the flat_multiset does not have enough free space. ///\param position The position to insert at. ///\param first The first element to add. ///\param last The last + 1 element to add. diff --git a/iflat_set.h b/iflat_set.h index 8904344d..d31137d3 100644 --- a/iflat_set.h +++ b/iflat_set.h @@ -190,8 +190,8 @@ namespace etl //********************************************************************* /// Assigns values to the flat_set. - /// If ETL_THROW_EXCEPTIONS is defined, emits flat_set_full if the flat_set does not have enough free space. - /// If ETL_THROW_EXCEPTIONS is defined, emits flat_set_iterator if the iterators are reversed. + /// If asserts or exceptions are enabled, emits flat_set_full if the flat_set does not have enough free space. + /// If asserts or exceptions are enabled, emits flat_set_iterator if the iterators are reversed. ///\param first The iterator to the first element. ///\param last The iterator to the last element + 1. //********************************************************************* @@ -213,7 +213,7 @@ namespace etl //********************************************************************* /// Inserts a value to the flat_set. - /// If ETL_THROW_EXCEPTIONS is defined, emits flat_set_full if the flat_set is already full. + /// If asserts or exceptions are enabled, emits flat_set_full if the flat_set is already full. ///\param value The value to insert. //********************************************************************* std::pair insert(parameter_t value) @@ -253,7 +253,7 @@ namespace etl //********************************************************************* /// Inserts a value to the flat_set. - /// If ETL_THROW_EXCEPTIONS is defined, emits flat_set_full if the flat_set is already full. + /// If asserts or exceptions are enabled, emits flat_set_full if the flat_set is already full. ///\param position The position to insert at. ///\param value The value to insert. //********************************************************************* @@ -264,7 +264,7 @@ namespace etl //********************************************************************* /// Inserts a range of values to the flat_set. - /// If ETL_THROW_EXCEPTIONS is defined, emits flat_set_full if the flat_set does not have enough free space. + /// If asserts or exceptions are enabled, emits flat_set_full if the flat_set does not have enough free space. ///\param position The position to insert at. ///\param first The first element to add. ///\param last The last + 1 element to add. diff --git a/iforward_list.h b/iforward_list.h index 8281a1f8..f1007dc4 100644 --- a/iforward_list.h +++ b/iforward_list.h @@ -356,7 +356,7 @@ namespace etl //************************************************************************* /// Assigns a range of values to the forward_list. - /// If ETL_THROW_EXCEPTIONS is defined throws etl::forward_list_full if the forward_list does not have enough free space. + /// If asserts or exceptions are enabled throws etl::forward_list_full if the forward_list does not have enough free space. /// If ETL_THROW_EXCEPTIONS & _DEBUG are defined throws forward_list_iterator if the iterators are reversed. //************************************************************************* template @@ -451,7 +451,7 @@ namespace etl //************************************************************************* /// Resizes the forward_list. - /// If ETL_THROW_EXCEPTIONS is defined, will throw an etl::forward_list_full + /// If asserts or exceptions are enabled, will throw an etl::forward_list_full /// if n is larger than the maximum size. //************************************************************************* void resize(size_t n, T value) diff --git a/ilist.h b/ilist.h index 8794d6f7..bf34a056 100644 --- a/ilist.h +++ b/ilist.h @@ -445,7 +445,7 @@ namespace etl //************************************************************************* /// Assigns a range of values to the list. - /// If ETL_THROW_EXCEPTIONS is defined throws etl::list_full if the list does not have enough free space. + /// If asserts or exceptions are enabled throws etl::list_full if the list does not have enough free space. /// If ETL_THROW_EXCEPTIONS & _DEBUG are defined throws list_iterator if the iterators are reversed. //************************************************************************* template diff --git a/imap.h b/imap.h index e1e50f36..13e53e74 100644 --- a/imap.h +++ b/imap.h @@ -517,7 +517,7 @@ namespace etl //********************************************************************* /// Returns a reference to the value at index 'key' - /// If ETL_THROW_EXCEPTIONS is defined, emits an etl::lookup_out_of_bounds if the key is not in the range. + /// If asserts or exceptions are enabled, emits an etl::lookup_out_of_bounds if the key is not in the range. ///\param i The index. ///\return A reference to the value at index 'key' //********************************************************************* @@ -532,7 +532,7 @@ namespace etl //********************************************************************* /// Returns a const reference to the value at index 'key' - /// If ETL_THROW_EXCEPTIONS is defined, emits an etl::lookup_out_of_bounds if the key is not in the range. + /// If asserts or exceptions are enabled, emits an etl::lookup_out_of_bounds if the key is not in the range. ///\param i The index. ///\return A const reference to the value at index 'key' //********************************************************************* @@ -547,8 +547,8 @@ namespace etl //********************************************************************* /// Assigns values to the map. - /// If ETL_THROW_EXCEPTIONS is defined, emits map_full if the map does not have enough free space. - /// If ETL_THROW_EXCEPTIONS is defined, emits map_iterator if the iterators are reversed. + /// If asserts or exceptions are enabled, emits map_full if the map does not have enough free space. + /// If asserts or exceptions are enabled, emits map_iterator if the iterators are reversed. ///\param first The iterator to the first element. ///\param last The iterator to the last element + 1. //********************************************************************* @@ -682,7 +682,7 @@ namespace etl //********************************************************************* /// Inserts a value to the map. - /// If ETL_THROW_EXCEPTIONS is defined, emits map_full if the map is already full. + /// If asserts or exceptions are enabled, emits map_full if the map is already full. ///\param value The value to insert. //********************************************************************* std::pair insert(const value_type& value) @@ -706,7 +706,7 @@ namespace etl //********************************************************************* /// Inserts a value to the map starting at the position recommended. - /// If ETL_THROW_EXCEPTIONS is defined, emits map_full if the map is already full. + /// If asserts or exceptions are enabled, emits map_full if the map is already full. ///\param position The position that would precede the value to insert. ///\param value The value to insert. //********************************************************************* @@ -729,7 +729,7 @@ namespace etl //********************************************************************* /// Inserts a value to the map starting at the position recommended. - /// If ETL_THROW_EXCEPTIONS is defined, emits map_full if the map is already full. + /// If asserts or exceptions are enabled, emits map_full if the map is already full. ///\param position The position that would precede the value to insert. ///\param value The value to insert. //********************************************************************* @@ -752,7 +752,7 @@ namespace etl //********************************************************************* /// Inserts a range of values to the map. - /// If ETL_THROW_EXCEPTIONS is defined, emits map_full if the map does not have enough free space. + /// If asserts or exceptions are enabled, emits map_full if the map does not have enough free space. ///\param position The position to insert at. ///\param first The first element to add. ///\param last The last + 1 element to add. diff --git a/imultimap.h b/imultimap.h index 3a27bf8d..81b53f7f 100644 --- a/imultimap.h +++ b/imultimap.h @@ -498,8 +498,8 @@ namespace etl //********************************************************************* /// Assigns values to the multimap. - /// If ETL_THROW_EXCEPTIONS is defined, emits map_full if the multimap does not have enough free space. - /// If ETL_THROW_EXCEPTIONS is defined, emits map_iterator if the iterators are reversed. + /// If asserts or exceptions are enabled, emits map_full if the multimap does not have enough free space. + /// If asserts or exceptions are enabled, emits map_iterator if the iterators are reversed. ///\param first The iterator to the first element. ///\param last The iterator to the last element + 1. //********************************************************************* @@ -648,7 +648,7 @@ namespace etl //********************************************************************* /// Inserts a value to the multimap. - /// If ETL_THROW_EXCEPTIONS is defined, emits map_full if the multimap is already full. + /// If asserts or exceptions are enabled, emits map_full if the multimap is already full. ///\param value The value to insert. //********************************************************************* iterator insert(const value_type& value) @@ -670,7 +670,7 @@ namespace etl //********************************************************************* /// Inserts a value to the multimap starting at the position recommended. - /// If ETL_THROW_EXCEPTIONS is defined, emits map_full if the multimap is already full. + /// If asserts or exceptions are enabled, emits map_full if the multimap is already full. ///\param position The position that would precede the value to insert. ///\param value The value to insert. //********************************************************************* @@ -682,7 +682,7 @@ namespace etl //********************************************************************* /// Inserts a value to the multimap starting at the position recommended. - /// If ETL_THROW_EXCEPTIONS is defined, emits map_full if the multimap is already full. + /// If asserts or exceptions are enabled, emits map_full if the multimap is already full. ///\param position The position that would precede the value to insert. ///\param value The value to insert. //********************************************************************* @@ -694,7 +694,7 @@ namespace etl //********************************************************************* /// Inserts a range of values to the multimap. - /// If ETL_THROW_EXCEPTIONS is defined, emits map_full if the multimap does not have enough free space. + /// If asserts or exceptions are enabled, emits map_full if the multimap does not have enough free space. ///\param position The position to insert at. ///\param first The first element to add. ///\param last The last + 1 element to add. diff --git a/imultiset.h b/imultiset.h index 5836d731..6b7ce644 100644 --- a/imultiset.h +++ b/imultiset.h @@ -479,8 +479,8 @@ namespace etl //********************************************************************* /// Assigns values to the multiset. - /// If ETL_THROW_EXCEPTIONS is defined, emits set_full if the multiset does not have enough free space. - /// If ETL_THROW_EXCEPTIONS is defined, emits set_iterator if the iterators are reversed. + /// If asserts or exceptions are enabled, emits set_full if the multiset does not have enough free space. + /// If asserts or exceptions are enabled, emits set_iterator if the iterators are reversed. ///\param first The iterator to the first element. ///\param last The iterator to the last element + 1. //********************************************************************* @@ -629,7 +629,7 @@ namespace etl //********************************************************************* /// Inserts a value to the multiset. - /// If ETL_THROW_EXCEPTIONS is defined, emits set_full if the multiset is already full. + /// If asserts or exceptions are enabled, emits set_full if the multiset is already full. ///\param value The value to insert. //********************************************************************* iterator insert(const value_type& value) @@ -651,7 +651,7 @@ namespace etl //********************************************************************* /// Inserts a value to the multiset starting at the position recommended. - /// If ETL_THROW_EXCEPTIONS is defined, emits set_full if the multiset is already full. + /// If asserts or exceptions are enabled, emits set_full if the multiset is already full. ///\param position The position that would precede the value to insert. ///\param value The value to insert. //********************************************************************* @@ -663,7 +663,7 @@ namespace etl //********************************************************************* /// Inserts a value to the multiset starting at the position recommended. - /// If ETL_THROW_EXCEPTIONS is defined, emits set_full if the multiset is already full. + /// If asserts or exceptions are enabled, emits set_full if the multiset is already full. ///\param position The position that would precede the value to insert. ///\param value The value to insert. //********************************************************************* @@ -675,7 +675,7 @@ namespace etl //********************************************************************* /// Inserts a range of values to the multiset. - /// If ETL_THROW_EXCEPTIONS is defined, emits set_full if the multiset does not have enough free space. + /// If asserts or exceptions are enabled, emits set_full if the multiset does not have enough free space. ///\param position The position to insert at. ///\param first The first element to add. ///\param last The last + 1 element to add. diff --git a/ipool.h b/ipool.h index abd46356..d797105b 100644 --- a/ipool.h +++ b/ipool.h @@ -132,7 +132,6 @@ namespace etl private: - //******************************* //******************************* iterator(size_t index, pointer p_buffer, @@ -232,7 +231,6 @@ namespace etl private: - //******************************* //******************************* const_iterator(size_t index, const_pointer p_buffer, @@ -317,7 +315,7 @@ namespace etl //************************************************************************* /// Allocate an object from the pool. /// Uses the default constructor. - /// If ETL_THROW_EXCEPTIONS is defined and there are no more free items an + /// If asserts or exceptions are enabled and there are no more free items an /// etl::pool_no_allocation if thrown, otherwise a nullptr is returned. /// \note The state of the object returned is undefined. //************************************************************************* @@ -338,7 +336,7 @@ namespace etl //************************************************************************* /// Allocate an object from the pool from an ititial value. - /// If ETL_THROW_EXCEPTIONS is defined and there are no more free items an + /// If asserts or exceptions are enabled and there are no more free items an /// etl::pool_no_allocation if thrown, otherwise a nullptr is returned. /// \note The state of the object returned is undefined. //************************************************************************* @@ -359,7 +357,7 @@ namespace etl //************************************************************************* /// Release an object in the pool. - /// If ETL_THROW_EXCEPTIONS is defined and the object does not belong to this + /// If asserts or exceptions are enabled and the object does not belong to this /// pool then an etl::pool_object_not_in_pool is thrown. /// \param p_object A pointer to the object to be released. //************************************************************************* @@ -370,7 +368,7 @@ namespace etl //************************************************************************* /// Release an object in the pool. - /// If ETL_THROW_EXCEPTIONS is defined and the object does not belong to this + /// If asserts or exceptions are enabled and the object does not belong to this /// pool then an etl::pool_object_not_in_pool is thrown. /// \param p_object A pointer to the object to be released. //************************************************************************* diff --git a/ipriority_queue.h b/ipriority_queue.h index 4aa824df..cc829837 100644 --- a/ipriority_queue.h +++ b/ipriority_queue.h @@ -143,7 +143,7 @@ namespace etl //************************************************************************* /// Adds a value to the queue. - /// If ETL_THROW_EXCEPTIONS is defined, throws an etl::priority_queue_full + /// If asserts or exceptions are enabled, throws an etl::priority_queue_full /// is the priority queue is already full, otherwise does nothing if full. ///\param value The value to push to the queue. //************************************************************************* @@ -159,9 +159,9 @@ namespace etl //************************************************************************* /// Assigns values to the priority queue. - /// If ETL_THROW_EXCEPTIONS is defined, emits priority_queue_full if + /// If asserts or exceptions are enabled, emits priority_queue_full if /// priority queue does not have enough free space. - /// If ETL_THROW_EXCEPTIONS is defined, emits priority_iterator if the + /// If asserts or exceptions are enabled, emits priority_iterator if the /// iterators are reversed. ///\param first The iterator to the first element. ///\param last The iterator to the last element + 1. diff --git a/iqueue.h b/iqueue.h index 85fd3194..cfdaa141 100644 --- a/iqueue.h +++ b/iqueue.h @@ -108,7 +108,7 @@ namespace etl //************************************************************************* /// Adds a value to the queue. - /// If ETL_THROW_EXCEPTIONS is defined, throws an etl::queue_full is the queue is already full, + /// If asserts or exceptions are enabled, throws an etl::queue_full is the queue is already full, /// otherwise does nothing if full. ///\param value The value to push to the queue. //************************************************************************* @@ -126,7 +126,7 @@ namespace etl /// Allows a possibly more efficient 'push' by moving to the next input value /// and returning a reference to it. /// This may eliminate a copy by allowing direct construction in-place.
- /// If ETL_THROW_EXCEPTIONS is defined, throws an etl::queue_full is the queue is already full, + /// If asserts or exceptions are enabled, throws an etl::queue_full is the queue is already full, /// otherwise does nothing if full. /// \return A reference to the position to 'push' to. //************************************************************************* diff --git a/iset.h b/iset.h index a575538e..cb7c926b 100644 --- a/iset.h +++ b/iset.h @@ -489,8 +489,8 @@ namespace etl //********************************************************************* /// Assigns values to the set. - /// If ETL_THROW_EXCEPTIONS is defined, emits set_full if the set does not have enough free space. - /// If ETL_THROW_EXCEPTIONS is defined, emits set_iterator if the iterators are reversed. + /// If asserts or exceptions are enabled, emits set_full if the set does not have enough free space. + /// If asserts or exceptions are enabled, emits set_iterator if the iterators are reversed. ///\param first The iterator to the first element. ///\param last The iterator to the last element + 1. //********************************************************************* @@ -624,7 +624,7 @@ namespace etl //********************************************************************* /// Inserts a value to the set. - /// If ETL_THROW_EXCEPTIONS is defined, emits set_full if the set is already full. + /// If asserts or exceptions are enabled, emits set_full if the set is already full. ///\param value The value to insert. //********************************************************************* std::pair insert(value_type& value) @@ -648,7 +648,7 @@ namespace etl //********************************************************************* /// Inserts a value to the set starting at the position recommended. - /// If ETL_THROW_EXCEPTIONS is defined, emits set_full if the set is already full. + /// If asserts or exceptions are enabled, emits set_full if the set is already full. ///\param position The position that would precede the value to insert. ///\param value The value to insert. //********************************************************************* @@ -671,7 +671,7 @@ namespace etl //********************************************************************* /// Inserts a value to the set starting at the position recommended. - /// If ETL_THROW_EXCEPTIONS is defined, emits set_full if the set is already full. + /// If asserts or exceptions are enabled, emits set_full if the set is already full. ///\param position The position that would precede the value to insert. ///\param value The value to insert. //********************************************************************* @@ -694,7 +694,7 @@ namespace etl //********************************************************************* /// Inserts a range of values to the set. - /// If ETL_THROW_EXCEPTIONS is defined, emits set_full if the set does not have enough free space. + /// If asserts or exceptions are enabled, emits set_full if the set does not have enough free space. ///\param position The position to insert at. ///\param first The first element to add. ///\param last The last + 1 element to add. diff --git a/istack.h b/istack.h index 14cb843f..6a9386db 100644 --- a/istack.h +++ b/istack.h @@ -81,7 +81,7 @@ namespace etl //************************************************************************* /// Adds a value to the stack. - /// If ETL_THROW_EXCEPTIONS is defined, throws an etl::stack_full is the stack is already full. + /// If asserts or exceptions are enabled, throws an etl::stack_full is the stack is already full. ///\param value The value to push to the stack. //************************************************************************* void push(parameter_t value) @@ -97,7 +97,7 @@ namespace etl /// Allows a possibly more efficient 'push' by moving to the next input value /// and returning a reference to it. /// This may eliminate a copy by allowing direct construction in-place.
- /// If ETL_THROW_EXCEPTIONS is defined, throws an etl::stack_full is the stack is already full. + /// If asserts or exceptions are enabled, throws an etl::stack_full is the stack is already full. /// \return A reference to the position to 'push' to. //************************************************************************* reference push() diff --git a/ivector.h b/ivector.h index 1d82427b..d2cd81ce 100644 --- a/ivector.h +++ b/ivector.h @@ -187,7 +187,7 @@ namespace etl //********************************************************************* /// Resizes the vector. - /// If ETL_THROW_EXCEPTIONS is defined and the new size is larger than the + /// 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. //********************************************************************* @@ -217,7 +217,7 @@ namespace etl //********************************************************************* /// Resizes the vector. - /// If ETL_THROW_EXCEPTIONS is defined and the new size is larger than the + /// 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. @@ -266,7 +266,7 @@ namespace etl //********************************************************************* /// Returns a reference to the value at index 'i' - /// If ETL_THROW_EXCEPTIONS is defined, emits an etl::vector_out_of_bounds if the index is out of range. + /// 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' //********************************************************************* @@ -278,7 +278,7 @@ namespace etl //********************************************************************* /// Returns a const reference to the value at index 'i' - /// If ETL_THROW_EXCEPTIONS is defined, emits an etl::vector_out_of_bounds if the index is out of range. + /// 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' //********************************************************************* @@ -344,8 +344,8 @@ namespace etl //********************************************************************* /// Assigns values to the vector. - /// If ETL_THROW_EXCEPTIONS is defined, emits vector_full if the vector does not have enough free space. - /// If ETL_THROW_EXCEPTIONS is defined, emits vector_iterator if the iterators are reversed. + /// 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. //********************************************************************* @@ -370,7 +370,7 @@ namespace etl //********************************************************************* /// Assigns values to the vector. - /// If ETL_THROW_EXCEPTIONS is defined, emits vector_full if the vector does not have enough free space. + /// 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. //********************************************************************* @@ -397,7 +397,7 @@ namespace etl //************************************************************************* /// Increases the size of the vector by one, but does not initialise the new element. - /// If ETL_THROW_EXCEPTIONS is defined, throws a vector_full if the vector is already full. + /// If asserts or exceptions are enabled, throws a vector_full if the vector is already full. //************************************************************************* void push_back() { @@ -409,7 +409,7 @@ namespace etl //********************************************************************* /// Inserts a value at the end of the vector. - /// If ETL_THROW_EXCEPTIONS is defined, emits vector_full if the vector is already full. + /// 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) @@ -434,7 +434,7 @@ namespace etl //********************************************************************* /// Inserts a value to the vector. - /// If ETL_THROW_EXCEPTIONS is defined, emits vector_full if the vector is already full. + /// 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. //********************************************************************* @@ -455,7 +455,7 @@ namespace etl //********************************************************************* /// Inserts 'n' values to the vector. - /// If ETL_THROW_EXCEPTIONS is defined, emits vector_full if the vector does not have enough free space. + /// 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. @@ -514,7 +514,7 @@ namespace etl //********************************************************************* /// Inserts a range of values to the vector. - /// If ETL_THROW_EXCEPTIONS is defined, emits vector_full if the vector does not have enough free space. + /// 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. diff --git a/observer.h b/observer.h index a18e3020..f46e4256 100644 --- a/observer.h +++ b/observer.h @@ -106,7 +106,7 @@ namespace etl //***************************************************************** /// Add an observer to the list. - /// If ETL_THROW_EXCEPTIONS is defined then an etl::observable_observer_list_full + /// If asserts or exceptions are enabled then an etl::observable_observer_list_full /// is emitted if the observer list is already full. ///\param observer A reference to the observer. //***************************************************************** From e8a365ff75c496aee07ff873b90c3f54f97f7df4 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 11 Jan 2016 23:57:10 +0000 Subject: [PATCH 14/43] Removed unneeded base class --- private/unordered_map_base.h | 170 ----------------------------------- 1 file changed, 170 deletions(-) delete mode 100644 private/unordered_map_base.h diff --git a/private/unordered_map_base.h b/private/unordered_map_base.h deleted file mode 100644 index bc9b4716..00000000 --- a/private/unordered_map_base.h +++ /dev/null @@ -1,170 +0,0 @@ -///\file - -/****************************************************************************** -The MIT License(MIT) - -Embedded Template Library. -https://github.com/ETLCPP/etl -http://www.etlcpp.com - -Copyright(c) 2014 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_IN_IUNORDERED_MAP_H__ -#error This header is a private element of etl::unordered_map & etl::iunordered_map -#endif - -#ifndef __ETL_UNORDERED_MAP_BASE__ -#define __ETL_UNORDERED_MAP_BASE__ - -#include -#include "../exception.h" -#include "../error_handler.h" - -#define ETL_FILE "16" - -namespace etl -{ - //*************************************************************************** - /// Exception for the unordered_map. - ///\ingroup unordered_map - //*************************************************************************** - class unordered_map_exception : public exception - { - public: - - unordered_map_exception(string_type what, string_type file_name, numeric_type line_number) - : exception(what, file_name, line_number) - { - } - }; - - //*************************************************************************** - /// Full exception for the unordered_map. - ///\ingroup unordered_map - //*************************************************************************** - class unordered_map_full : public unordered_map_exception - { - public: - - unordered_map_full(string_type file_name, numeric_type line_number) - : unordered_map_exception(ETL_ERROR_TEXT("unordered_map:full", ETL_FILE"A"), file_name, line_number) - { - } - }; - - //*************************************************************************** - /// Out of range exception for the unordered_map. - ///\ingroup unordered_map - //*************************************************************************** - class unordered_map_out_of_range : public unordered_map_exception - { - public: - - unordered_map_out_of_range(string_type file_name, numeric_type line_number) - : unordered_map_exception(ETL_ERROR_TEXT("unordered_map:range", ETL_FILE"B"), file_name, line_number) - {} - }; - - //*************************************************************************** - /// Iterator exception for the unordered_map. - ///\ingroup unordered_map - //*************************************************************************** - class unordered_map_iterator : public unordered_map_exception - { - public: - - unordered_map_iterator(string_type file_name, numeric_type line_number) - : unordered_map_exception("unordered_map:iterator", file_name, line_number) - { - } - }; - - //*************************************************************************** - /// The base class for all unordered_maps. - ///\ingroup unordered_map - //*************************************************************************** - class unordered_map_base - { - public: - - typedef size_t size_type; ///< The type used for determining the size of unordered_map. - - //************************************************************************* - /// Gets the size of the unordered_map. - //************************************************************************* - size_type size() const - { - return current_size; - } - - //************************************************************************* - /// Gets the maximum possible size of the unordered_map. - //************************************************************************* - size_type max_size() const - { - return MAX_SIZE; - } - - //************************************************************************* - /// Checks to see if the unordered_map is empty. - //************************************************************************* - bool empty() const - { - return current_size == 0; - } - - //************************************************************************* - /// Checks to see if the unordered_map is full. - //************************************************************************* - bool full() const - { - return current_size == MAX_SIZE; - } - - //************************************************************************* - /// Returns the remaining capacity. - ///\return The remaining capacity. - //************************************************************************* - size_t available() const - { - return max_size() - size(); - } - - protected: - - //************************************************************************* - /// The constructor that is called from derived classes. - //************************************************************************* - unordered_map_base(size_type max_size) - : current_size(0), - MAX_SIZE(max_size) - { - } - - size_type current_size; ///< The number of the used nodes. - const size_type MAX_SIZE; ///< The maximum size of the unordered_map. - }; -} - -#undef ETL_FILE - -#endif From 1ecbbe5c05d59e0e432b0d20bfc1e6a3bff5a363 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 11 Jan 2016 23:58:01 +0000 Subject: [PATCH 15/43] Added and modified capacity functions to better match the standard container APIs. --- private/pool_base.h | 31 +++++++++++-- test/test_pool.cpp | 104 +++++++++++++++++++++++++++++--------------- 2 files changed, 97 insertions(+), 38 deletions(-) diff --git a/private/pool_base.h b/private/pool_base.h index b9aa7257..7a358166 100644 --- a/private/pool_base.h +++ b/private/pool_base.h @@ -93,6 +93,14 @@ namespace etl { public: + //************************************************************************* + /// Returns the maximum number of items in the pool. + //************************************************************************* + size_t max_size() const + { + return MAX_SIZE; + } + //************************************************************************* /// Returns the number of free items in the pool. //************************************************************************* @@ -102,10 +110,27 @@ namespace etl } //************************************************************************* - /// Checks to see if there are no free items in the pool. - /// \return true if there are none free (or 'empty') + /// Returns the number of allocated items in the pool. //************************************************************************* - bool none_free() const + size_t size() const + { + return items_allocated; + } + + //************************************************************************* + /// Checks to see if there are no allocated items in the pool. + /// \return true if there are none allocated. + //************************************************************************* + bool empty() const + { + return items_allocated == 0; + } + + //************************************************************************* + /// Checks to see if there are no free items in the pool. + /// \return true if there are none free. + //************************************************************************* + bool full() const { return items_allocated == MAX_SIZE; } diff --git a/test/test_pool.cpp b/test/test_pool.cpp index e803934f..950594e7 100644 --- a/test/test_pool.cpp +++ b/test/test_pool.cpp @@ -138,7 +138,7 @@ namespace CHECK(p7 != p4); CHECK(p7 != p6); - CHECK(pool.none_free()); + CHECK(pool.full()); } //************************************************************************* @@ -163,24 +163,58 @@ namespace } //************************************************************************* - TEST(test_none_free) + TEST(test_max_size) { etl::pool pool; - CHECK_EQUAL(4, pool.available()); + + CHECK(pool.max_size() == 4); + } + + //************************************************************************* + TEST(test_size) + { + etl::pool pool; + CHECK_EQUAL(0, pool.size()); Test_Data* p; p = pool.allocate(); - CHECK(!pool.none_free()); + CHECK_EQUAL(1, pool.size()); p = pool.allocate(); - CHECK(!pool.none_free()); + CHECK_EQUAL(2, pool.size()); p = pool.allocate(); - CHECK(!pool.none_free()); + CHECK_EQUAL(3, pool.size()); p = pool.allocate(); - CHECK(pool.none_free()); + CHECK_EQUAL(4, pool.size()); + } + + //************************************************************************* + TEST(test_empty_full) + { + etl::pool pool; + CHECK(pool.empty()); + CHECK(!pool.full()); + + Test_Data* p; + + p = pool.allocate(); + CHECK(!pool.empty()); + CHECK(!pool.full()); + + p = pool.allocate(); + CHECK(!pool.empty()); + CHECK(!pool.full()); + + p = pool.allocate(); + CHECK(!pool.empty()); + CHECK(!pool.full()); + + p = pool.allocate(); + CHECK(!pool.empty()); + CHECK(pool.full()); } //************************************************************************* @@ -244,42 +278,42 @@ namespace } } - ////************************************************************************* - //TEST(test_get_iterator) - //{ - // typedef etl::pool Pool; + //************************************************************************* + TEST(test_get_iterator) + { + typedef etl::pool Pool; - // Pool pool; - // Test_Data not_in_pool; + Pool pool; + Test_Data not_in_pool; - // Test_Data* p1 = pool.allocate(); - // Test_Data* p2 = pool.allocate(); + Test_Data* p1 = pool.allocate(); + Test_Data* p2 = pool.allocate(); - // Pool::iterator i_data = pool.get_iterator(*p1); - // Pool::iterator i_ndata = pool.get_iterator(not_in_pool); + Pool::iterator i_data = pool.get_iterator(*p1); + Pool::iterator i_ndata = pool.get_iterator(not_in_pool); - // CHECK(p1 == &*i_data); - // CHECK(p2 != &*i_data); - // CHECK(pool.end() == i_ndata); - //} + CHECK(p1 == &*i_data); + CHECK(p2 != &*i_data); + CHECK(pool.end() == i_ndata); + } - ////************************************************************************* - //TEST(test_get_iterator_const) - //{ - // typedef etl::pool Pool; + //************************************************************************* + TEST(test_get_iterator_const) + { + typedef etl::pool Pool; - // Pool pool; - // const Test_Data not_in_pool; + Pool pool; + const Test_Data not_in_pool; - // const Test_Data* p1 = pool.allocate(); - // const Test_Data* p2 = pool.allocate(); + const Test_Data* p1 = pool.allocate(); + const Test_Data* p2 = pool.allocate(); - // Pool::const_iterator i_data = pool.get_iterator(*p1); - // Pool::const_iterator i_ndata = pool.get_iterator(not_in_pool); + Pool::const_iterator i_data = pool.get_iterator(*p1); + Pool::const_iterator i_ndata = pool.get_iterator(not_in_pool); - // CHECK(p1 == &*i_data); - // CHECK(p2 != &*i_data); - // CHECK(pool.end() == i_ndata); - //} + CHECK(p1 == &*i_data); + CHECK(p2 != &*i_data); + CHECK(pool.end() == i_ndata); + } }; } From 674b3fe3432d74a8e681dc1a4ed29b0064058a7c Mon Sep 17 00:00:00 2001 From: jwellbelove Date: Tue, 12 Jan 2016 09:45:17 +0000 Subject: [PATCH 16/43] Experimental rolling hash --- cyclic_hash.h | 145 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 cyclic_hash.h diff --git a/cyclic_hash.h b/cyclic_hash.h new file mode 100644 index 00000000..5bf22116 --- /dev/null +++ b/cyclic_hash.h @@ -0,0 +1,145 @@ + +#ifndef CYCLICHASH +#define CYCLICHASH + +#include "characterhash.h" + +/** +* Each instance is a rolling hash function meant to hash streams of characters. +* Each new instance of this class comes with new random keys. +* +* Recommended usage to get L-bit hash values over n-grams: +* CyclicHash<> hf(n,L ); +* for(uint32 k = 0; k +class CyclicHash +{ +public: + // myn is the length of the sequences, e.g., 3 means that you want to hash sequences of 3 characters + // mywordsize is the number of bits you which to receive as hash values, e.g., 19 means that the hash values are 19-bit integers + CyclicHash(int myn, int mywordsize=19) : hashvalue(0), + n(myn), wordsize(mywordsize), + hasher(maskfnc(wordsize)), + mask1(maskfnc(wordsize-1)), + myr(n%wordsize), + maskn(maskfnc(wordsize-myr)) + { + if(static_cast(wordsize) > 8*sizeof(THashtype)) + { + cerr<<"Can't create "<> (wordsize-myr)) ; + } + + void fastleftshift1(THashtype & x) const + { + x = ((x & mask1) << 1 ) | (x >> (wordsize-1)) ; + } + + void fastrightshift1(THashtype & x) const + { + x = (x >> 1 ) | ((x & 1)<< (wordsize-1)) ; + } + + + THashtype getfastleftshift1(THashtype x) const + { + return ((x & mask1) << 1 ) | (x >> (wordsize-1)) ; + } + + + THashtype getfastrightshift1(THashtype x) const + { + return (x >> 1 ) | ((x & 1)<< (wordsize-1)) ; + } + + // this is a convenience function, use eat,update and .hashvalue to use as a rolling hash function + template + THashtype hash(container & c) { + THashtype answer(0); + for(uint k = 0; k(c[k])]; + } + return answer; + } + + THashtype hashz(TChartype outchar,uint n) { + THashtype answer = hasher.hashvalues[static_cast(outchar)]; + for(uint k = 0; k hasher; + const THashtype mask1; + const int myr; + const THashtype maskn; +}; + +#endif \ No newline at end of file From 07d5e63510d1475047a0d2c3a9049836e4fa1e37 Mon Sep 17 00:00:00 2001 From: jwellbelove Date: Tue, 12 Jan 2016 11:00:24 +0000 Subject: [PATCH 17/43] Updated with full set of types and functions. --- char_traits.h | 288 ++++++++++++++++---------------------------------- 1 file changed, 90 insertions(+), 198 deletions(-) diff --git a/char_traits.h b/char_traits.h index 98d65f22..72b74bb5 100644 --- a/char_traits.h +++ b/char_traits.h @@ -42,19 +42,50 @@ SOFTWARE. namespace etl { - template struct char_traits; + template struct char_traits_types; - //*************************************************************************** - /// Specialisation for char. - //*************************************************************************** - template<> struct char_traits + template<> struct char_traits_types { typedef char char_type; typedef int int_type; typedef long long off_type; typedef size_t pos_type; typedef char state_type; - + }; + + template<> struct char_traits_types + { + typedef wchar_t char_type; + typedef wchar_t int_type; + typedef long long off_type; + typedef size_t pos_type; + typedef char state_type; + }; + + template<> struct char_traits_types + { + typedef char16_t char_type; + typedef uint_least16_t int_type; + typedef long long off_type; + typedef size_t pos_type; + typedef char state_type; + }; + + template<> struct char_traits_types + { + typedef char32_t char_type; + typedef uint_least32_t int_type; + typedef long long off_type; + typedef size_t pos_type; + typedef char state_type; + }; + + //*************************************************************************** + /// Specialisation for char. + //*************************************************************************** + template + struct char_traits : public char_traits_types + { //************************************************************************* static bool eq(char_type a, char_type b) { @@ -101,7 +132,7 @@ namespace etl } //************************************************************************* - static char_type* move(char_type* dest, const char_type* src, std::size_t count) + static char_type* move(char_type* dest, const char_type* src, size_t count) { if ((dest < src) || (dest > (src + count)) { @@ -113,224 +144,85 @@ namespace etl std::reverse_iterator(src), std::reverse_iterator(dest + count)); } + + return dest; } - }; - - //*************************************************************************** - /// Specialisation for wchar_t - //*************************************************************************** - template <> struct char_traits - { - typedef wchar_t char_type; - typedef wchar_t int_type; - typedef long long off_type; - typedef size_t pos_type; - typedef char state_type; - + //************************************************************************* - static bool eq(char_type a, char_type b) + static char_type* copy(char_type* dest, const char_type* src, size_t count) { - return a == b; + etl::copy_n(src, src + count, dest); + + return dest; } - + //************************************************************************* - static bool lt(char_type a, char_type b) - { - return a < b; - } - - //************************************************************************* - static size_t length(const wchar_t* str) - { - size_t count = 0; - - if (str != 0) + static int compare(const char_type* s1, const char_type* s2, size_t count) + { + for (size_t i = 0; i < count; ++i) { - while (*str++ != 0) + if (*s1 < *s2) { - ++count; + return -1; + } + else if (*s1 > *s2) + { + return 1; } - } - - return count; - } - - //************************************************************************* - static void assign(char_type& r, const char_type& c) - { - r = a; - } - - //************************************************************************* - static char_type* assign(char_type* p, size_t n, char_type c) - { - if (p != 0) - { - std::fill_n(p, n, c); - } - - return p; - } - - //************************************************************************* - static char_type* move(char_type* dest, const char_type* src, std::size_t count) - { - if ((dest < src) || (dest > (src + count)) - { - etl::copy_n(src, src + count, dest); - } - else - { - etl::copy_n(std::reverse_iterator(src + count), - std::reverse_iterator(src), - std::reverse_iterator(dest + count)); - } - } - }; - - //*************************************************************************** - /// Specialisation for char16_t. - //*************************************************************************** - template <> struct char_traits - { - typedef char16_t char_type; - typedef uint_least16_t int_type; - typedef long long off_type; - typedef size_t pos_type; - typedef char state_type; - - //************************************************************************* - static bool eq(char_type a, char_type b) - { - return a == b; - } - - //************************************************************************* - static bool lt(char_type a, char_type b) - { - return a < b; - } - - //************************************************************************* - static size_t length(const char16_t* str) - { - size_t count = 0; - if (str != 0) + ++s1; + ++s2; + } + + return 0; + } + + //************************************************************************* + static const char_type* find(const char_type* p, size_t count, const char_type& ch) + { + for (size_t i = 0; i < count; ++i) { - while (*str++ != 0) + if (*p == ch) { - ++count; - } - } - - return count; - } - - //************************************************************************* - static void assign(char_type& r, const char_type& c) - { - r = a; - } - - //************************************************************************* - static char_type* assign(char_type* p, size_t n, char_type c) - { - if (p != 0) - { - std::fill_n(p, n, c); - } - - return p; - } - - //************************************************************************* - static char_type* move(char_type* dest, const char_type* src, std::size_t count) - { - if ((dest < src) || (dest > (src + count)) - { - etl::copy_n(src, src + count, dest); - } - else - { - etl::copy_n(std::reverse_iterator(src + count), - std::reverse_iterator(src), - std::reverse_iterator(dest + count)); - } - } - } - - //*************************************************************************** - /// Specialisation for char32_t. - //*************************************************************************** - template <> struct char_traits - { - typedef char16_t char_type; - typedef uint_least32_t int_type; - typedef long long off_type; - typedef size_t pos_type; - typedef char state_type; - - //************************************************************************* - static bool eq(char_type a, char_type b) - { - return a == b; - } - - //************************************************************************* - static bool lt(char_type a, char_type b) - { - return a < b; - } - - //************************************************************************* - static size_t length(const char32_t* str) - { - size_t count = 0; - - if (str != 0) - { - while (*str++ != 0) - { - ++count; + return p; } + + ++p; } - return count; + return 0; } //************************************************************************* - static void assign(char_type& r, const char_type& c) + static char_type to_char_type(int_type c) { - r = a; + return static_cast(c); } //************************************************************************* - static char_type* assign(char_type* p, size_t n, char_type c) + static int_type to_int_type(char_type c) { - if (p != 0) - { - std::fill_n(p, n, c); - } - - return p; + return static_cast(c); } //************************************************************************* - static char_type* move(char_type* dest, const char_type* src, std::size_t count) + static bool eq_int_type(int_type c1, int_type c2) { - if ((dest < src) || (dest > (src + count)) - { - etl::copy_n(src, src + count, dest); - } - else - { - etl::copy_n(std::reverse_iterator(src + count), - std::reverse_iterator(src), - std::reverse_iterator(dest + count)); - } + return (c1 == c2); } - } + + //************************************************************************* + static int_type eof() + { + return -1; + } + + //************************************************************************* + static int_type not_eof(int_type e) + { + return (e == eof()) ? eof() - 1 : e; + } + }; } #endif From f7b990776768821b3684b0b9d074ec39cb97da98 Mon Sep 17 00:00:00 2001 From: jwellbelove Date: Wed, 13 Jan 2016 12:18:34 +0000 Subject: [PATCH 18/43] Added compilation macro to change the element type from default uint8_t. Define ETL_BITSET_ELEMENT_TYPE to customise. --- ibitset.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ibitset.h b/ibitset.h index a7f09239..9994e716 100644 --- a/ibitset.h +++ b/ibitset.h @@ -81,7 +81,11 @@ namespace etl protected: // The type used for each element in the array. +#if !defined(ETL_BITSET_ELEMENT_TYPE) typedef uint8_t element_t; +#else + typedef ETL_BITSET_ELEMENT_TYPE element_t; +#endif public: From 2926a72ea2d4ba899e93e873a2ef6624cf1ba5db Mon Sep 17 00:00:00 2001 From: jwellbelove Date: Wed, 13 Jan 2016 12:55:35 +0000 Subject: [PATCH 19/43] Removed redundant comment --- murmur3.h | 1 - 1 file changed, 1 deletion(-) diff --git a/murmur3.h b/murmur3.h index 18aac14d..39f22e48 100644 --- a/murmur3.h +++ b/murmur3.h @@ -49,7 +49,6 @@ namespace etl //*************************************************************************** /// Calculates the murmur3 hash. /// See https://en.wikipedia.org/wiki/MurmurHash for more details. - ///\tparam ENDIANNESS The endianness of the calculation for input types larger than uint8_t. Default = endian::little. ///\ingroup murmur3 //*************************************************************************** template From 5208751a8c078f374f2dda76379825189985fc37 Mon Sep 17 00:00:00 2001 From: jwellbelove Date: Wed, 13 Jan 2016 13:53:28 +0000 Subject: [PATCH 20/43] Added compiler #if to exclude Windows header for Linux platforms. --- test/test_error_handler.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/test_error_handler.cpp b/test/test_error_handler.cpp index a7c6549c..f75a51f0 100644 --- a/test/test_error_handler.cpp +++ b/test/test_error_handler.cpp @@ -27,7 +27,9 @@ SOFTWARE. ******************************************************************************/ #include +#if defined(PLATFORM_WINDOWS) #include +#endif #include #include @@ -59,6 +61,7 @@ void receive_error(const etl::exception& e) std::ostringstream oss; oss << "Error '" << e.what() << "' in " << e.file_name() << " at line " << e.line_number() << "\n"; +#if defined(PLATFORM_WINDOWS) std::string stext = oss.str(); WCHAR text[200]; @@ -66,6 +69,7 @@ void receive_error(const etl::exception& e) LPCWSTR ltext = text; OutputDebugString(ltext); +#endif } //***************************************************************************** @@ -82,6 +86,7 @@ public: std::ostringstream oss; oss << "Error '" << e.what() << "' in " << e.file_name() << " at line " << e.line_number() << "\n"; +#if defined(PLATFORM_WINDOWS) std::string stext = oss.str(); WCHAR text[200]; @@ -89,11 +94,12 @@ public: LPCWSTR ltext = text; OutputDebugString(ltext); +#endif } }; namespace -{ +{ SUITE(test_error_handler) { //************************************************************************* From f7eb9dd04e7cdd29a5ee1e5b30386a68861900b1 Mon Sep 17 00:00:00 2001 From: jwellbelove Date: Wed, 13 Jan 2016 13:53:52 +0000 Subject: [PATCH 21/43] Initial parts of string support. Incomplete. --- basic_string.h | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/basic_string.h b/basic_string.h index 7ba871e9..1a5d5059 100644 --- a/basic_string.h +++ b/basic_string.h @@ -36,6 +36,7 @@ SOFTWARE. #include #include "ibasic_string.h" +#include "char_traits.h" #include "container.h" #include "alignment.h" #include "array.h" @@ -74,7 +75,7 @@ namespace etl /// Constructor, with size. ///\param initialSize The initial size of the basic_string. //************************************************************************* - explicit basic_string(size_t initialSize) + explicit basic_string(size_t count, T c) : ibasic_string(reinterpret_cast(&buffer), MAX_SIZE) { ibasic_string::initialise(); @@ -89,7 +90,19 @@ namespace etl : ibasic_string(reinterpret_cast(&buffer), MAX_SIZE) { ibasic_string::initialise(); - ibasic_string::assign(text, text + strlen) + ibasic_string::assign(text, text + etl::char_traits::length(text)) + } + + //************************************************************************* + /// Constructor, from null terminated text and count. + ///\param text The initial text of the basic_string. + ///\param count The number of characters to copy. + //************************************************************************* + basic_string(const T* text, size_t count) + : ibasic_string(reinterpret_cast(&buffer), MAX_SIZE) + { + ibasic_string::initialise(); + ibasic_string::assign(text, text + count) } //************************************************************************* @@ -97,11 +110,11 @@ namespace etl ///\param initialSize The initial size of the basic_string. ///\param value The value to fill the basic_string with. //************************************************************************* - basic_string(size_t initialSize, typename ibasic_string::parameter_t value) + basic_string(size_t count, T c) : ibasic_string(reinterpret_cast(&buffer), MAX_SIZE) { ibasic_string::initialise(); - ibasic_string::resize(initialSize, value); + ibasic_string::resize(count, c); } //************************************************************************* @@ -132,7 +145,7 @@ namespace etl private: - typename etl::aligned_storage::value>::type buffer; + T buffer[MAX_SIZE + 1]; }; } From 64c31c5b0fb1ee6d6299a4767aacd2c7ce302973 Mon Sep 17 00:00:00 2001 From: jwellbelove Date: Wed, 13 Jan 2016 15:02:57 +0000 Subject: [PATCH 22/43] Modified for 64 bit 'size_t' compatibilty --- test/test_hash.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/test/test_hash.cpp b/test/test_hash.cpp index 8d0bac99..d7fdb1ac 100644 --- a/test/test_hash.cpp +++ b/test/test_hash.cpp @@ -126,7 +126,10 @@ namespace { size_t hash = etl::hash()((long long)(0x5AA555AA3CC333CC)); - CHECK_EQUAL(0xEC6A8D69, hash); + if (sizeof(size_t) == sizeof(long long)) + CHECK_EQUAL(0x5AA555AA3CC333CC, hash); + else + CHECK_EQUAL(0xEC6A8D69, hash); } //************************************************************************* @@ -134,7 +137,10 @@ namespace { size_t hash = etl::hash()((unsigned long long)(0x5AA555AA3CC333CC)); - CHECK_EQUAL(0xEC6A8D69, hash); + if (sizeof(size_t) == sizeof(unsigned long long)) + CHECK_EQUAL(0x5AA555AA3CC333CC, hash); + else + CHECK_EQUAL(0xEC6A8D69, hash); } //************************************************************************* @@ -142,7 +148,10 @@ namespace { size_t hash = etl::hash()((float)(1.2345)); - CHECK_EQUAL(0x3F9E0419, hash); + if (sizeof(size_t) == sizeof(long long)) + CHECK_EQUAL(0x884B5E3F478AF88F, hash); + else + CHECK_EQUAL(0x3F9E0419, hash); } //************************************************************************* @@ -150,7 +159,10 @@ namespace { size_t hash = etl::hash()((double)(1.2345)); - CHECK_EQUAL(0x86FBF224, hash); + if (sizeof(size_t) == sizeof(long long)) + CHECK_EQUAL(0x3FF3C083126E978D, hash); + else + CHECK_EQUAL(0x86FBF224, hash); } //************************************************************************* From 3cbe7950510c907958a85d5fd443114e24f6a5f9 Mon Sep 17 00:00:00 2001 From: jwellbelove Date: Wed, 13 Jan 2016 15:03:44 +0000 Subject: [PATCH 23/43] Fixed signed/unsigned warnings for GCC --- test/test_observer.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/test_observer.cpp b/test/test_observer.cpp index 933d600b..b53f5d15 100644 --- a/test/test_observer.cpp +++ b/test/test_observer.cpp @@ -121,7 +121,7 @@ public: data3_count(0) { } - + //******************************************* // Notification1 is passed by value. //******************************************* @@ -225,7 +225,7 @@ namespace CHECK_EQUAL(0, observer2.data3_count); observable2.send_notifications(); // Updates data3. observeable2 has no observers yet. - + CHECK_EQUAL(1, observer1.data1_count); CHECK_EQUAL(1, observer1.data2_count); CHECK_EQUAL(0, observer1.data3_count); @@ -408,27 +408,27 @@ namespace Observer observer5; observable.add_observer(observer1); - CHECK_EQUAL(1, observable.number_of_observers()); + CHECK_EQUAL(size_t(1), observable.number_of_observers()); observable.add_observer(observer2); - CHECK_EQUAL(2, observable.number_of_observers()); + CHECK_EQUAL(size_t(2), observable.number_of_observers()); observable.add_observer(observer3); - CHECK_EQUAL(3, observable.number_of_observers()); + CHECK_EQUAL(size_t(3), observable.number_of_observers()); observable.add_observer(observer2); - CHECK_EQUAL(3, observable.number_of_observers()); + CHECK_EQUAL(size_t(3), observable.number_of_observers()); observable.add_observer(observer4); - CHECK_EQUAL(4, observable.number_of_observers()); + CHECK_EQUAL(size_t(4), observable.number_of_observers()); CHECK_THROW(observable.add_observer(observer5), etl::observer_list_full); observable.remove_observer(observer3); - CHECK_EQUAL(3, observable.number_of_observers()); + CHECK_EQUAL(size_t(3), observable.number_of_observers()); observable.clear_observers(); - CHECK_EQUAL(0, observable.number_of_observers()); + CHECK_EQUAL(size_t(0), observable.number_of_observers()); } } } From 341c199d8f7a13f2e89388164174b2517fa8622a Mon Sep 17 00:00:00 2001 From: jwellbelove Date: Wed, 13 Jan 2016 16:08:46 +0000 Subject: [PATCH 24/43] Fixed Linux/GCC error for whar_t --- type_traits.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/type_traits.h b/type_traits.h index 5c527838..4d8a12f0 100644 --- a/type_traits.h +++ b/type_traits.h @@ -267,7 +267,7 @@ namespace etl template <> struct make_unsigned { typedef unsigned char type; }; template <> struct make_unsigned { typedef unsigned char type; }; template <> struct make_unsigned { typedef unsigned short type; }; -#if defined(COMPILER_GCC) +#if defined(COMPILER_GCC) && !defined(PLATFORM_LINUX) template <> struct make_unsigned { typedef wchar_t type; From 26fdc2e7d25a4b010adddfaef6873b93c3e25e94 Mon Sep 17 00:00:00 2001 From: jwellbelove Date: Wed, 13 Jan 2016 16:09:43 +0000 Subject: [PATCH 25/43] Removed usused line. --- ideque.h | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/ideque.h b/ideque.h index f84f976f..aa769937 100644 --- a/ideque.h +++ b/ideque.h @@ -271,7 +271,7 @@ namespace etl //*************************************************** const_iterator() : index(0), - p_deque(0), + p_deque(0), p_buffer(0) { } @@ -514,10 +514,10 @@ namespace etl reference at(size_t index) { ETL_ASSERT(index < current_size, ETL_ERROR(deque_out_of_bounds)); - + iterator result(_begin); result += index; - + return *result; } @@ -535,7 +535,7 @@ namespace etl return *result; } - + //************************************************************************* /// Gets a reference to the item at the index. ///\return A reference to the item at the index. @@ -611,7 +611,7 @@ namespace etl { return _begin; } - + //************************************************************************* /// Gets a const iterator to the beginning of the deque. //************************************************************************* @@ -691,7 +691,7 @@ namespace etl { return const_reverse_iterator(cbegin()); } - + //************************************************************************* /// Clears the deque. //************************************************************************* @@ -740,7 +740,7 @@ namespace etl { // Construct the _end. create_element_back(*(_end - 1)); - + // Move the values. std::copy_backward(position, _end - 2, _end - 1); @@ -771,7 +771,7 @@ namespace etl { create_element_front(value); } - + position = _begin; } else if (insert_position == end()) @@ -828,7 +828,6 @@ namespace etl } else { - size_t insert_index = std::distance(begin(), position); size_t n_insert = n; size_t n_move = std::distance(position, end()); size_t n_create_copy = std::min(n_insert, n_move); @@ -1044,14 +1043,14 @@ namespace etl position = end(); } else - { + { // Copy the smallest number of items. // Are we closer to the front? if (distance(_begin, position) < difference_type(current_size / 2)) { // Move the items. std::copy_backward(_begin, position, position + length); - + for (size_t i = 0; i < length; ++i) { destroy_element_front(); @@ -1064,7 +1063,7 @@ namespace etl { // Move the items. std::copy(position + length, _end, position); - + for (size_t i = 0; i < length; ++i) { destroy_element_back(); From 01ff869fb5dd1b3740754fc8343c0025db2c9ccc Mon Sep 17 00:00:00 2001 From: jwellbelove Date: Wed, 13 Jan 2016 16:10:15 +0000 Subject: [PATCH 26/43] Fixed test compile warnings --- test/test_alignment.cpp | 4 +- test/test_binary.cpp | 136 ++++++++++++++++++------------------- test/test_bloom_filter.cpp | 8 +-- test/test_crc.cpp | 10 +-- test/test_maths.cpp | 32 ++++----- test/test_pool.cpp | 6 +- test/test_queue.cpp | 10 +-- test/test_stack.cpp | 18 ++--- 8 files changed, 111 insertions(+), 113 deletions(-) diff --git a/test/test_alignment.cpp b/test/test_alignment.cpp index 0e2de31d..45d0e8dc 100644 --- a/test/test_alignment.cpp +++ b/test/test_alignment.cpp @@ -60,7 +60,7 @@ namespace for (int i = 0; i < 10; ++i) { - CHECK_EQUAL(0, size_t(&data32[1]) % expected); + CHECK_EQUAL(0U, size_t(&data32[1]) % expected); } etl::aligned_storage<100, 8>::type data9; @@ -83,7 +83,7 @@ namespace for (int i = 0; i < 10; ++i) { - CHECK_EQUAL(0, size_t(&data32[1]) % expected); + CHECK_EQUAL(0U, size_t(&data32[1]) % expected); } etl::aligned_storage<100, 8>::type data9; diff --git a/test/test_binary.cpp b/test/test_binary.cpp index 11a27e20..5eb500a1 100644 --- a/test/test_binary.cpp +++ b/test/test_binary.cpp @@ -512,15 +512,15 @@ namespace value = 0xF0C3A55A; value = etl::reverse_bytes(value); - CHECK_EQUAL(0x5AA5C3F0, value); + CHECK_EQUAL(0x5AA5C3F0U, value); value = 0xA5A55A5A; value = etl::reverse_bytes(value); - CHECK_EQUAL(0x5A5AA5A5, value); + CHECK_EQUAL(0x5A5AA5A5U, value); value = 0x5A5AA5A5; value = etl::reverse_bytes(value); - CHECK_EQUAL(0xA5A55A5A, value); + CHECK_EQUAL(0xA5A55A5AU, value); } //************************************************************************* @@ -708,8 +708,6 @@ namespace { const uint64_t data = 0xE8C9AACCBC3D9A8F; - uint8_t result = etl::fold_bits(data); - CHECK_EQUAL(test_fold_bits(data, 1), (etl::fold_bits(data))); CHECK_EQUAL(test_fold_bits(data, 2), (etl::fold_bits(data))); CHECK_EQUAL(test_fold_bits(data, 3), (etl::fold_bits(data))); @@ -780,70 +778,70 @@ namespace { // Check that the values are correct. //CHECK_EQUAL(0, etl::max_value_for_nbits<0>::value); - CHECK_EQUAL(1, etl::max_value_for_nbits<1>::value); - CHECK_EQUAL(3, etl::max_value_for_nbits<2>::value); - CHECK_EQUAL(7, etl::max_value_for_nbits<3>::value); - CHECK_EQUAL(15, etl::max_value_for_nbits<4>::value); - CHECK_EQUAL(31, etl::max_value_for_nbits<5>::value); - CHECK_EQUAL(63, etl::max_value_for_nbits<6>::value); - CHECK_EQUAL(127, etl::max_value_for_nbits<7>::value); - CHECK_EQUAL(255, etl::max_value_for_nbits<8>::value); - CHECK_EQUAL(511, etl::max_value_for_nbits<9>::value); - CHECK_EQUAL(1023, etl::max_value_for_nbits<10>::value); - CHECK_EQUAL(2047, etl::max_value_for_nbits<11>::value); - CHECK_EQUAL(4095, etl::max_value_for_nbits<12>::value); - CHECK_EQUAL(8191, etl::max_value_for_nbits<13>::value); - CHECK_EQUAL(16383, etl::max_value_for_nbits<14>::value); - CHECK_EQUAL(32767, etl::max_value_for_nbits<15>::value); - CHECK_EQUAL(65535, etl::max_value_for_nbits<16>::value); - CHECK_EQUAL(131071, etl::max_value_for_nbits<17>::value); - CHECK_EQUAL(262143, etl::max_value_for_nbits<18>::value); - CHECK_EQUAL(524287, etl::max_value_for_nbits<19>::value); - CHECK_EQUAL(1048575, etl::max_value_for_nbits<20>::value); - CHECK_EQUAL(2097151, etl::max_value_for_nbits<21>::value); - CHECK_EQUAL(4194303, etl::max_value_for_nbits<22>::value); - CHECK_EQUAL(8388607, etl::max_value_for_nbits<23>::value); - CHECK_EQUAL(16777215, etl::max_value_for_nbits<24>::value); - CHECK_EQUAL(33554431, etl::max_value_for_nbits<25>::value); - CHECK_EQUAL(67108863, etl::max_value_for_nbits<26>::value); - CHECK_EQUAL(134217727, etl::max_value_for_nbits<27>::value); - CHECK_EQUAL(268435455, etl::max_value_for_nbits<28>::value); - CHECK_EQUAL(536870911, etl::max_value_for_nbits<29>::value); - CHECK_EQUAL(1073741823, etl::max_value_for_nbits<30>::value); - CHECK_EQUAL(2147483647, etl::max_value_for_nbits<31>::value); - CHECK_EQUAL(4294967295, etl::max_value_for_nbits<32>::value); - CHECK_EQUAL(8589934591, etl::max_value_for_nbits<33>::value); - CHECK_EQUAL(17179869183, etl::max_value_for_nbits<34>::value); - CHECK_EQUAL(34359738367, etl::max_value_for_nbits<35>::value); - CHECK_EQUAL(68719476735, etl::max_value_for_nbits<36>::value); - CHECK_EQUAL(137438953471, etl::max_value_for_nbits<37>::value); - CHECK_EQUAL(274877906943, etl::max_value_for_nbits<38>::value); - CHECK_EQUAL(549755813887, etl::max_value_for_nbits<39>::value); - CHECK_EQUAL(1099511627775, etl::max_value_for_nbits<40>::value); - CHECK_EQUAL(2199023255551, etl::max_value_for_nbits<41>::value); - CHECK_EQUAL(4398046511103, etl::max_value_for_nbits<42>::value); - CHECK_EQUAL(8796093022207, etl::max_value_for_nbits<43>::value); - CHECK_EQUAL(17592186044415, etl::max_value_for_nbits<44>::value); - CHECK_EQUAL(35184372088831, etl::max_value_for_nbits<45>::value); - CHECK_EQUAL(70368744177663, etl::max_value_for_nbits<46>::value); - CHECK_EQUAL(140737488355327, etl::max_value_for_nbits<47>::value); - CHECK_EQUAL(281474976710655, etl::max_value_for_nbits<48>::value); - CHECK_EQUAL(562949953421311, etl::max_value_for_nbits<49>::value); - CHECK_EQUAL(1125899906842623, etl::max_value_for_nbits<50>::value); - CHECK_EQUAL(2251799813685247, etl::max_value_for_nbits<51>::value); - CHECK_EQUAL(4503599627370495, etl::max_value_for_nbits<52>::value); - CHECK_EQUAL(9007199254740991, etl::max_value_for_nbits<53>::value); - CHECK_EQUAL(18014398509481983, etl::max_value_for_nbits<54>::value); - CHECK_EQUAL(36028797018963967, etl::max_value_for_nbits<55>::value); - CHECK_EQUAL(72057594037927935, etl::max_value_for_nbits<56>::value); - CHECK_EQUAL(144115188075855871, etl::max_value_for_nbits<57>::value); - CHECK_EQUAL(288230376151711743, etl::max_value_for_nbits<58>::value); - CHECK_EQUAL(576460752303423487, etl::max_value_for_nbits<59>::value); - CHECK_EQUAL(1152921504606846975, etl::max_value_for_nbits<60>::value); - CHECK_EQUAL(2305843009213693951, etl::max_value_for_nbits<61>::value); - CHECK_EQUAL(4611686018427387903, etl::max_value_for_nbits<62>::value); - CHECK_EQUAL(9223372036854775807, etl::max_value_for_nbits<63>::value); - CHECK_EQUAL((unsigned long long)18446744073709551615, etl::max_value_for_nbits<64>::value); + CHECK_EQUAL(1U, etl::max_value_for_nbits<1>::value); + CHECK_EQUAL(3U, etl::max_value_for_nbits<2>::value); + CHECK_EQUAL(7U, etl::max_value_for_nbits<3>::value); + CHECK_EQUAL(15U, etl::max_value_for_nbits<4>::value); + CHECK_EQUAL(31U, etl::max_value_for_nbits<5>::value); + CHECK_EQUAL(63U, etl::max_value_for_nbits<6>::value); + CHECK_EQUAL(127U, etl::max_value_for_nbits<7>::value); + CHECK_EQUAL(255U, etl::max_value_for_nbits<8>::value); + CHECK_EQUAL(511U, etl::max_value_for_nbits<9>::value); + CHECK_EQUAL(1023U, etl::max_value_for_nbits<10>::value); + CHECK_EQUAL(2047U, etl::max_value_for_nbits<11>::value); + CHECK_EQUAL(4095U, etl::max_value_for_nbits<12>::value); + CHECK_EQUAL(8191U, etl::max_value_for_nbits<13>::value); + CHECK_EQUAL(16383U, etl::max_value_for_nbits<14>::value); + CHECK_EQUAL(32767U, etl::max_value_for_nbits<15>::value); + CHECK_EQUAL(65535U, etl::max_value_for_nbits<16>::value); + CHECK_EQUAL(131071U, etl::max_value_for_nbits<17>::value); + CHECK_EQUAL(262143U, etl::max_value_for_nbits<18>::value); + CHECK_EQUAL(524287U, etl::max_value_for_nbits<19>::value); + CHECK_EQUAL(1048575U, etl::max_value_for_nbits<20>::value); + CHECK_EQUAL(2097151U, etl::max_value_for_nbits<21>::value); + CHECK_EQUAL(4194303U, etl::max_value_for_nbits<22>::value); + CHECK_EQUAL(8388607U, etl::max_value_for_nbits<23>::value); + CHECK_EQUAL(16777215U, etl::max_value_for_nbits<24>::value); + CHECK_EQUAL(33554431U, etl::max_value_for_nbits<25>::value); + CHECK_EQUAL(67108863U, etl::max_value_for_nbits<26>::value); + CHECK_EQUAL(134217727U, etl::max_value_for_nbits<27>::value); + CHECK_EQUAL(268435455U, etl::max_value_for_nbits<28>::value); + CHECK_EQUAL(536870911U, etl::max_value_for_nbits<29>::value); + CHECK_EQUAL(1073741823U, etl::max_value_for_nbits<30>::value); + CHECK_EQUAL(2147483647U, etl::max_value_for_nbits<31>::value); + CHECK_EQUAL(4294967295U, etl::max_value_for_nbits<32>::value); + CHECK_EQUAL(8589934591U, etl::max_value_for_nbits<33>::value); + CHECK_EQUAL(17179869183U, etl::max_value_for_nbits<34>::value); + CHECK_EQUAL(34359738367U, etl::max_value_for_nbits<35>::value); + CHECK_EQUAL(68719476735U, etl::max_value_for_nbits<36>::value); + CHECK_EQUAL(137438953471U, etl::max_value_for_nbits<37>::value); + CHECK_EQUAL(274877906943U, etl::max_value_for_nbits<38>::value); + CHECK_EQUAL(549755813887U, etl::max_value_for_nbits<39>::value); + CHECK_EQUAL(1099511627775U, etl::max_value_for_nbits<40>::value); + CHECK_EQUAL(2199023255551U, etl::max_value_for_nbits<41>::value); + CHECK_EQUAL(4398046511103U, etl::max_value_for_nbits<42>::value); + CHECK_EQUAL(8796093022207U, etl::max_value_for_nbits<43>::value); + CHECK_EQUAL(17592186044415U, etl::max_value_for_nbits<44>::value); + CHECK_EQUAL(35184372088831U, etl::max_value_for_nbits<45>::value); + CHECK_EQUAL(70368744177663U, etl::max_value_for_nbits<46>::value); + CHECK_EQUAL(140737488355327U, etl::max_value_for_nbits<47>::value); + CHECK_EQUAL(281474976710655U, etl::max_value_for_nbits<48>::value); + CHECK_EQUAL(562949953421311U, etl::max_value_for_nbits<49>::value); + CHECK_EQUAL(1125899906842623U, etl::max_value_for_nbits<50>::value); + CHECK_EQUAL(2251799813685247U, etl::max_value_for_nbits<51>::value); + CHECK_EQUAL(4503599627370495U, etl::max_value_for_nbits<52>::value); + CHECK_EQUAL(9007199254740991U, etl::max_value_for_nbits<53>::value); + CHECK_EQUAL(18014398509481983U, etl::max_value_for_nbits<54>::value); + CHECK_EQUAL(36028797018963967U, etl::max_value_for_nbits<55>::value); + CHECK_EQUAL(72057594037927935U, etl::max_value_for_nbits<56>::value); + CHECK_EQUAL(144115188075855871U, etl::max_value_for_nbits<57>::value); + CHECK_EQUAL(288230376151711743U, etl::max_value_for_nbits<58>::value); + CHECK_EQUAL(576460752303423487U, etl::max_value_for_nbits<59>::value); + CHECK_EQUAL(1152921504606846975U, etl::max_value_for_nbits<60>::value); + CHECK_EQUAL(2305843009213693951U, etl::max_value_for_nbits<61>::value); + CHECK_EQUAL(4611686018427387903U, etl::max_value_for_nbits<62>::value); + CHECK_EQUAL(9223372036854775807U, etl::max_value_for_nbits<63>::value); + CHECK_EQUAL(18446744073709551615U, etl::max_value_for_nbits<64>::value); // Check that the value types are correct. CHECK((std::is_same::value_type>::value)); diff --git a/test/test_bloom_filter.cpp b/test/test_bloom_filter.cpp index aebaa7ba..c5831bdd 100644 --- a/test/test_bloom_filter.cpp +++ b/test/test_bloom_filter.cpp @@ -198,8 +198,8 @@ namespace typedef etl::bloom_filter<256, hash1_t> Bloom; Bloom bloom; - CHECK_EQUAL(256, bloom.width()); - CHECK_EQUAL(256, Bloom::WIDTH); + CHECK_EQUAL(256U, bloom.width()); + CHECK_EQUAL(256U, Bloom::WIDTH); } //************************************************************************* @@ -247,8 +247,8 @@ namespace size_t usage = bloom.usage(); size_t count = bloom.count(); - CHECK_EQUAL(0, usage); - CHECK_EQUAL(0, count); + CHECK_EQUAL(0U, usage); + CHECK_EQUAL(0U, count); // Check that we get no matches. bool any_exist = false; diff --git a/test/test_crc.cpp b/test/test_crc.cpp index 1f3a0029..dec4924b 100644 --- a/test/test_crc.cpp +++ b/test/test_crc.cpp @@ -41,7 +41,7 @@ SOFTWARE. #include "../crc64_ecma.h" namespace -{ +{ SUITE(test_crc) { //************************************************************************* @@ -65,7 +65,7 @@ namespace { crc_calculator.add(data[i]); } - + uint8_t crc = crc_calculator; CHECK_EQUAL(0xF4, crc); @@ -332,7 +332,7 @@ namespace uint64_t crc = etl::crc64_ecma(data.begin(), data.end()); - CHECK_EQUAL(0x6C40DF5F0B497347, crc); + CHECK_EQUAL(0x6C40DF5F0B497347U, crc); } //************************************************************************* @@ -349,7 +349,7 @@ namespace uint64_t crc = crc_calculator; - CHECK_EQUAL(0x6C40DF5F0B497347, crc); + CHECK_EQUAL(0x6C40DF5F0B497347U, crc); } //************************************************************************* @@ -363,7 +363,7 @@ namespace uint64_t crc = crc_calculator.value(); - CHECK_EQUAL(0x6C40DF5F0B497347, crc); + CHECK_EQUAL(0x6C40DF5F0B497347U, crc); } //************************************************************************* diff --git a/test/test_maths.cpp b/test/test_maths.cpp index 82a879ad..9e883e89 100644 --- a/test/test_maths.cpp +++ b/test/test_maths.cpp @@ -34,7 +34,7 @@ SOFTWARE. #include "../factorial.h" namespace -{ +{ SUITE(test_maths) { //************************************************************************* @@ -131,51 +131,51 @@ namespace // 2^1 actual = etl::power<2, 1>::value; - CHECK_EQUAL(2, actual); + CHECK_EQUAL(2U, actual); // 3^2 actual = etl::power<3, 2>::value; - CHECK_EQUAL(9, actual); + CHECK_EQUAL(9U, actual); // 4^3 actual = etl::power<4, 3>::value; - CHECK_EQUAL(64, actual); + CHECK_EQUAL(64U, actual); // 5^4 actual = etl::power<5, 4>::value; - CHECK_EQUAL(625, actual); + CHECK_EQUAL(625U, actual); // 6^5 actual = etl::power<6, 5>::value; - CHECK_EQUAL(7776, actual); + CHECK_EQUAL(7776U, actual); // 7^6 actual = etl::power<7, 6>::value; - CHECK_EQUAL(117649, actual); + CHECK_EQUAL(117649U, actual); // 8^7 actual = etl::power<8, 7>::value; - CHECK_EQUAL(2097152, actual); + CHECK_EQUAL(2097152U, actual); // 9^8 actual = etl::power<9, 8>::value; - CHECK_EQUAL(43046721, actual); + CHECK_EQUAL(43046721U, actual); // 10^9 actual = etl::power<10, 9>::value; - CHECK_EQUAL(1000000000, actual); + CHECK_EQUAL(1000000000U, actual); // 2^16 actual = etl::power<2, 15>::value; - CHECK_EQUAL(0x8000, actual); + CHECK_EQUAL(0x8000U, actual); // 2^31 actual = etl::power<2, 31>::value; - CHECK_EQUAL(0x80000000, actual); + CHECK_EQUAL(0x80000000U, actual); // 2^63 actual = etl::power<2, 63>::value; - CHECK_EQUAL(0x8000000000000000, actual); + CHECK_EQUAL(0x8000000000000000U, actual); } //************************************************************************* @@ -183,7 +183,7 @@ namespace { int actual; - // + // actual = etl::power_of_2_round_up<0>::value; CHECK_EQUAL(2, actual); @@ -328,7 +328,7 @@ namespace 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(2971215073, (size_t)etl::fibonacci<47>::value); + CHECK_EQUAL(2971215073U, (size_t)etl::fibonacci<47>::value); } TEST(test_factorial) @@ -348,4 +348,4 @@ namespace CHECK_EQUAL(479001600, (size_t)etl::factorial<12>::value); } }; -} \ No newline at end of file +} diff --git a/test/test_pool.cpp b/test/test_pool.cpp index 950594e7..42638eb3 100644 --- a/test/test_pool.cpp +++ b/test/test_pool.cpp @@ -47,7 +47,7 @@ namespace TEST(test_allocate) { etl::pool pool; - + Test_Data* p1; Test_Data* p2; Test_Data* p3; @@ -83,7 +83,7 @@ namespace CHECK_NO_THROW(pool.release(p1)); CHECK_NO_THROW(pool.release(*p4)); - CHECK_EQUAL(4, pool.available()); + CHECK_EQUAL(4U, pool.available()); Test_Data not_in_pool; @@ -102,7 +102,7 @@ namespace // Allocated p1, p2, p3, p4 - CHECK_EQUAL(0, pool.available()); + CHECK_EQUAL(0U, pool.available()); CHECK_NO_THROW(pool.release(p2)); CHECK_NO_THROW(pool.release(p3)); diff --git a/test/test_queue.cpp b/test/test_queue.cpp index 610f94db..3b67966a 100644 --- a/test/test_queue.cpp +++ b/test/test_queue.cpp @@ -33,7 +33,7 @@ SOFTWARE. #include "../queue.h" namespace -{ +{ SUITE(test_queue) { //************************************************************************* @@ -67,7 +67,7 @@ namespace queue.push(2); queue.push(3); - CHECK_EQUAL(3, queue.size()); + CHECK_EQUAL(3U, queue.size()); } //************************************************************************* @@ -78,7 +78,7 @@ namespace queue.push(1); queue.push(2); queue.clear(); - CHECK_EQUAL(0, queue.size()); + CHECK_EQUAL(0U, queue.size()); } //************************************************************************* @@ -182,10 +182,10 @@ namespace etl::queue queue; queue.push(1); - CHECK_EQUAL(1, queue.size()); + CHECK_EQUAL(1U, queue.size()); queue.push(2); - CHECK_EQUAL(2, queue.size()); + CHECK_EQUAL(2U, queue.size()); CHECK_EQUAL(1, queue.front()); diff --git a/test/test_stack.cpp b/test/test_stack.cpp index 5f36880e..d5033c67 100644 --- a/test/test_stack.cpp +++ b/test/test_stack.cpp @@ -35,7 +35,7 @@ SOFTWARE. #include "../stack.h" namespace -{ +{ SUITE(test_stack) { typedef TestDataDC ItemDC; @@ -99,7 +99,7 @@ namespace stack.push(2); stack.push(3); - CHECK_EQUAL(3, stack.size()); + CHECK_EQUAL(3U, stack.size()); } //************************************************************************* @@ -107,7 +107,7 @@ namespace { etl::stack stack; - CHECK_EQUAL(4, stack.max_size()); + CHECK_EQUAL(4U, stack.max_size()); } //************************************************************************* @@ -118,7 +118,7 @@ namespace stack.push(1); stack.push(2); stack.clear(); - CHECK_EQUAL(0, stack.size()); + CHECK_EQUAL(0U, stack.size()); } //************************************************************************* @@ -127,10 +127,10 @@ namespace etl::stack stack; stack.push(1); - CHECK_EQUAL(1, stack.size()); + CHECK_EQUAL(1U, stack.size()); stack.push(2); - CHECK_EQUAL(2, stack.size()); + CHECK_EQUAL(2U, stack.size()); CHECK_EQUAL(2, stack.top()); @@ -144,10 +144,10 @@ namespace etl::stack stack; stack.push() = 1; - CHECK_EQUAL(1, stack.size()); + CHECK_EQUAL(1U, stack.size()); stack.push() = 2; - CHECK_EQUAL(2, stack.size()); + CHECK_EQUAL(2U, stack.size()); CHECK_EQUAL(2, stack.top()); @@ -176,7 +176,7 @@ namespace stack.push(1); stack.push(2); stack.pop(); - CHECK_EQUAL(1, stack.size()); + CHECK_EQUAL(1U, stack.size()); } //************************************************************************* From 6e52088df1e83ce4aa4c44cc13481dd6a427162f Mon Sep 17 00:00:00 2001 From: jwellbelove Date: Wed, 13 Jan 2016 16:11:12 +0000 Subject: [PATCH 27/43] Added required compile macro directives to the project. --- test/codeblocks/ETL.cbp | 10 + test/codeblocks/ETL.depend | 1058 ++++++++++++++++++++++++++++++++++++ test/codeblocks/ETL.layout | 614 +++++++++++---------- 3 files changed, 1395 insertions(+), 287 deletions(-) diff --git a/test/codeblocks/ETL.cbp b/test/codeblocks/ETL.cbp index 4b3f82b4..33df9414 100644 --- a/test/codeblocks/ETL.cbp +++ b/test/codeblocks/ETL.cbp @@ -14,8 +14,13 @@ + + + + + @@ -32,6 +37,10 @@ + + + + @@ -42,6 +51,7 @@ + diff --git a/test/codeblocks/ETL.depend b/test/codeblocks/ETL.depend index 7e9fbd5d..99e3912f 100644 --- a/test/codeblocks/ETL.depend +++ b/test/codeblocks/ETL.depend @@ -3711,3 +3711,1061 @@ "alignment.h" "error_handler.h" +1452516033 source:/home/jwellbelove/Programming/etl/crc16.cpp + + +1452516033 source:/home/jwellbelove/Programming/etl/crc16_ccitt.cpp + + +1452516033 source:/home/jwellbelove/Programming/etl/crc16_kermit.cpp + + +1452516033 source:/home/jwellbelove/Programming/etl/crc32.cpp + + +1452516033 source:/home/jwellbelove/Programming/etl/crc64_ecma.cpp + + +1452516033 source:/home/jwellbelove/Programming/etl/crc8_ccitt.cpp + + +1452516033 source:/home/jwellbelove/Programming/etl/error_handler.cpp + "error_handler.h" + "nullptr.h" + +1452516033 /home/jwellbelove/Programming/etl/error_handler.h + + "exception.h" + "function.h" + +1452516033 /home/jwellbelove/Programming/etl/exception.h + +1452516033 /home/jwellbelove/Programming/etl/function.h + +1452516033 /home/jwellbelove/Programming/etl/nullptr.h + +1447740690 source:/home/jwellbelove/Programming/unittest-cpp/UnitTest++/AssertException.cpp + "AssertException.h" + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/AssertException.h + "Config.h" + "HelperMacros.h" + + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/Config.h + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/HelperMacros.h + "Config.h" + +1447740690 source:/home/jwellbelove/Programming/unittest-cpp/UnitTest++/Checks.cpp + "Checks.h" + + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/Checks.h + "Config.h" + "TestResults.h" + "MemoryOutStream.h" + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/TestResults.h + "HelperMacros.h" + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/MemoryOutStream.h + "Config.h" + "HelperMacros.h" + + + +1447740690 source:/home/jwellbelove/Programming/unittest-cpp/UnitTest++/CompositeTestReporter.cpp + "CompositeTestReporter.h" + + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/CompositeTestReporter.h + "TestReporter.h" + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/TestReporter.h + "HelperMacros.h" + +1447740690 source:/home/jwellbelove/Programming/unittest-cpp/UnitTest++/CurrentTest.cpp + "CurrentTest.h" + + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/CurrentTest.h + "HelperMacros.h" + +1447740690 source:/home/jwellbelove/Programming/unittest-cpp/UnitTest++/DeferredTestReporter.cpp + "Config.h" + "DeferredTestReporter.h" + "TestDetails.h" + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/DeferredTestReporter.h + "Config.h" + "TestReporter.h" + "DeferredTestResult.h" + + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/DeferredTestResult.h + "Config.h" + "HelperMacros.h" + + + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/TestDetails.h + "HelperMacros.h" + +1447740690 source:/home/jwellbelove/Programming/unittest-cpp/UnitTest++/DeferredTestResult.cpp + "Config.h" + "DeferredTestResult.h" + + +1447740690 source:/home/jwellbelove/Programming/unittest-cpp/UnitTest++/MemoryOutStream.cpp + "MemoryOutStream.h" + + + +1447740690 source:/home/jwellbelove/Programming/unittest-cpp/UnitTest++/Posix/SignalTranslator.cpp + "SignalTranslator.h" + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/Posix/SignalTranslator.h + + + +1447740690 source:/home/jwellbelove/Programming/unittest-cpp/UnitTest++/Posix/TimeHelpers.cpp + "TimeHelpers.h" + + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/Posix/TimeHelpers.h + + +1447740690 source:/home/jwellbelove/Programming/unittest-cpp/UnitTest++/ReportAssert.cpp + "ReportAssert.h" + "ReportAssertImpl.h" + "AssertException.h" + "CurrentTest.h" + "TestResults.h" + "TestDetails.h" + "ReportAssertImpl.h" + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/ReportAssert.h + "HelperMacros.h" + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/ReportAssertImpl.h + "Config.h" + "HelperMacros.h" + + +1447740690 source:/home/jwellbelove/Programming/unittest-cpp/UnitTest++/Test.cpp + "Config.h" + "Test.h" + "TestList.h" + "TestResults.h" + "AssertException.h" + "MemoryOutStream.h" + "ExecuteTest.h" + "Posix/SignalTranslator.h" + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/Test.h + "TestDetails.h" + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/TestList.h + "HelperMacros.h" + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/ExecuteTest.h + "Config.h" + "ExceptionMacros.h" + "TestDetails.h" + "TestResults.h" + "MemoryOutStream.h" + "AssertException.h" + "CurrentTest.h" + "ReportAssertImpl.h" + "Posix/SignalTranslator.h" + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/ExceptionMacros.h + "Config.h" + +1447740690 source:/home/jwellbelove/Programming/unittest-cpp/UnitTest++/TestDetails.cpp + "TestDetails.h" + +1447740690 source:/home/jwellbelove/Programming/unittest-cpp/UnitTest++/TestList.cpp + "TestList.h" + "Test.h" + + +1447740690 source:/home/jwellbelove/Programming/unittest-cpp/UnitTest++/TestReporter.cpp + "TestReporter.h" + +1447740690 source:/home/jwellbelove/Programming/unittest-cpp/UnitTest++/TestReporterStdout.cpp + "TestReporterStdout.h" + + "TestDetails.h" + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/TestReporterStdout.h + "TestReporter.h" + +1447740690 source:/home/jwellbelove/Programming/unittest-cpp/UnitTest++/TestResults.cpp + "TestResults.h" + "TestReporter.h" + "TestDetails.h" + +1447740690 source:/home/jwellbelove/Programming/unittest-cpp/UnitTest++/TestRunner.cpp + "TestRunner.h" + "TestResults.h" + "TestReporter.h" + "TestReporterStdout.h" + "TimeHelpers.h" + "MemoryOutStream.h" + + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/TestRunner.h + "Test.h" + "TestList.h" + "CurrentTest.h" + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/TimeHelpers.h + "Config.h" + "Posix/TimeHelpers.h" + "Win32/TimeHelpers.h" + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/Win32/TimeHelpers.h + "../Config.h" + "../HelperMacros.h" + +1447740690 source:/home/jwellbelove/Programming/unittest-cpp/UnitTest++/TimeConstraint.cpp + "TimeConstraint.h" + "TestResults.h" + "MemoryOutStream.h" + "CurrentTest.h" + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/TimeConstraint.h + "TimeHelpers.h" + "HelperMacros.h" + "TestDetails.h" + +1447740690 source:/home/jwellbelove/Programming/unittest-cpp/UnitTest++/XmlTestReporter.cpp + "Config.h" + "XmlTestReporter.h" + + + + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/XmlTestReporter.h + "Config.h" + "DeferredTestReporter.h" + + +1452692153 source:/home/jwellbelove/Programming/etl/test/main.cpp + + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/UnitTest++.h + "UnitTestPP.h" + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/UnitTestPP.h + "Config.h" + "TestMacros.h" + "CheckMacros.h" + "TestRunner.h" + "TimeConstraint.h" + "ReportAssert.h" + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/TestMacros.h + "Config.h" + "TestSuite.h" + "ExceptionMacros.h" + "ExecuteTest.h" + "AssertException.h" + "TestDetails.h" + "MemoryOutStream.h" + "Posix/SignalTranslator.h" + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/TestSuite.h + +1447740690 /home/jwellbelove/Programming/unittest-cpp/UnitTest++/CheckMacros.h + "HelperMacros.h" + "ExceptionMacros.h" + "Checks.h" + "AssertException.h" + "MemoryOutStream.h" + "TestDetails.h" + "CurrentTest.h" + "ReportAssertImpl.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_algorithm.cpp + + "../algorithm.h" + "../container.h" + + + + + +1452516120 /home/jwellbelove/Programming/etl/algorithm.h + + + + + + "type_traits.h" + +1452700367 /home/jwellbelove/Programming/etl/type_traits.h + + "nullptr.h" + +1452516033 /home/jwellbelove/Programming/etl/container.h + + + +1452700976 source:/home/jwellbelove/Programming/etl/test/test_alignment.cpp + + "../alignment.h" + "../type_traits.h" + + + + + +1452516033 /home/jwellbelove/Programming/etl/alignment.h + + "type_traits.h" + "static_assert.h" + +1452516033 /home/jwellbelove/Programming/etl/static_assert.h + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_array.cpp + + "../array.h" + + + + "../integral_limits.h" + +1452516033 /home/jwellbelove/Programming/etl/array.h + + + + + "exception.h" + "type_traits.h" + "parameter_type.h" + "static_assert.h" + "error_handler.h" + +1452516033 /home/jwellbelove/Programming/etl/parameter_type.h + "type_traits.h" + +1452516033 /home/jwellbelove/Programming/etl/integral_limits.h + + + "type_traits.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_binary.cpp + + + + "../binary.h" + "../bitset.h" + "../fnv_1.h" + "../integral_limits.h" + +1452516033 /home/jwellbelove/Programming/etl/binary.h + "type_traits.h" + "integral_limits.h" + "static_assert.h" + "log.h" + "power.h" + "smallest.h" + +1452516033 /home/jwellbelove/Programming/etl/log.h + + +1452516033 /home/jwellbelove/Programming/etl/power.h + + "log.h" + +1452516033 /home/jwellbelove/Programming/etl/smallest.h + + "integral_limits.h" + +1452516120 /home/jwellbelove/Programming/etl/bitset.h + + + + + "integral_limits.h" + "algorithm.h" + "nullptr.h" + "log.h" + "ibitset.h" + "error_handler.h" + +1452687411 /home/jwellbelove/Programming/etl/ibitset.h + + + "exception.h" + "integral_limits.h" + "binary.h" + +1452516033 /home/jwellbelove/Programming/etl/fnv_1.h + + "static_assert.h" + "type_traits.h" + "ihash.h" + +1452516033 /home/jwellbelove/Programming/etl/ihash.h + + + "exception.h" + "error_handler.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_bitset.cpp + + + + + "../bitset.h" + +1452701006 source:/home/jwellbelove/Programming/etl/test/test_bloom_filter.cpp + + + + "../bloom_filter.h" + "../fnv_1.h" + "../crc16.h" + "../crc16_ccitt.h" + "../crc32.h" + +1452516033 /home/jwellbelove/Programming/etl/bloom_filter.h + "parameter_type.h" + "bitset.h" + "type_traits.h" + "binary.h" + "log.h" + "power.h" + +1452516033 /home/jwellbelove/Programming/etl/crc16.h + + "static_assert.h" + "type_traits.h" + +1452516033 /home/jwellbelove/Programming/etl/crc16_ccitt.h + + "static_assert.h" + "type_traits.h" + +1452516033 /home/jwellbelove/Programming/etl/crc32.h + + + "static_assert.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_checksum.cpp + + + + + + "../checksum.h" + "../endian.h" + +1452516033 /home/jwellbelove/Programming/etl/checksum.h + + "static_assert.h" + "type_traits.h" + "ihash.h" + +1452516033 /home/jwellbelove/Programming/etl/endian.h + + "enum_type.h" + +1452516120 /home/jwellbelove/Programming/etl/enum_type.h + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_container.cpp + + "../container.h" + + +1452701006 source:/home/jwellbelove/Programming/etl/test/test_crc.cpp + + + + + + "../crc8_ccitt.h" + "../crc16.h" + "../crc16_ccitt.h" + "../crc16_kermit.h" + "../crc32.h" + "../crc64_ecma.h" + +1452516033 /home/jwellbelove/Programming/etl/crc8_ccitt.h + + "static_assert.h" + "type_traits.h" + +1452516033 /home/jwellbelove/Programming/etl/crc16_kermit.h + + "static_assert.h" + "type_traits.h" + +1452516033 /home/jwellbelove/Programming/etl/crc64_ecma.h + + "static_assert.h" + "type_traits.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_cyclic_value.cpp + + "../cyclic_value.h" + +1452516033 /home/jwellbelove/Programming/etl/cyclic_value.h + + + "static_assert.h" + "exception.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_deque.cpp + + "ExtraCheckMacros.h" + "../deque.h" + "data.h" + + + + + + +1452516033 /home/jwellbelove/Programming/etl/test/ExtraCheckMacros.h + + + + + + + + + +1452516120 /home/jwellbelove/Programming/etl/deque.h + + + + + "ideque.h" + "container.h" + "alignment.h" + "array.h" + +1452700904 /home/jwellbelove/Programming/etl/ideque.h + + + "algorithm.h" + "type_traits.h" + "private/deque_base.h" + "parameter_type.h" + "error_handler.h" + +1452516033 /home/jwellbelove/Programming/etl/private/deque_base.h + + "../exception.h" + "../error_handler.h" + +1452516033 /home/jwellbelove/Programming/etl/test/data.h + + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_endian.cpp + + + "../endian.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_enum_type.cpp + + + "../enum_type.h" + +1452692276 source:/home/jwellbelove/Programming/etl/test/test_error_handler.cpp + + + + + "../error_handler.h" + "../exception.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_exception.cpp + + + "../exception.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_fixed_iterator.cpp + + + + "../fixed_iterator.h" + +1452516033 /home/jwellbelove/Programming/etl/fixed_iterator.h + + +1452516120 source:/home/jwellbelove/Programming/etl/test/test_flat_map.cpp + + + + + + + + + "data.h" + "../flat_map.h" + +1452516033 /home/jwellbelove/Programming/etl/flat_map.h + + + + "iflat_map.h" + "vector.h" + +1452587158 /home/jwellbelove/Programming/etl/iflat_map.h + + + + + + "private/flat_map_base.h" + "type_traits.h" + "parameter_type.h" + "ivector.h" + "error_handler.h" + +1452516033 /home/jwellbelove/Programming/etl/private/flat_map_base.h + + "../exception.h" + "../ivector.h" + "../error_handler.h" + +1452587158 /home/jwellbelove/Programming/etl/ivector.h + + + + + "algorithm.h" + "private/vector_base.h" + "type_traits.h" + "parameter_type.h" + "error_handler.h" + +1452516033 /home/jwellbelove/Programming/etl/private/vector_base.h + + "../exception.h" + "../error_handler.h" + +1452524360 /home/jwellbelove/Programming/etl/vector.h + + + + "ivector.h" + "container.h" + "alignment.h" + "array.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_flat_set.cpp + + + + + + + + + "data.h" + "../flat_set.h" + +1452516033 /home/jwellbelove/Programming/etl/flat_set.h + + + + "iflat_set.h" + "vector.h" + +1452587158 /home/jwellbelove/Programming/etl/iflat_set.h + + + + + + "private/flat_set_base.h" + "type_traits.h" + "parameter_type.h" + "ivector.h" + "error_handler.h" + +1452516033 /home/jwellbelove/Programming/etl/private/flat_set_base.h + + "../exception.h" + "../ivector.h" + "../error_handler.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_fnv_1.cpp + + + + + + "../fnv_1.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_forward_list.cpp + + "ExtraCheckMacros.h" + "data.h" + "../forward_list.h" + + + + + + +1452516120 /home/jwellbelove/Programming/etl/forward_list.h + + "pool.h" + "iforward_list.h" + "container.h" + +1452516033 /home/jwellbelove/Programming/etl/pool.h + "alignment.h" + "array.h" + "bitset.h" + "ipool.h" + + +1452587158 /home/jwellbelove/Programming/etl/ipool.h + + "private/pool_base.h" + "nullptr.h" + "ibitset.h" + "error_handler.h" + +1452587158 /home/jwellbelove/Programming/etl/private/pool_base.h + + "../exception.h" + "../error_handler.h" + "../error_handler.h" + +1452587158 /home/jwellbelove/Programming/etl/iforward_list.h + + + + + "pool.h" + "nullptr.h" + "private/forward_list_base.h" + "type_traits.h" + "parameter_type.h" + +1452516033 /home/jwellbelove/Programming/etl/private/forward_list_base.h + + "../exception.h" + "../error_handler.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_function.cpp + + "../function.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_functional.cpp + + "../functional.h" + + + + +1452516033 /home/jwellbelove/Programming/etl/functional.h + +1452697226 source:/home/jwellbelove/Programming/etl/test/test_hash.cpp + + + + + + "../hash.h" + +1452516033 /home/jwellbelove/Programming/etl/hash.h + + "fnv_1.h" + "type_traits.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_instance_count.cpp + + "../instance_count.h" + + + + +1452516033 /home/jwellbelove/Programming/etl/instance_count.h + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_integral_limits.cpp + + + + + "../integral_limits.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_io_port.cpp + + "../io_port.h" + + +1452516033 /home/jwellbelove/Programming/etl/io_port.h + + "nullptr.h" + "parameter_type.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_largest.cpp + + "../largest.h" + + +1452516033 /home/jwellbelove/Programming/etl/largest.h + "type_traits.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_list.cpp + + "ExtraCheckMacros.h" + "../list.h" + "data.h" + + + + + +1452516120 /home/jwellbelove/Programming/etl/list.h + + "ilist.h" + "container.h" + "pool.h" + +1452587158 /home/jwellbelove/Programming/etl/ilist.h + + + + + "nullptr.h" + "private/list_base.h" + "type_traits.h" + "parameter_type.h" + "pool.h" + +1452516033 /home/jwellbelove/Programming/etl/private/list_base.h + + "../exception.h" + "../error_handler.h" + +1452516120 source:/home/jwellbelove/Programming/etl/test/test_map.cpp + + + + + + + + + "../map.h" + +1452516120 /home/jwellbelove/Programming/etl/map.h + + + + "imap.h" + "container.h" + "pool.h" + +1452587158 /home/jwellbelove/Programming/etl/imap.h + + + + + "nullptr.h" + "private/map_base.h" + "type_traits.h" + "parameter_type.h" + "pool.h" + +1452516033 /home/jwellbelove/Programming/etl/private/map_base.h + + "../exception.h" + "../error_handler.h" + +1452700712 source:/home/jwellbelove/Programming/etl/test/test_maths.cpp + + "../log.h" + "../power.h" + "../fibonacci.h" + "../factorial.h" + +1452516033 /home/jwellbelove/Programming/etl/fibonacci.h + + +1452516033 /home/jwellbelove/Programming/etl/factorial.h + + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_numeric.cpp + + "../numeric.h" + + + +1452516033 /home/jwellbelove/Programming/etl/numeric.h + +1452696227 source:/home/jwellbelove/Programming/etl/test/test_observer.cpp + + "../observer.h" + +1452587158 /home/jwellbelove/Programming/etl/observer.h + + "vector.h" + "exception.h" + "error_handler.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_optional.cpp + + + + "../optional.h" + "../vector.h" + "data.h" + +1452516033 /home/jwellbelove/Programming/etl/optional.h + "alignment.h" + "type_traits.h" + "exception.h" + "error_handler.h" + +1452700712 source:/home/jwellbelove/Programming/etl/test/test_pool.cpp + + "ExtraCheckMacros.h" + "data.h" + + + "../pool.h" + +1452700712 source:/home/jwellbelove/Programming/etl/test/test_queue.cpp + + + "../queue.h" + +1452516033 /home/jwellbelove/Programming/etl/queue.h + + + "iqueue.h" + "container.h" + "alignment.h" + "array.h" + +1452587158 /home/jwellbelove/Programming/etl/iqueue.h + + "private/queue_base.h" + "type_traits.h" + "parameter_type.h" + "error_handler.h" + +1452516033 /home/jwellbelove/Programming/etl/private/queue_base.h + + "../exception.h" + "../error_handler.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_set.cpp + + + + + + + + + "../set.h" + +1452516120 /home/jwellbelove/Programming/etl/set.h + + + + "iset.h" + "container.h" + "pool.h" + +1452587158 /home/jwellbelove/Programming/etl/iset.h + + + + + "nullptr.h" + "private/set_base.h" + "type_traits.h" + "parameter_type.h" + "pool.h" + +1452516033 /home/jwellbelove/Programming/etl/private/set_base.h + + "../exception.h" + "../error_handler.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_smallest.cpp + + "../smallest.h" + + +1452700712 source:/home/jwellbelove/Programming/etl/test/test_stack.cpp + + + "data.h" + "../stack.h" + +1452516033 /home/jwellbelove/Programming/etl/stack.h + + + + "istack.h" + "container.h" + "alignment.h" + "array.h" + +1452587158 /home/jwellbelove/Programming/etl/istack.h + + "private/stack_base.h" + "type_traits.h" + "parameter_type.h" + "error_handler.h" + +1452516033 /home/jwellbelove/Programming/etl/private/stack_base.h + + "../exception.h" + "../error_handler.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_type_traits.cpp + + "../type_traits.h" + + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_variant.cpp + + "ExtraCheckMacros.h" + "../variant.h" + + + + +1452516033 /home/jwellbelove/Programming/etl/variant.h + + "array.h" + "largest.h" + "exception.h" + "type_traits.h" + "integral_limits.h" + "static_assert.h" + "alignment.h" + "error_handler.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_vector.cpp + + + + + "../vector.h" + +1452516033 source:/home/jwellbelove/Programming/etl/test/test_visitor.cpp + + "../visitor.h" + +1452516033 /home/jwellbelove/Programming/etl/visitor.h + diff --git a/test/codeblocks/ETL.layout b/test/codeblocks/ETL.layout index a5cb20c5..89345761 100644 --- a/test/codeblocks/ETL.layout +++ b/test/codeblocks/ETL.layout @@ -1,349 +1,389 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 0423a140332a39d5b6557f0f77bb6e25222fb434 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 13 Jan 2016 18:56:04 +0000 Subject: [PATCH 28/43] Fixed missing copy constructor. --- test/test_vector.cpp | 11 +++++++++++ vector.h | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/test/test_vector.cpp b/test/test_vector.cpp index d5feb40a..cbe94355 100644 --- a/test/test_vector.cpp +++ b/test/test_vector.cpp @@ -139,6 +139,17 @@ namespace CHECK(!data.empty()); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_copy_constructor) + { + Data data(initial_data.begin(), initial_data.end()); + Data data2(data); + CHECK(data2 == data); + + data2[2] = -1; + CHECK(data2 != data); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assignment) { diff --git a/vector.h b/vector.h index 9dd0e38a..83ef45c4 100644 --- a/vector.h +++ b/vector.h @@ -106,6 +106,16 @@ namespace etl ivector::assign(first, last); } + //************************************************************************* + /// Copy constructor. + //************************************************************************* + vector(const vector& other) + : ivector(reinterpret_cast(&buffer), MAX_SIZE) + { + ivector::initialise(); + ivector::assign(other.begin(), other.end()); + } + //************************************************************************* /// Assignment operator. //************************************************************************* From 8477b87e3a663234e09851734644a58d93acbbe5 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 13 Jan 2016 18:56:23 +0000 Subject: [PATCH 29/43] Added copy constructor test --- test/test_cyclic_value.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/test_cyclic_value.cpp b/test/test_cyclic_value.cpp index bd42dae3..a81df304 100644 --- a/test/test_cyclic_value.cpp +++ b/test/test_cyclic_value.cpp @@ -56,6 +56,17 @@ namespace CHECK_EQUAL(7, value.last()); } + //************************************************************************* + TEST(test_copy_constructor) + { + etl::cyclic_value value(2, 7); + etl::cyclic_value value2(value); + CHECK(value == value2); + + value2.set(3, 6); + CHECK(value != value2); + } + //************************************************************************* TEST(test_set) { From f233d527d8d257c085f9cb5db3f1feeb11f65ff6 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 13 Jan 2016 18:56:47 +0000 Subject: [PATCH 30/43] Improved erase_after test --- test/test_basic_intrusive_forward_list.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_basic_intrusive_forward_list.cpp b/test/test_basic_intrusive_forward_list.cpp index 9c1f5712..feb04f12 100644 --- a/test/test_basic_intrusive_forward_list.cpp +++ b/test/test_basic_intrusive_forward_list.cpp @@ -475,13 +475,13 @@ namespace std::advance(i_data_1, 2); DataNDC::iterator i_data_2 = data.begin(); - std::advance(i_data_2, 4); + std::advance(i_data_2, 5); std::vector::iterator i_compare_data_1 = compare_data.begin(); std::advance(i_compare_data_1, 3); std::vector::iterator i_compare_data_2 = compare_data.begin(); - std::advance(i_compare_data_2, 4); + std::advance(i_compare_data_2, 5); std::vector::iterator i_compare_result = compare_data.erase(i_compare_data_1, i_compare_data_2); From f29d45942c0f2d45ba5ce45c276834d53dbae031 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 13 Jan 2016 18:57:20 +0000 Subject: [PATCH 31/43] Modified comment --- error_handler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/error_handler.h b/error_handler.h index e1f0ea55..53875fcc 100644 --- a/error_handler.h +++ b/error_handler.h @@ -88,7 +88,7 @@ namespace etl /// Versions of the macro that return a constant value of 'true' will allow the compiler to optimise away /// any 'if' statements that it is contained within. /// If ETL_NO_CHECKS is defined then no runtime checks are executed at all. -/// If ETL_THROW_EXCEPTIONS is defined then the error is thrown if the assert fails. The return value is always 'true'. +/// If asserts or exceptions are enabled then the error is thrown if the assert fails. The return value is always 'true'. /// If ETL_LOG_ERRORS is defined then the error is logged if the assert fails. The return value is the value of the boolean test. /// Otherwise 'assert' is called. The return value is always 'true'. ///\ingroup error_handler From 1c3187844f844cf6ff10d27b0d136026ec9e4a23 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 13 Jan 2016 18:57:50 +0000 Subject: [PATCH 32/43] Simplified erase_after code. --- basic_intrusive_forward_list.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/basic_intrusive_forward_list.h b/basic_intrusive_forward_list.h index 9af8c075..94d5b0d1 100644 --- a/basic_intrusive_forward_list.h +++ b/basic_intrusive_forward_list.h @@ -519,14 +519,7 @@ namespace etl p_first = p_next; // Move to the next node. } - if (p_next == nullptr) - { - return end(); - } - else - { - return iterator(*p_last); - } + return last; } //************************************************************************* From 06815473d1d116cc0abc230df0279b435998fc64 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 14 Jan 2016 18:06:07 +0000 Subject: [PATCH 33/43] New unordered_map --- test/test_unordered_map.cpp | 545 ++++++++++++++++++++++++++++++++++++ unordered_map.h | 119 ++++++++ 2 files changed, 664 insertions(+) create mode 100644 test/test_unordered_map.cpp create mode 100644 unordered_map.h diff --git a/test/test_unordered_map.cpp b/test/test_unordered_map.cpp new file mode 100644 index 00000000..eec97746 --- /dev/null +++ b/test/test_unordered_map.cpp @@ -0,0 +1,545 @@ +/****************************************************************************** +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 + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "data.h" + +#include "../unordered_map.h" + +namespace +{ + //************************************************************************* + struct simple_hash + { + size_t operator ()(const std::string& text) const + { + return std::accumulate(text.begin(), text.end(), 0); + } + }; + + //************************************************************************* + template + bool Check_Equal(T1 begin1, T1 end1, T2 begin2) + { + while (begin1 != end1) + { + if ((begin1->first != begin2->first) || (begin1->second != begin2->second)) + { + return false; + } + + ++begin1; + ++begin2; + } + + return true; + } + + SUITE(test_unordered_map) + { + static const size_t SIZE = 10; + + typedef TestDataDC DC; + typedef TestDataNDC NDC; + + typedef std::pair ElementDC; + typedef std::pair ElementNDC; + + typedef etl::unordered_map DataDC; + typedef etl::unordered_map DataNDC; + typedef etl::iunordered_map IDataNDC; + + NDC N0 = NDC("A"); + NDC N1 = NDC("B"); + NDC N2 = NDC("C"); + NDC N3 = NDC("D"); + NDC N4 = NDC("E"); + NDC N5 = NDC("F"); + NDC N6 = NDC("G"); + NDC N7 = NDC("H"); + NDC N8 = NDC("I"); + NDC N9 = NDC("J"); + NDC N10 = NDC("K"); + NDC N11 = NDC("L"); + NDC N12 = NDC("M"); + NDC N13 = NDC("N"); + NDC N14 = NDC("O"); + NDC N15 = NDC("P"); + NDC N16 = NDC("Q"); + NDC N17 = NDC("R"); + NDC N18 = NDC("S"); + NDC N19 = NDC("T"); + + const char* K0 = "FF"; // 0 + const char* K1 = "FG"; // 1 + const char* K2 = "FH"; // 2 + const char* K3 = "FI"; // 3 + const char* K4 = "FJ"; // 4 + const char* K5 = "FK"; // 5 + const char* K6 = "FL"; // 6 + const char* K7 = "FM"; // 7 + const char* K8 = "FN"; // 8 + const char* K9 = "FO"; // 9 + const char* K10 = "FP"; // 0 + const char* K11 = "FQ"; // 1 + const char* K12 = "FR"; // 2 + const char* K13 = "FS"; // 3 + const char* K14 = "FT"; // 4 + const char* K15 = "FU"; // 5 + const char* K16 = "FV"; // 6 + const char* K17 = "FW"; // 7 + const char* K18 = "FX"; // 8 + const char* K19 = "FY"; // 9 + + std::string K[] = { K0, K1, K2, K3, K4, K5, K6, K7, K8, K9, K10, K11, K12, K13, K14, K15, K16, K17, K18, K19 }; + + std::vector initial_data; + std::vector excess_data; + std::vector different_data; + + //************************************************************************* + template + bool Check_Equal(T1 begin1, T1 end1, T2 begin2) + { + while (begin1 != end1) + { + if ((begin1->first != begin2->first) || (begin1->second != begin2->second)) + { + return false; + } + + ++begin1; + ++begin2; + } + + return true; + } + + //************************************************************************* + struct SetupFixture + { + SetupFixture() + { + ElementNDC n[] = + { + ElementNDC(K0, N0), ElementNDC(K1, N1), ElementNDC(K2, N2), ElementNDC(K3, N3), ElementNDC(K4, N4), + ElementNDC(K5, N5), ElementNDC(K6, N6), ElementNDC(K7, N7), ElementNDC(K8, N8), ElementNDC(K9, N9) + }; + + ElementNDC n2[] = + { + ElementNDC(K0, N0), ElementNDC(K1, N1), ElementNDC(K2, N2), ElementNDC(K3, N3), ElementNDC(K4, N4), + ElementNDC(K5, N5), ElementNDC(K6, N6), ElementNDC(K7, N7), ElementNDC(K8, N8), ElementNDC(K9, N9), + ElementNDC(K10, N10) + }; + + ElementNDC n3[] = + { + ElementNDC(K10, N10), ElementNDC(K11, N11), ElementNDC(K12, N12), ElementNDC(K13, N13), ElementNDC(K14, N14), + ElementNDC(K15, N15), ElementNDC(K16, N16), ElementNDC(K17, N17), ElementNDC(K18, N18), ElementNDC(K19, N19) + }; + + initial_data.assign(std::begin(n), std::end(n)); + excess_data.assign(std::begin(n2), std::end(n2)); + different_data.assign(std::begin(n3), std::end(n3)); + } + }; + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_default_constructor) + { + DataDC data; + + CHECK_EQUAL(data.size(), size_t(0)); + CHECK(data.empty()); + CHECK_EQUAL(data.max_size(), SIZE); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_range) + { + DataNDC data(initial_data.begin(), initial_data.end()); + + CHECK(data.size() == SIZE); + CHECK(!data.empty()); + CHECK(data.full()); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment) + { + DataNDC data(initial_data.begin(), initial_data.end()); + DataNDC other_data; + + other_data = data; + + bool isEqual = std::equal(data.begin(), + data.end(), + other_data.begin()); + + CHECK(isEqual); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_interface) + { + DataNDC data1(initial_data.begin(), initial_data.end()); + DataNDC data2; + + IDataNDC& idata1 = data1; + IDataNDC& idata2 = data2; + + idata2 = idata1; + + bool isEqual = std::equal(data1.begin(), + data1.end(), + data2.begin()); + + CHECK(isEqual); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_self_assignment) + { + DataNDC data(initial_data.begin(), initial_data.end()); + DataNDC other_data(data); + + other_data = other_data; + + bool isEqual = std::equal(data.begin(), + data.end(), + other_data.begin()); + + CHECK(isEqual); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_empty_full) + { + DataNDC data; + + CHECK(!data.full()); + CHECK(data.empty()); + + data.insert(initial_data.begin(), initial_data.end()); + + CHECK(data.full()); + CHECK(!data.empty()); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_index_read) + { + DataNDC data(initial_data.begin(), initial_data.end()); + + CHECK_EQUAL(N0, data[K0]); + CHECK_EQUAL(N1, data[K1]); + CHECK_EQUAL(N2, data[K2]); + CHECK_EQUAL(N3, data[K3]); + CHECK_EQUAL(N4, data[K4]); + CHECK_EQUAL(N5, data[K5]); + CHECK_EQUAL(N6, data[K6]); + CHECK_EQUAL(N7, data[K7]); + CHECK_EQUAL(N8, data[K8]); + CHECK_EQUAL(N9, data[K9]); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_index_write) + { + DataNDC data(initial_data.begin(), initial_data.end()); + + data[K0] = N9; + data[K1] = N8; + data[K2] = N7; + data[K3] = N6; + data[K4] = N5; + data[K5] = N4; + data[K6] = N3; + data[K7] = N2; + data[K8] = N1; + data[K9] = N0; + + CHECK_EQUAL(N9, data[K0]); + CHECK_EQUAL(N8, data[K1]); + CHECK_EQUAL(N7, data[K2]); + CHECK_EQUAL(N6, data[K3]); + CHECK_EQUAL(N5, data[K4]); + CHECK_EQUAL(N4, data[K5]); + CHECK_EQUAL(N3, data[K6]); + CHECK_EQUAL(N2, data[K7]); + CHECK_EQUAL(N1, data[K8]); + CHECK_EQUAL(N0, data[K9]); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_at) + { + DataNDC data(initial_data.begin(), initial_data.end()); + + CHECK_EQUAL(data.at(K0), N0); + CHECK_EQUAL(data.at(K1), N1); + CHECK_EQUAL(data.at(K2), N2); + CHECK_EQUAL(data.at(K3), N3); + CHECK_EQUAL(data.at(K4), N4); + CHECK_EQUAL(data.at(K5), N5); + CHECK_EQUAL(data.at(K6), N6); + CHECK_EQUAL(data.at(K7), N7); + CHECK_EQUAL(data.at(K8), N8); + CHECK_EQUAL(data.at(K9), N9); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_at_const) + { + const DataNDC data(initial_data.begin(), initial_data.end()); + + CHECK_EQUAL(data.at(K0), N0); + CHECK_EQUAL(data.at(K1), N1); + CHECK_EQUAL(data.at(K2), N2); + CHECK_EQUAL(data.at(K3), N3); + CHECK_EQUAL(data.at(K4), N4); + CHECK_EQUAL(data.at(K5), N5); + CHECK_EQUAL(data.at(K6), N6); + CHECK_EQUAL(data.at(K7), N7); + CHECK_EQUAL(data.at(K8), N8); + CHECK_EQUAL(data.at(K9), N9); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_range) + { + DataNDC data; + + data.assign(initial_data.begin(), initial_data.end()); + + DataNDC::iterator idata; + + for (size_t i = 0; i < 10; ++i) + { + idata = data.find(K[i]); + CHECK(idata != data.end()); + } + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_value) + { + DataNDC data; + + data.insert(DataNDC::value_type(K0, N0)); // Inserted + data.insert(DataNDC::value_type(K2, N2)); // Inserted + data.insert(DataNDC::value_type(K1, N1)); // Inserted + data.insert(DataNDC::value_type(K11, N1)); // Duplicate hash. Inserted + data.insert(DataNDC::value_type(K1, N3)); // Duplicate key. Not inserted + + CHECK_EQUAL(4, data.size()); + + DataNDC::iterator idata; + + idata = data.find(K0); + CHECK(idata != data.end()); + CHECK(idata->first == K0); + CHECK(idata->second == N0); + + idata = data.find(K1); + CHECK(idata != data.end()); + CHECK(idata->first == K1); + CHECK(idata->second == N1); + + idata = data.find(K2); + CHECK(idata != data.end()); + CHECK(idata->first == K2); + CHECK(idata->second == N2); + + idata = data.find(K11); + CHECK(idata != data.end()); + CHECK(idata->first == K11); + CHECK(idata->second == N1); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_value_excess) + { + DataNDC data(initial_data.begin(), initial_data.end()); + + CHECK_THROW(data.insert(std::make_pair(K10, N10)), etl::unordered_map_full); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_range) + { + DataNDC data; + + data.insert(initial_data.begin(), initial_data.end()); + + for (size_t i = 0; i < data.size(); ++i) + { + DataNDC::iterator idata = data.find(initial_data[i].first); + CHECK(idata != data.end()); + } + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_range_excess) + { + DataNDC data; + + CHECK_THROW(data.insert(excess_data.begin(), excess_data.end()), etl::unordered_map_full); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_erase_key) + { + DataNDC data(initial_data.begin(), initial_data.end()); + + size_t count = data.erase(K5); + + CHECK_EQUAL(1, count); + + DataNDC::iterator idata = data.find(K5); + CHECK(idata == data.end()); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_erase_single) + { + DataNDC data(initial_data.begin(), initial_data.end()); + + DataNDC::const_iterator idata = data.find(K5); + DataNDC::const_iterator inext = idata; + ++inext; + + DataNDC::const_iterator iafter = data.erase(idata); + idata = data.find(K5); + + CHECK(idata == data.end()); + CHECK(inext == iafter); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_erase_range) + { + DataNDC data(initial_data.begin(), initial_data.end()); + + DataNDC::iterator idata = data.find(K5); + DataNDC::iterator idata_end = data.find(K8); + + idata = data.erase(idata, idata_end); // Erase K5, K6, K7 + CHECK(idata == data.find(K8)); + + idata = data.find(K0); + CHECK(idata != data.end()); + + idata = data.find(K1); + CHECK(idata != data.end()); + + idata = data.find(K2); + CHECK(idata != data.end()); + + idata = data.find(K3); + CHECK(idata != data.end()); + + idata = data.find(K4); + CHECK(idata != data.end()); + + idata = data.find(K5); + CHECK(idata == data.end()); + + idata = data.find(K6); + CHECK(idata == data.end()); + + idata = data.find(K7); + CHECK(idata == data.end()); + + idata = data.find(K8); + CHECK(idata != data.end()); + + idata = data.find(K9); + CHECK(idata != data.end()); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_clear) + { + DataNDC data(initial_data.begin(), initial_data.end()); + data.clear(); + + CHECK_EQUAL(data.size(), size_t(0)); + } + + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_count_key) + { + DataNDC data(initial_data.begin(), initial_data.end()); + + size_t count = data.count(K5); + CHECK_EQUAL(1, count); + + count = data.count(K12); + CHECK_EQUAL(0, count); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_equal) + { + const DataNDC initial1(initial_data.begin(), initial_data.end()); + const DataNDC initial2(initial_data.begin(), initial_data.end()); + + CHECK(initial1 == initial2); + + const DataNDC different(different_data.begin(), different_data.end()); + + CHECK(!(initial1 == different)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_not_equal) + { + const DataNDC initial1(initial_data.begin(), initial_data.end()); + const DataNDC initial2(initial_data.begin(), initial_data.end()); + + CHECK(!(initial1 != initial2)); + + const DataNDC different(different_data.begin(), different_data.end()); + + CHECK(initial1 != different); + } + }; +} diff --git a/unordered_map.h b/unordered_map.h new file mode 100644 index 00000000..9dc5f283 --- /dev/null +++ b/unordered_map.h @@ -0,0 +1,119 @@ +///\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_UNORDERED_MAP__ +#define __ETL_UNORDERED_MAP__ + +#include +#include +#include + +#include "iunordered_map.h" +#include "container.h" +#include "pool.h" +#include "vector.h" +#include "basic_intrusive_forward_list.h" +#include "hash.h" + +//***************************************************************************** +///\defgroup unordered_map unordered_map +/// A unordered_map with the capacity defined at compile time. +///\ingroup containers +//***************************************************************************** + +namespace etl +{ + //************************************************************************* + /// A templated unordered_map implementation that uses a fixed size buffer. + //************************************************************************* + template , typename TKeyEqual = std::equal_to > + class unordered_map : public iunordered_map + { + public: + + static const size_t MAX_SIZE = MAX_SIZE_; + + //************************************************************************* + /// Default constructor. + //************************************************************************* + unordered_map() + : iunordered_map(node_pool, buckets) + { + iunordered_map::initialise(); + } + + //************************************************************************* + /// Copy constructor. + //************************************************************************* + unordered_map(const unordered_map& other) + : iunordered_map(node_pool, buckets) + { + iunordered_map::assign(other.cbegin(), other.cend()); + } + + //************************************************************************* + /// Constructor, from an iterator range. + ///\tparam TIterator The iterator type. + ///\param first The iterator to the first element. + ///\param last The iterator to the last element + 1. + //************************************************************************* + template + unordered_map(TIterator first, TIterator last) + : iunordered_map(node_pool, buckets) + { + iunordered_map::assign(first, last); + } + + //************************************************************************* + /// Assignment operator. + //************************************************************************* + unordered_map& operator = (const unordered_map& rhs) + { + // Skip if doing self assignment + if (this != &rhs) + { + iunordered_map::assign(rhs.cbegin(), rhs.cend()); + } + + return *this; + } + + private: + + /// The pool of nodes used for the unordered_map. + etl::pool::node_t, MAX_SIZE> node_pool; + + /// The buckets of node lists. + etl::vector buckets; + }; + +} + +#endif From 6d3b317ebc814ba13a44ac1c93377c538e08a3e3 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 14 Jan 2016 18:07:30 +0000 Subject: [PATCH 34/43] Removed commented out code. Added self assignement guard. --- bitset.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bitset.h b/bitset.h index d873fcf3..3f5d41b3 100644 --- a/bitset.h +++ b/bitset.h @@ -130,9 +130,6 @@ namespace etl return *this; } -//#define NDEBUG - - //************************************************************************* /// Set from a string. //************************************************************************* @@ -185,7 +182,11 @@ namespace etl //************************************************************************* bitset& operator =(const bitset& other) { - etl::copy_n(other.data, ARRAY_SIZE, data); + if (this != &other) + { + etl::copy_n(other.data, ARRAY_SIZE, data); + } + return *this; } From eabc44a9dbc25b4b5160d07328e44d2123214396 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 14 Jan 2016 18:19:07 +0000 Subject: [PATCH 35/43] Changed to assign() for initialisation. --- flat_map.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/flat_map.h b/flat_map.h index 1dae5d36..f323a367 100644 --- a/flat_map.h +++ b/flat_map.h @@ -90,7 +90,7 @@ namespace etl flat_map(TIterator first, TIterator last) : iflat_map(buffer) { - iflat_map::insert(first, last); + iflat_map::assign(first, last); } //************************************************************************* @@ -100,8 +100,7 @@ namespace etl { if (&rhs != this) { - iflat_map::clear(); - iflat_map::insert(rhs.cbegin(), rhs.cend()); + iflat_map::assign(rhs.cbegin(), rhs.cend()); } return *this; From 6b77d73c1eb47d07bcf6ff641440c80dc588a1b1 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 14 Jan 2016 18:19:27 +0000 Subject: [PATCH 36/43] Changed to assign() for initialisation. --- flat_multimap.h | 5 ++--- flat_multiset.h | 5 ++--- flat_set.h | 5 ++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/flat_multimap.h b/flat_multimap.h index 561ab7e5..b0d3722b 100644 --- a/flat_multimap.h +++ b/flat_multimap.h @@ -90,7 +90,7 @@ namespace etl flat_multimap(TIterator first, TIterator last) : iflat_multimap(buffer) { - iflat_multimap::insert(first, last); + iflat_multimap::assign(first, last); } //************************************************************************* @@ -100,8 +100,7 @@ namespace etl { if (&rhs != this) { - iflat_multimap::clear(); - iflat_multimap::insert(rhs.cbegin(), rhs.cend()); + iflat_multimap::assign(rhs.cbegin(), rhs.cend()); } return *this; diff --git a/flat_multiset.h b/flat_multiset.h index fda59a51..3f5c47f9 100644 --- a/flat_multiset.h +++ b/flat_multiset.h @@ -89,7 +89,7 @@ namespace etl flat_multiset(TIterator first, TIterator last) : iflat_multiset(buffer) { - iflat_multiset::insert(first, last); + iflat_multiset::assign(first, last); } //************************************************************************* @@ -99,8 +99,7 @@ namespace etl { if (&rhs != this) { - iflat_multiset::clear(); - iflat_multiset::insert(rhs.cbegin(), rhs.cend()); + iflat_multiset::assign(rhs.cbegin(), rhs.cend()); } return *this; diff --git a/flat_set.h b/flat_set.h index e6c347ba..07ce888a 100644 --- a/flat_set.h +++ b/flat_set.h @@ -89,7 +89,7 @@ namespace etl flat_set(TIterator first, TIterator last) : iflat_set(buffer) { - iflat_set::insert(first, last); + iflat_set::assign(first, last); } //************************************************************************* @@ -99,8 +99,7 @@ namespace etl { if (&rhs != this) { - iflat_set::clear(); - iflat_set::insert(rhs.cbegin(), rhs.cend()); + iflat_set::assign(rhs.cbegin(), rhs.cend()); } return *this; From 34d31c9e3e5dc398e776386174535c08d01eab4f Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 14 Jan 2016 18:29:03 +0000 Subject: [PATCH 37/43] Added self assignement guard. --- list.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/list.h b/list.h index b61e0f74..d192ab6d 100644 --- a/list.h +++ b/list.h @@ -98,7 +98,10 @@ namespace etl list(const list& other) : ilist(node_pool, MAX_SIZE) { - ilist::assign(other.cbegin(), other.cend()); + if (this != &other) + { + ilist::assign(other.cbegin(), other.cend()); + } } //************************************************************************* From 925f84761ce8e63a5a55c8e6a915177bdfb9eb1d Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 14 Jan 2016 18:30:02 +0000 Subject: [PATCH 38/43] Disabled copy constructor and assignment operator. --- pool.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pool.h b/pool.h index 9b5f9d90..eb98e2ec 100644 --- a/pool.h +++ b/pool.h @@ -80,6 +80,10 @@ namespace etl ///< The set of flags that indicate which items are free in the pool. bitset in_use; + + // Should not be copied. + pool(const pool&); + pool& operator =(const pool&); }; } From 571c0f761c47f86c0dada7c7ad72e1ba1dc5b602 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 14 Jan 2016 18:30:24 +0000 Subject: [PATCH 39/43] Added self assignement guard. --- optional.h | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/optional.h b/optional.h index 2237426e..3fb1c47c 100644 --- a/optional.h +++ b/optional.h @@ -171,21 +171,24 @@ namespace etl //*************************************************************************** optional& operator =(const optional& other) { - if (valid && !bool(other)) + if (this != &other) { - storage.template get_reference().~T(); - valid = false; - } - else if (bool(other)) - { - if (valid) + if (valid && !bool(other)) { - storage.template get_reference() = other.value(); + storage.template get_reference().~T(); + valid = false; } - else + else if (bool(other)) { - new (storage.template get_address()) T(other.value()); - valid = true; + if (valid) + { + storage.template get_reference() = other.value(); + } + else + { + new (storage.template get_address()) T(other.value()); + valid = true; + } } } From ceef10dc93a858711177ca66a1798bfae6c24290 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 14 Jan 2016 18:31:43 +0000 Subject: [PATCH 40/43] Disabled copy constructor. Added interface assignment operator. --- ibitset.h | 17 +++++++ ideque.h | 26 ++++++---- iflat_map.h | 16 ++++++ iflat_multimap.h | 16 ++++++ iflat_multiset.h | 16 ++++++ iflat_set.h | 16 ++++++ iforward_list.h | 26 ++++++---- ilist.h | 16 ++++++ imap.h | 17 +++++++ imultimap.h | 17 +++++++ imultiset.h | 17 +++++++ ipool.h | 6 +++ ipriority_queue.h | 3 ++ iqueue.h | 16 ++++++ iset.h | 8 ++- istack.h | 16 ++++++ ivector.h | 16 ++++++ test/test_bitset.cpp | 17 +++++++ test/test_deque.cpp | 94 +++++++++++++++++++++--------------- test/test_flat_map.cpp | 19 ++++++++ test/test_flat_multimap.cpp | 19 ++++++++ test/test_flat_multiset.cpp | 23 ++++++++- test/test_flat_set.cpp | 23 ++++++++- test/test_forward_list.cpp | 17 +++++++ test/test_list.cpp | 20 ++++++++ test/test_map.cpp | 37 +++++++++++++- test/test_multimap.cpp | 35 ++++++++++++++ test/test_multiset.cpp | 43 +++++++++++++++-- test/test_priority_queue.cpp | 78 +++++++++++++++++++----------- test/test_queue.cpp | 27 +++++++++++ test/test_set.cpp | 34 +++++++++++++ test/test_stack.cpp | 28 +++++++++++ test/test_variant.cpp | 23 +++++++++ test/test_vector.cpp | 23 ++++++++- vector.h | 1 - 35 files changed, 727 insertions(+), 99 deletions(-) diff --git a/ibitset.h b/ibitset.h index 9994e716..7d9112a6 100644 --- a/ibitset.h +++ b/ibitset.h @@ -37,6 +37,7 @@ SOFTWARE. #include "exception.h" #include "integral_limits.h" #include "binary.h" +#include "algorithm.h" #if WIN32 #undef min @@ -595,6 +596,19 @@ namespace etl return *this; } + //************************************************************************* + /// operator = + //************************************************************************* + ibitset& operator =(const ibitset& other) + { + if (this != &other) + { + etl::copy_n(other.pdata, SIZE, pdata); + } + + return *this; + } + //************************************************************************* /// swap //************************************************************************* @@ -679,6 +693,9 @@ namespace etl private: + // Disable copy construction. + ibitset(const ibitset&); + const size_t NBITS; const size_t SIZE; element_t* pdata; diff --git a/ideque.h b/ideque.h index aa769937..aafd32b9 100644 --- a/ideque.h +++ b/ideque.h @@ -459,16 +459,6 @@ namespace etl typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; - //************************************************************************* - /// Assignment operator. - //************************************************************************* - ideque& operator =(const ideque& other) - { - assign(other.begin(), other.end()); - - return *this; - } - //************************************************************************* /// Assigns a range to the deque. //************************************************************************* @@ -1215,6 +1205,19 @@ namespace etl return distance(lhs.base(), rhs.base()); } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + ideque& operator =(const ideque& rhs) + { + if (&rhs != this) + { + assign(rhs.begin(), rhs.end()); + } + + return *this; + } + protected: //************************************************************************* @@ -1373,6 +1376,9 @@ namespace etl return index - reference_index; } } + + // Disable copy construction. + ideque(const ideque&); }; } diff --git a/iflat_map.h b/iflat_map.h index bb21571c..34d3e790 100644 --- a/iflat_map.h +++ b/iflat_map.h @@ -492,6 +492,19 @@ namespace etl return std::make_pair(i_lower, std::upper_bound(i_lower, cend(), key, compare())); } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + iflat_map& operator = (const iflat_map& rhs) + { + if (&rhs != this) + { + assign(rhs.cbegin(), rhs.cend()); + } + + return *this; + } + protected: //********************************************************************* @@ -505,6 +518,9 @@ namespace etl private: + // Disable copy construction. + iflat_map(const iflat_map&); + buffer_t& buffer; }; diff --git a/iflat_multimap.h b/iflat_multimap.h index 7c28be2f..a6f4e08a 100644 --- a/iflat_multimap.h +++ b/iflat_multimap.h @@ -439,6 +439,19 @@ namespace etl return std::make_pair(i_lower, std::upper_bound(i_lower, cend(), key, compare())); } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + iflat_multimap& operator = (const iflat_multimap& rhs) + { + if (&rhs != this) + { + assign(rhs.cbegin(), rhs.cend()); + } + + return *this; + } + protected: //********************************************************************* @@ -452,6 +465,9 @@ namespace etl private: + // Disable copy construction. + iflat_multimap(const iflat_multimap&); + buffer_t& buffer; }; diff --git a/iflat_multiset.h b/iflat_multiset.h index 17776e06..8e178c53 100644 --- a/iflat_multiset.h +++ b/iflat_multiset.h @@ -412,6 +412,19 @@ namespace etl return std::equal_range(cbegin(), cend(), key, TKeyCompare()); } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + iflat_multiset& operator = (const iflat_multiset& rhs) + { + if (&rhs != this) + { + assign(rhs.cbegin(), rhs.cend()); + } + + return *this; + } + protected: //********************************************************************* @@ -425,6 +438,9 @@ namespace etl private: + // Disable copy construction. + iflat_multiset(const iflat_multiset&); + buffer_t& buffer; }; diff --git a/iflat_set.h b/iflat_set.h index d31137d3..81f70dbe 100644 --- a/iflat_set.h +++ b/iflat_set.h @@ -417,6 +417,19 @@ namespace etl return std::upper_bound(cbegin(), cend(), key, TKeyCompare()); } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + iflat_set& operator = (const iflat_set& rhs) + { + if (&rhs != this) + { + assign(rhs.cbegin(), rhs.cend()); + } + + return *this; + } + protected: //********************************************************************* @@ -430,6 +443,9 @@ namespace etl private: + // Disable copy construction. + iflat_set(const iflat_set&); + buffer_t& buffer; }; diff --git a/iforward_list.h b/iforward_list.h index f1007dc4..8915bdad 100644 --- a/iforward_list.h +++ b/iforward_list.h @@ -320,16 +320,6 @@ namespace etl return const_iterator(); } - //************************************************************************* - /// Assignment operator. - //************************************************************************* - iforward_list& operator = (const iforward_list& rhs) - { - assign(rhs.cbegin(), rhs.cend()); - - return *this; - } - //************************************************************************* /// Clears the forward_list. //************************************************************************* @@ -795,6 +785,19 @@ namespace etl } } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + iforward_list& operator = (const iforward_list& rhs) + { + if (&rhs != this) + { + assign(rhs.cbegin(), rhs.cend()); + } + + return *this; + } + protected: //************************************************************************* @@ -893,6 +896,9 @@ namespace etl { p_node_pool->release(node); } + + // Disable copy construction. + iforward_list(const iforward_list&); }; } diff --git a/ilist.h b/ilist.h index bf34a056..f24783f5 100644 --- a/ilist.h +++ b/ilist.h @@ -884,6 +884,19 @@ namespace etl } } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + ilist& operator = (const ilist& rhs) + { + if (&rhs != this) + { + assign(rhs.cbegin(), rhs.cend()); + } + + return *this; + } + protected: //************************************************************************* @@ -941,6 +954,9 @@ namespace etl { p_node_pool->release(&node); } + + // Disable copy construction. + ilist(const ilist&); }; } diff --git a/imap.h b/imap.h index 13e53e74..cd6dd2e9 100644 --- a/imap.h +++ b/imap.h @@ -810,6 +810,20 @@ namespace etl return const_iterator(*this, find_upper_node(root_node, key)); } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + imap& operator = (const imap& rhs) + { + // Skip if doing self assignment + if (this != &rhs) + { + assign(rhs.cbegin(), rhs.cend()); + } + + return *this; + } + protected: //************************************************************************* @@ -1580,6 +1594,9 @@ namespace etl // Return node found (might be nullptr) return found; } + + // Disable copy construction. + imap(const imap&); }; } diff --git a/imultimap.h b/imultimap.h index 81b53f7f..9ace711c 100644 --- a/imultimap.h +++ b/imultimap.h @@ -757,6 +757,20 @@ namespace etl return const_iterator(*this, find_upper_node(root_node, key)); } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + imultimap& operator = (const imultimap& rhs) + { + // Skip if doing self assignment + if (this != &rhs) + { + assign(rhs.cbegin(), rhs.cend()); + } + + return *this; + } + protected: //************************************************************************* @@ -1318,6 +1332,9 @@ namespace etl destroy_data_node(data_node); } // if(found) } + + // Disable copy construction. + imultimap(const imultimap&); }; } diff --git a/imultiset.h b/imultiset.h index 6b7ce644..b1e126b5 100644 --- a/imultiset.h +++ b/imultiset.h @@ -738,6 +738,20 @@ namespace etl return const_iterator(*this, find_upper_node(root_node, key)); } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + imultiset& operator = (const imultiset& rhs) + { + // Skip if doing self assignment + if (this != &rhs) + { + assign(rhs.cbegin(), rhs.cend()); + } + + return *this; + } + protected: //************************************************************************* @@ -1299,6 +1313,9 @@ namespace etl destroy_data_node(data_node); } // if(found) } + + // Disable copy construction. + imultiset(const imultiset&); }; } diff --git a/ipool.h b/ipool.h index d797105b..fdd8620f 100644 --- a/ipool.h +++ b/ipool.h @@ -501,6 +501,12 @@ namespace etl { } + private: + + // Disable copy construction and assignment. + ipool(const ipool&); + ipool& operator =(const ipool&); + T* p_buffer; ibitset& in_use_flags; }; diff --git a/ipriority_queue.h b/ipriority_queue.h index cc829837..0cd40578 100644 --- a/ipriority_queue.h +++ b/ipriority_queue.h @@ -265,6 +265,9 @@ namespace etl private: + // Disable copy construction. + ipriority_queue(const ipriority_queue&); + /// The container specified at instantiation of the priority_queue TContainer container; }; diff --git a/iqueue.h b/iqueue.h index cfdaa141..8a59ab1d 100644 --- a/iqueue.h +++ b/iqueue.h @@ -174,6 +174,19 @@ namespace etl --current_size; } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + iqueue& operator = (const iqueue& rhs) + { + if (&rhs != this) + { + clone(rhs); + } + + return *this; + } + protected: //************************************************************************* @@ -201,6 +214,9 @@ namespace etl private: + // Disable copy construction. + iqueue(const iqueue&); + T* p_buffer; ///< The internal buffer. }; } diff --git a/iset.h b/iset.h index cb7c926b..17b989d6 100644 --- a/iset.h +++ b/iset.h @@ -386,7 +386,10 @@ namespace etl //************************************************************************* iset& operator = (const iset& rhs) { - assign(rhs.cbegin(), rhs.cend()); + if (this != &rhs) + { + assign(rhs.cbegin(), rhs.cend()); + } return *this; } @@ -1522,6 +1525,9 @@ namespace etl // Return node found (might be nullptr) return found; } + + // Disable copy construction. + iset(const iset&); }; } diff --git a/istack.h b/istack.h index 6a9386db..f3d0a430 100644 --- a/istack.h +++ b/istack.h @@ -147,6 +147,19 @@ namespace etl --current_size; } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + istack& operator = (const istack& rhs) + { + if (&rhs != this) + { + clone(rhs); + } + + return *this; + } + protected: //************************************************************************* @@ -173,6 +186,9 @@ namespace etl private: + // Disable copy construction. + istack(const istack&); + T* p_buffer; ///< The internal buffer. }; } diff --git a/ivector.h b/ivector.h index d2cd81ce..68a9adbf 100644 --- a/ivector.h +++ b/ivector.h @@ -610,6 +610,19 @@ namespace etl return first; } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + ivector& operator = (const ivector& rhs) + { + if (&rhs != this) + { + assign(rhs.cbegin(), rhs.cend()); + } + + return *this; + } + protected: //********************************************************************* @@ -666,6 +679,9 @@ namespace etl p_buffer[--current_size].~T(); } + // Disable copy construction. + ivector(const ivector&); + T* p_buffer; }; diff --git a/test/test_bitset.cpp b/test/test_bitset.cpp index c09635b4..b21cd6fd 100644 --- a/test/test_bitset.cpp +++ b/test/test_bitset.cpp @@ -453,6 +453,23 @@ namespace } } + //************************************************************************* + TEST(test_assignment_operator_iterface) + { + etl::bitset<60> data1(0xFFFFFFFFFFFFFFF); + etl::bitset<60> data2; + + etl::ibitset& idata1 = data1; + etl::ibitset& idata2 = data2; + + idata2 = idata1; + + for (size_t i = 0; i < data2.size(); ++i) + { + CHECK_EQUAL(data1.test(i), data2.test(i)); + } + } + //************************************************************************* TEST(test_equality_operator) { diff --git a/test/test_deque.cpp b/test/test_deque.cpp index 52044f05..81dbdb02 100644 --- a/test/test_deque.cpp +++ b/test/test_deque.cpp @@ -39,49 +39,50 @@ SOFTWARE. #include #include -const size_t SIZE = 14; - -typedef TestDataDC DC; -typedef TestDataNDC NDC; - -typedef etl::deque DataDC; -typedef etl::deque DataNDC; - -typedef std::deque Compare_Data; -typedef std::deque Compare_DataDC; - -NDC N0 = NDC("0"); -NDC N1 = NDC("1"); -NDC N2 = NDC("2"); -NDC N3 = NDC("3"); -NDC N4 = NDC("4"); -NDC N5 = NDC("5"); -NDC N6 = NDC("6"); -NDC N7 = NDC("7"); -NDC N8 = NDC("8"); -NDC N9 = NDC("9"); -NDC N10 = NDC("10"); -NDC N11 = NDC("11"); -NDC N12 = NDC("12"); -NDC N13 = NDC("13"); -NDC N14 = NDC("14"); -NDC N15 = NDC("15"); -NDC N16 = NDC("16"); -NDC N17 = NDC("17"); -NDC N999 = NDC("999"); - -std::vector blank_data = { N999, N999, N999, N999, N999, N999, N999, N999, N999, N999, N999, N999, N999, N999 }; -std::vector initial_data = { N0, N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, N11, N12, N13 }; -std::vector initial_data_excess = { N0, N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, N11, N12, N13, N14 }; -std::vector initial_data_under = { N0, N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, N11 }; -std::vector initial_data_small = { N0, N1, N2, N3, N4, N5, N6, N7, N8, N9 }; -std::vector insert_data = { N10, N11, N12, N13, N14 }; -std::vector initial_data_dc = { DC("0"), DC("1"), DC("2"), DC("3"), DC("4"), DC("5"), DC("6"), DC("7"), DC("8"), DC("9"), DC("10"), DC("11"), DC("12"), DC("13") }; - namespace { SUITE(test_deque) { + const size_t SIZE = 14; + + typedef TestDataDC DC; + typedef TestDataNDC NDC; + + typedef etl::deque DataDC; + typedef etl::deque DataNDC; + typedef etl::ideque IDataNDC; + + typedef std::deque Compare_Data; + typedef std::deque Compare_DataDC; + + NDC N0 = NDC("0"); + NDC N1 = NDC("1"); + NDC N2 = NDC("2"); + NDC N3 = NDC("3"); + NDC N4 = NDC("4"); + NDC N5 = NDC("5"); + NDC N6 = NDC("6"); + NDC N7 = NDC("7"); + NDC N8 = NDC("8"); + NDC N9 = NDC("9"); + NDC N10 = NDC("10"); + NDC N11 = NDC("11"); + NDC N12 = NDC("12"); + NDC N13 = NDC("13"); + NDC N14 = NDC("14"); + NDC N15 = NDC("15"); + NDC N16 = NDC("16"); + NDC N17 = NDC("17"); + NDC N999 = NDC("999"); + + std::vector blank_data = { N999, N999, N999, N999, N999, N999, N999, N999, N999, N999, N999, N999, N999, N999 }; + std::vector initial_data = { N0, N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, N11, N12, N13 }; + std::vector initial_data_excess = { N0, N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, N11, N12, N13, N14 }; + std::vector initial_data_under = { N0, N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, N11 }; + std::vector initial_data_small = { N0, N1, N2, N3, N4, N5, N6, N7, N8, N9 }; + std::vector insert_data = { N10, N11, N12, N13, N14 }; + std::vector initial_data_dc = { DC("0"), DC("1"), DC("2"), DC("3"), DC("4"), DC("5"), DC("6"), DC("7"), DC("8"), DC("9"), DC("10"), DC("11"), DC("12"), DC("13") }; + //************************************************************************* TEST(test_constructor) { @@ -144,6 +145,21 @@ namespace CHECK(std::equal(deque1.begin(), deque1.end(), deque2.begin())); } + //************************************************************************* + TEST(test_assignment_interface) + { + DataNDC deque1(initial_data.begin(), initial_data.end()); + DataNDC deque2; + + IDataNDC& ideque1 = deque1; + IDataNDC& ideque2 = deque2; + + ideque2 = ideque1; + + CHECK_EQUAL(deque1.size(), deque2.size()); + CHECK(std::equal(deque1.begin(), deque1.end(), deque2.begin())); + } + //************************************************************************* TEST(test_self_assignment) { diff --git a/test/test_flat_map.cpp b/test/test_flat_map.cpp index 711a9566..37dc8dbc 100644 --- a/test/test_flat_map.cpp +++ b/test/test_flat_map.cpp @@ -72,6 +72,7 @@ namespace typedef etl::flat_map DataDC; typedef etl::flat_map DataNDC; + typedef etl::iflat_map IDataNDC; typedef std::map Compare_DataDC; typedef std::map Compare_DataNDC; @@ -186,6 +187,24 @@ namespace CHECK(isEqual); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_interface) + { + DataNDC data1(initial_data.begin(), initial_data.end()); + DataNDC data2; + + IDataNDC& idata1 = data1; + IDataNDC& idata2 = data2; + + idata2 = idata1; + + bool isEqual = Check_Equal(data1.begin(), + data1.end(), + data2.begin()); + + CHECK(isEqual); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_self_assignment) { diff --git a/test/test_flat_multimap.cpp b/test/test_flat_multimap.cpp index bc082030..51e8cc92 100644 --- a/test/test_flat_multimap.cpp +++ b/test/test_flat_multimap.cpp @@ -54,6 +54,7 @@ namespace typedef etl::flat_multimap DataDC; typedef etl::flat_multimap DataNDC; + typedef etl::iflat_multimap IDataNDC; typedef std::multimap Compare_DataDC; typedef std::multimap Compare_DataNDC; @@ -176,6 +177,24 @@ namespace CHECK(isEqual); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_interface) + { + DataNDC data1(initial_data.begin(), initial_data.end()); + DataNDC data2; + + IDataNDC& idata1 = data1; + IDataNDC& idata2 = data2; + + idata2 = idata1; + + bool isEqual = Check_Equal(data1.begin(), + data1.end(), + data2.begin()); + + CHECK(isEqual); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_self_assignment) { diff --git a/test/test_flat_multiset.cpp b/test/test_flat_multiset.cpp index f3136e46..2cb4e9ad 100644 --- a/test/test_flat_multiset.cpp +++ b/test/test_flat_multiset.cpp @@ -49,8 +49,9 @@ namespace typedef TestDataDC DC; typedef TestDataNDC NDC; - typedef etl::flat_multiset DataDC; - typedef etl::flat_multiset DataNDC; + typedef etl::flat_multiset DataDC; + typedef etl::flat_multiset DataNDC; + typedef etl::iflat_multiset IDataNDC; typedef std::multiset Compare_DataDC; typedef std::multiset Compare_DataNDC; @@ -150,6 +151,24 @@ namespace CHECK(isEqual); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_interface) + { + DataNDC data1(initial_data.begin(), initial_data.end()); + DataNDC data2; + + IDataNDC& idata1 = data1; + IDataNDC& idata2 = data2; + + idata2 = idata1; + + bool isEqual = std::equal(data1.begin(), + data1.end(), + data2.begin()); + + CHECK(isEqual); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_self_assignment) { diff --git a/test/test_flat_set.cpp b/test/test_flat_set.cpp index dc0084ee..37602f5f 100644 --- a/test/test_flat_set.cpp +++ b/test/test_flat_set.cpp @@ -49,8 +49,9 @@ namespace typedef TestDataDC DC; typedef TestDataNDC NDC; - typedef etl::flat_set DataDC; - typedef etl::flat_set DataNDC; + typedef etl::flat_set DataDC; + typedef etl::flat_set DataNDC; + typedef etl::iflat_set IDataNDC; typedef std::set Compare_DataDC; typedef std::set Compare_DataNDC; @@ -143,6 +144,24 @@ namespace CHECK(isEqual); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_interface) + { + DataNDC data1(initial_data.begin(), initial_data.end()); + DataNDC data2; + + IDataNDC& idata1 = data1; + IDataNDC& idata2 = data2; + + idata2 = idata1; + + bool isEqual = std::equal(data1.begin(), + data1.end(), + data2.begin()); + + CHECK(isEqual); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_self_assignment) { diff --git a/test/test_forward_list.cpp b/test/test_forward_list.cpp index 51d274ea..1f54828c 100644 --- a/test/test_forward_list.cpp +++ b/test/test_forward_list.cpp @@ -50,6 +50,7 @@ namespace typedef etl::forward_list DataDC; typedef etl::forward_list DataNDC; + typedef etl::iforward_list IDataNDC; typedef std::forward_list CompareDataNDC; typedef std::vector InitialDataNDC; @@ -499,6 +500,22 @@ namespace CHECK(are_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_interface) + { + DataNDC data1(sorted_data.begin(), sorted_data.end()); + DataNDC data2; + + IDataNDC& idata1 = data1; + IDataNDC& idata2 = data2; + + idata2 = idata1; + + bool isEqual = std::equal(data1.begin(), data1.end(), data2.begin()); + + CHECK(isEqual); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_self_assignment) { diff --git a/test/test_list.cpp b/test/test_list.cpp index f795b61b..b1614386 100644 --- a/test/test_list.cpp +++ b/test/test_list.cpp @@ -49,6 +49,7 @@ namespace typedef etl::list DataDC; typedef etl::list DataNDC; + typedef etl::ilist IDataNDC; typedef std::list CompareData; typedef std::vector InitialData; @@ -700,6 +701,25 @@ namespace CHECK(are_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_interface) + { + CompareData compare_data(sorted_data.begin(), sorted_data.end()); + DataNDC data1(sorted_data.begin(), sorted_data.end()); + DataNDC data2; + + IDataNDC& idata1 = data1; + IDataNDC& idata2 = data2; + + idata2 = idata1; + + CHECK_EQUAL(data1.size(), data2.size()); + + are_equal = std::equal(data1.begin(), data1.end(), data2.begin()); + + CHECK(are_equal); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_self_assignment) { diff --git a/test/test_map.cpp b/test/test_map.cpp index 4d5b67a9..c18a2351 100644 --- a/test/test_map.cpp +++ b/test/test_map.cpp @@ -43,9 +43,11 @@ static const size_t SIZE = 10; #define TEST_GREATER_THAN #ifdef TEST_GREATER_THAN typedef etl::map > Data; +typedef etl::imap > IData; typedef std::map > Compare_Data; #else typedef etl::map > Data; +typedef etl::imap > IData; typedef std::map > Compare_Data; #endif @@ -111,7 +113,7 @@ namespace //************************************************************************* struct SetupFixture { - // Maps of predefined data from which to constuct maps used in each test + // Maps of predefined data from which to construct maps used in each test std::map initial_data; std::map excess_data; std::map different_data; @@ -207,6 +209,39 @@ namespace CHECK(isEqual); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_interface) + { + Data data1(initial_data.begin(), initial_data.end()); + Data data2; + + IData& idata1 = data1; + IData& idata2 = data2; + + idata2 = idata1; + + bool isEqual = std::equal(data1.begin(), + data1.end(), + data2.begin()); + + CHECK(isEqual); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_self_assignment) + { + Data data(initial_data.begin(), initial_data.end()); + Data other_data(data); + + other_data = other_data; + + bool isEqual = std::equal(data.begin(), + data.end(), + other_data.begin()); + + CHECK(isEqual); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { diff --git a/test/test_multimap.cpp b/test/test_multimap.cpp index 1f8087bf..efc26d4f 100644 --- a/test/test_multimap.cpp +++ b/test/test_multimap.cpp @@ -42,9 +42,11 @@ static const size_t SIZE = 10; #define TEST_GREATER_THAN #ifdef TEST_GREATER_THAN typedef etl::multimap > Data; +typedef etl::imultimap > IData; typedef std::multimap > Compare_Data; #else typedef etl::multimap > Data; +typedef etl::imultimap > IData; typedef std::multimap > Compare_Data; #endif @@ -207,6 +209,39 @@ namespace CHECK(isEqual); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_interface) + { + Data data1(initial_data.begin(), initial_data.end()); + Data data2; + + IData& idata1 = data1; + IData& idata2 = data2; + + idata2 = idata1; + + bool isEqual = std::equal(data1.begin(), + data1.end(), + data2.begin()); + + CHECK(isEqual); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_self_assignment) + { + Data data(initial_data.begin(), initial_data.end()); + Data other_data(data); + + other_data = other_data; + + bool isEqual = std::equal(data.begin(), + data.end(), + other_data.begin()); + + CHECK(isEqual); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { diff --git a/test/test_multiset.cpp b/test/test_multiset.cpp index 9c83ab16..64483879 100644 --- a/test/test_multiset.cpp +++ b/test/test_multiset.cpp @@ -41,11 +41,13 @@ static const size_t SIZE = 10; #define TEST_GREATER_THAN #ifdef TEST_GREATER_THAN -typedef etl::multiset > Data; -typedef std::multiset > Compare_Data; +typedef etl::multiset > Data; +typedef etl::imultiset > IData; +typedef std::multiset > Compare_Data; #else -typedef etl::multiset > Data; -typedef std::multiset > Compare_Data; +typedef etl::multiset > Data; +typedef etl::multiset > IData; +typedef std::multiset > Compare_Data; #endif typedef Data::iterator Data_iterator; @@ -199,6 +201,39 @@ namespace CHECK(isEqual); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_interface) + { + Data data1(initial_data.begin(), initial_data.end()); + Data data2; + + IData& idata1 = data1; + IData& idata2 = data2; + + idata2 = idata1; + + bool isEqual = std::equal(data1.begin(), + data1.end(), + data2.begin()); + + CHECK(isEqual); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_self_assignment) + { + Data data(initial_data.begin(), initial_data.end()); + Data other_data(data); + + other_data = other_data; + + bool isEqual = std::equal(data.begin(), + data.end(), + other_data.begin()); + + CHECK(isEqual); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { diff --git a/test/test_priority_queue.cpp b/test/test_priority_queue.cpp index e30b8ff0..216663f1 100644 --- a/test/test_priority_queue.cpp +++ b/test/test_priority_queue.cpp @@ -324,6 +324,57 @@ namespace } } + //************************************************************************* + //TEST(test_assignment_interface) + //{ + // etl::priority_queue priority_queue1; + // + // priority_queue1.push(1); + // priority_queue1.push(4); + // priority_queue1.push(3); + // priority_queue1.push(2); + + // etl::priority_queue priority_queue2; + + // etl::ipriority_queue ipriority_queue1 = priority_queue1; + // etl::ipriority_queue ipriority_queue2 = priority_queue2; + + // ipriority_queue2 = ipriority_queue1; + + // CHECK(priority_queue1.size() == priority_queue2.size()); + + // while (!priority_queue1.empty()) + // { + // CHECK_EQUAL(priority_queue1.top(), priority_queue2.top()); + // priority_queue1.pop(); + // priority_queue2.pop(); + // } + //} + + //************************************************************************* + TEST(test_self_assignment) + { + etl::priority_queue priority_queue1; + + priority_queue1.push(1); + priority_queue1.push(4); + priority_queue1.push(3); + priority_queue1.push(2); + + etl::priority_queue priority_queue2 = priority_queue1; + + priority_queue1 = priority_queue1; + + CHECK(priority_queue1.size() == priority_queue2.size()); + + while (!priority_queue1.empty()) + { + CHECK_EQUAL(priority_queue1.top(), priority_queue2.top()); + priority_queue1.pop(); + priority_queue2.pop(); + } + } + //************************************************************************* TEST(test_interface) { @@ -347,32 +398,5 @@ namespace CHECK_EQUAL(compare_priority_queue.size(), ipriority_queue.size()); CHECK_EQUAL(compare_priority_queue.top(), ipriority_queue.top()); } - - //************************************************************************* - TEST(test_self_assignment) - { - etl::priority_queue priority_queue; - - priority_queue.push(2); - priority_queue.push(1); - priority_queue.push(4); - priority_queue.push(3); - - priority_queue = priority_queue; - - CHECK(priority_queue.max_size() == priority_queue.size()); - - CHECK_EQUAL(4, priority_queue.top()); - priority_queue.pop(); - - CHECK_EQUAL(3, priority_queue.top()); - priority_queue.pop(); - - CHECK_EQUAL(2, priority_queue.top()); - priority_queue.pop(); - - CHECK_EQUAL(1, priority_queue.top()); - priority_queue.pop(); - } }; } diff --git a/test/test_queue.cpp b/test/test_queue.cpp index 3b67966a..00bf0a4d 100644 --- a/test/test_queue.cpp +++ b/test/test_queue.cpp @@ -324,6 +324,33 @@ namespace } } + //************************************************************************* + TEST(test_assignment_interface) + { + etl::queue queue1; + + queue1.push(1); + queue1.push(2); + queue1.push(3); + queue1.push(4); + + etl::queue queue2; + + etl::iqueue& iqueue1 = queue1; + etl::iqueue& iqueue2 = queue2; + + iqueue2 = iqueue1; + + CHECK(queue1.size() == queue2.size()); + + while (!queue1.empty()) + { + CHECK_EQUAL(queue1.front(), queue2.front()); + queue1.pop(); + queue2.pop(); + } + } + //************************************************************************* TEST(test_self_assignment) { diff --git a/test/test_set.cpp b/test/test_set.cpp index aa6c1835..6dd2765d 100644 --- a/test/test_set.cpp +++ b/test/test_set.cpp @@ -43,6 +43,7 @@ static const size_t SIZE = 10; #define TEST_GREATER_THAN #ifdef TEST_GREATER_THAN typedef etl::set > Data; +typedef etl::iset > IData; typedef std::set > Compare_Data; #else typedef etl::set > Data; @@ -211,6 +212,39 @@ namespace CHECK(isEqual); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_interface) + { + Data data1(initial_data.begin(), initial_data.end()); + Data data2; + + IData& idata1 = data1; + IData& idata2 = data2; + + idata2 = idata1; + + bool isEqual = Check_Equal(data1.begin(), + data1.end(), + data2.begin()); + + CHECK(isEqual); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_self_assignment) + { + Data data(initial_data.begin(), initial_data.end()); + Data otherData(data); + + data = data; + + bool isEqual = Check_Equal(data.begin(), + data.end(), + otherData.begin()); + + CHECK(isEqual); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { diff --git a/test/test_stack.cpp b/test/test_stack.cpp index d5033c67..337a1869 100644 --- a/test/test_stack.cpp +++ b/test/test_stack.cpp @@ -306,6 +306,34 @@ namespace } } + //************************************************************************* + TEST(test_assignment_interface) + { + etl::stack stack1; + + stack1.push(1); + stack1.push(2); + stack1.push(3); + stack1.push(4); + + etl::stack stack2; + + etl::istack& istack1 = stack1; + etl::istack& istack2 = stack2; + + istack2 = istack1; + + CHECK(istack1.size() == stack2.size()); + + while (!stack1.empty()) + { + CHECK_EQUAL(stack1.top(), stack2.top()); + stack1.pop(); + stack2.pop(); + } + } + + //************************************************************************* TEST(test_self_assignment) { diff --git a/test/test_variant.cpp b/test/test_variant.cpp index bf7d580a..463a47d7 100644 --- a/test/test_variant.cpp +++ b/test/test_variant.cpp @@ -274,6 +274,29 @@ namespace CHECK_EQUAL(std::string("Some Text"), variant.get()); } + //************************************************************************* + TEST(test_assignment) + { + test_variant_1 variant1; + test_variant_1 variant2; + + variant1 = 1; + variant2 = variant1; + + CHECK_EQUAL(variant1.get(), variant2.get()); + } + + //************************************************************************* + TEST(test_self_assignment) + { + test_variant_1 variant; + + variant = 1; + variant = variant; + + CHECK_EQUAL(1, variant.get()); + } + //************************************************************************* TEST(TestGetException) { diff --git a/test/test_vector.cpp b/test/test_vector.cpp index cbe94355..392679fd 100644 --- a/test/test_vector.cpp +++ b/test/test_vector.cpp @@ -40,8 +40,9 @@ namespace { static const size_t SIZE = 10; - typedef etl::vector Data; - typedef std::vector Compare_Data; + typedef etl::vector Data; + typedef etl::ivector IData; + typedef std::vector Compare_Data; Compare_Data initial_data; Compare_Data less_data; @@ -165,6 +166,24 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_iterface) + { + Data data1(initial_data.begin(), initial_data.end()); + Data data2; + + IData& idata1 = data1; + IData& idata2 = data2; + + idata2 = idata1; + + bool is_equal = std::equal(data1.begin(), + data1.end(), + data2.begin()); + + CHECK(is_equal); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_self_assignment) { diff --git a/vector.h b/vector.h index 83ef45c4..46e61d9b 100644 --- a/vector.h +++ b/vector.h @@ -112,7 +112,6 @@ namespace etl vector(const vector& other) : ivector(reinterpret_cast(&buffer), MAX_SIZE) { - ivector::initialise(); ivector::assign(other.begin(), other.end()); } From f733aed04973bb11c39b7927414c9488a730e86f Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 14 Jan 2016 18:32:23 +0000 Subject: [PATCH 41/43] Updated projects files for added and removed project files. --- test/vs2015/etl.vcxproj | 45 +++++++++++++++++++++++++++++++-- test/vs2015/etl.vcxproj.filters | 12 ++++----- 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/test/vs2015/etl.vcxproj b/test/vs2015/etl.vcxproj index e0ccb5e2..40063922 100644 --- a/test/vs2015/etl.vcxproj +++ b/test/vs2015/etl.vcxproj @@ -1,6 +1,10 @@  + + Debug No Unit Tests + Win32 + Debug Win32 @@ -23,6 +27,12 @@ v140 Unicode + + Application + true + v140 + Unicode + Application false @@ -36,6 +46,9 @@ + + + @@ -44,6 +57,10 @@ true true + + true + true + false @@ -66,6 +83,26 @@ $(OutDir)\etl.exe + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_THROW_EXCEPTIONS;PLATFORM_WINDOWS;COMPILER_MICROSOFT;ETL_VERBOSE_ERRORS;ETL_CHECK_PUSH_POP;%(PreprocessorDefinitions) + ../../../unittest-cpp + + + + + Console + true + + + + + + Level3 @@ -126,6 +163,7 @@ + @@ -211,11 +249,9 @@ - - @@ -280,6 +316,7 @@ false false + false @@ -290,6 +327,7 @@ false + false @@ -305,6 +343,7 @@ false + false @@ -314,6 +353,7 @@ false + false @@ -324,6 +364,7 @@ + diff --git a/test/vs2015/etl.vcxproj.filters b/test/vs2015/etl.vcxproj.filters index 371bf09c..6dd59bb2 100644 --- a/test/vs2015/etl.vcxproj.filters +++ b/test/vs2015/etl.vcxproj.filters @@ -450,9 +450,6 @@ ETL\Private - - ETL\Private - ETL\Private @@ -462,15 +459,15 @@ ETL\Private - - ETL\Private - ETL\Private ETL\Containers + + ETL\Utilities + @@ -716,6 +713,9 @@ Source Files + + Source Files + From d6a5e314e6224f182217c5989737673cb4f7bdf3 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 14 Jan 2016 18:33:25 +0000 Subject: [PATCH 42/43] Updates to code:blocks project file. --- test/codeblocks/ETL.cbp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/codeblocks/ETL.cbp b/test/codeblocks/ETL.cbp index 33df9414..3d47bf30 100644 --- a/test/codeblocks/ETL.cbp +++ b/test/codeblocks/ETL.cbp @@ -18,8 +18,8 @@ - + @@ -36,10 +36,11 @@ + - + From 63910abcc8caa9f2aebd131d3edbbf2012be4bab Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 14 Jan 2016 18:33:36 +0000 Subject: [PATCH 43/43] Added self assignement guard. --- deque.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/deque.h b/deque.h index bf7cb736..08db51d5 100644 --- a/deque.h +++ b/deque.h @@ -92,7 +92,10 @@ namespace etl deque(const deque& other) : ideque(reinterpret_cast(&buffer[0]), MAX_SIZE, BUFFER_SIZE) { - ideque::assign(other.begin(), other.end()); + if (this != &other) + { + ideque::assign(other.begin(), other.end()); + } } //*************************************************************************