diff --git a/include/etl/basic_string.h b/include/etl/basic_string.h index 106803c6c..f6741eea2 100644 --- a/include/etl/basic_string.h +++ b/include/etl/basic_string.h @@ -1466,9 +1466,9 @@ namespace etl int compare(const ibasic_string& str) const { return compare(p_buffer, - p_buffer + size(), - str.p_buffer, - str.p_buffer + str.size()); + p_buffer + size(), + str.p_buffer, + str.p_buffer + str.size()); } //************************************************************************* @@ -1482,9 +1482,9 @@ namespace etl length_ = std::min(length_, size() - position); return compare(p_buffer + position, - p_buffer + position + length_, - str.p_buffer, - str.p_buffer + str.size()); + p_buffer + position + length_, + str.p_buffer, + str.p_buffer + str.size()); } //************************************************************************* @@ -1500,9 +1500,9 @@ namespace etl sublength = std::min(sublength, str.size() - subposition); return compare(p_buffer + position, - p_buffer + position + length_, - str.p_buffer + subposition, - str.p_buffer + subposition + sublength); + p_buffer + position + length_, + str.p_buffer + subposition, + str.p_buffer + subposition + sublength); } //************************************************************************* @@ -1511,9 +1511,9 @@ namespace etl int compare(const value_type* s) const { return compare(p_buffer, - p_buffer + size(), - s, - s + etl::strlen(s)); + p_buffer + size(), + s, + s + etl::strlen(s)); } //************************************************************************* @@ -1522,9 +1522,9 @@ namespace etl int compare(size_t position, size_t length_, const_pointer s) const { return compare(p_buffer + position, - p_buffer + position + length_, - s, - s + etl::strlen(s)); + p_buffer + position + length_, + s, + s + etl::strlen(s)); } //************************************************************************* @@ -1533,9 +1533,9 @@ namespace etl int compare(size_t position, size_t length_, const_pointer s, size_t n) const { return compare(p_buffer + position, - p_buffer + position + length_, - s, - s + n);; + p_buffer + position + length_, + s, + s + n); } //********************************************************************* diff --git a/include/etl/cstring.h b/include/etl/cstring.h index 36e602330..d9f69f16c 100644 --- a/include/etl/cstring.h +++ b/include/etl/cstring.h @@ -35,6 +35,10 @@ SOFTWARE. #include "basic_string.h" #include "hash.h" +#if ETL_CPP11_SUPPORTED + #include +#endif + #if defined(ETL_COMPILER_MICROSOFT) #undef min #endif @@ -63,7 +67,7 @@ namespace etl string() : istring(reinterpret_cast(&buffer), MAX_SIZE) { - istring::initialise(); + this->initialise(); } //************************************************************************* @@ -73,7 +77,7 @@ namespace etl string(const etl::string& other) : istring(reinterpret_cast(&buffer), MAX_SIZE) { - istring::assign(other.begin(), other.end()); + this->assign(other.begin(), other.end()); } //************************************************************************* @@ -90,7 +94,7 @@ namespace etl // Set the length to the exact amount. length_ = (length_ > MAX_SIZE_) ? MAX_SIZE_ : length_; - istring::assign(other.begin() + position, other.begin() + position + length_); + this->assign(other.begin() + position, other.begin() + position + length_); } //************************************************************************* @@ -100,7 +104,7 @@ namespace etl string(const value_type* text) : istring(reinterpret_cast(&buffer), MAX_SIZE) { - istring::assign(text, text + etl::char_traits::length(text)); + this->assign(text, text + etl::char_traits::length(text)); } //************************************************************************* @@ -111,7 +115,7 @@ namespace etl string(const value_type* text, size_t count) : istring(reinterpret_cast(&buffer), MAX_SIZE) { - istring::assign(text, text + count); + this->assign(text, text + count); } //************************************************************************* @@ -122,8 +126,8 @@ namespace etl string(size_t count, value_type c) : istring(reinterpret_cast(&buffer), MAX_SIZE) { - istring::initialise(); - istring::resize(count, c); + this->initialise(); + this->resize(count, c); } //************************************************************************* @@ -136,9 +140,20 @@ namespace etl string(TIterator first, TIterator last) : istring(reinterpret_cast(&buffer), MAX_SIZE) { - istring::assign(first, last); + this->assign(first, last); } +#if ETL_CPP11_SUPPORTED + //************************************************************************* + /// Construct from initializer_list. + //************************************************************************* + string(std::initializer_list init) + : istring(reinterpret_cast(&buffer), MAX_SIZE) + { + this->assign(init.begin(), init.end()); + } +#endif + //************************************************************************* /// Returns a sub-string. ///\param position The position of the first character. Default = 0. @@ -167,7 +182,7 @@ namespace etl { if (&rhs != this) { - istring::assign(rhs.cbegin(), rhs.cend()); + this->assign(rhs.cbegin(), rhs.cend()); } return *this; diff --git a/include/etl/deque.h b/include/etl/deque.h index 0d0966cd3..dd4870025 100644 --- a/include/etl/deque.h +++ b/include/etl/deque.h @@ -48,8 +48,12 @@ SOFTWARE. #include "type_traits.h" #include "parameter_type.h" +#if ETL_CPP11_SUPPORTED + #include +#endif + #ifdef ETL_COMPILER_MICROSOFT -#undef min + #undef min #endif #undef ETL_FILE @@ -2022,7 +2026,7 @@ namespace etl deque() : etl::ideque(reinterpret_cast(&buffer[0]), MAX_SIZE, BUFFER_SIZE) { - etl::ideque::initialise(); + this->initialise(); } //************************************************************************* @@ -2030,7 +2034,7 @@ namespace etl //************************************************************************* ~deque() { - etl::ideque::initialise(); + this->initialise(); } //************************************************************************* @@ -2041,7 +2045,7 @@ namespace etl { if (this != &other) { - etl::ideque::assign(other.begin(), other.end()); + this->assign(other.begin(), other.end()); } } @@ -2052,7 +2056,7 @@ namespace etl deque(TIterator begin_, TIterator end_) : etl::ideque(reinterpret_cast(&buffer[0]), MAX_SIZE, BUFFER_SIZE) { - etl::ideque::assign(begin_, end_); + this->assign(begin_, end_); } //************************************************************************* @@ -2061,8 +2065,19 @@ namespace etl explicit deque(size_t n, typename etl::ideque::parameter_t value = value_type()) : etl::ideque(reinterpret_cast(&buffer[0]), MAX_SIZE, BUFFER_SIZE) { - etl::ideque::assign(n, value); + this->assign(n, value); + } + +#if ETL_CPP11_SUPPORTED + //************************************************************************* + /// Construct from initializer_list. + //************************************************************************* + deque(std::initializer_list init) + : ideque(reinterpret_cast(&buffer[0]), MAX_SIZE, BUFFER_SIZE) + { + this->assign(init.begin(), init.end()); } +#endif //************************************************************************* /// Assignment operator. @@ -2071,7 +2086,7 @@ namespace etl { if (&rhs != this) { - etl::ideque::assign(rhs.begin(), rhs.end()); + this->assign(rhs.begin(), rhs.end()); } return *this; diff --git a/include/etl/flat_map.h b/include/etl/flat_map.h index e9b799cd5..abd423b48 100644 --- a/include/etl/flat_map.h +++ b/include/etl/flat_map.h @@ -35,6 +35,10 @@ SOFTWARE. #include "reference_flat_map.h" #include "pool.h" +#if ETL_CPP11_SUPPORTED + #include +#endif + #undef ETL_FILE #define ETL_FILE "2" @@ -834,7 +838,7 @@ namespace etl flat_map(const flat_map& other) : etl::iflat_map(lookup, storage) { - etl::iflat_map::assign(other.cbegin(), other.cend()); + this->assign(other.cbegin(), other.cend()); } //************************************************************************* @@ -847,15 +851,26 @@ namespace etl flat_map(TIterator first, TIterator last) : etl::iflat_map(lookup, storage) { - etl::iflat_map::assign(first, last); + this->assign(first, last); } +#if ETL_CPP11_SUPPORTED + //************************************************************************* + /// Construct from initializer_list. + //************************************************************************* + flat_map(std::initializer_list::value_type> init) + : etl::iflat_map(lookup, storage) + { + this->assign(init.begin(), init.end()); + } +#endif + //************************************************************************* /// Destructor. //************************************************************************* ~flat_map() { - etl::iflat_map::clear(); + this->clear(); } //************************************************************************* @@ -865,7 +880,7 @@ namespace etl { if (&rhs != this) { - etl::iflat_map::assign(rhs.cbegin(), rhs.cend()); + this->assign(rhs.cbegin(), rhs.cend()); } return *this; diff --git a/include/etl/flat_multimap.h b/include/etl/flat_multimap.h index 4ef7901ed..25b6a36d0 100644 --- a/include/etl/flat_multimap.h +++ b/include/etl/flat_multimap.h @@ -35,6 +35,10 @@ SOFTWARE. #include "reference_flat_multimap.h" #include "pool.h" +#if ETL_CPP11_SUPPORTED + #include +#endif + #undef ETL_FILE #define ETL_FILE "3" @@ -715,7 +719,7 @@ namespace etl flat_multimap(const flat_multimap& other) : etl::iflat_multimap(lookup, storage) { - etl::iflat_multimap::assign(other.cbegin(), other.cend()); + this->assign(other.cbegin(), other.cend()); } //************************************************************************* @@ -728,15 +732,26 @@ namespace etl flat_multimap(TIterator first, TIterator last) : etl::iflat_multimap(lookup, storage) { - etl::iflat_multimap::assign(first, last); + this->assign(first, last); } +#if ETL_CPP11_SUPPORTED + //************************************************************************* + /// Construct from initializer_list. + //************************************************************************* + flat_multimap(std::initializer_list::value_type> init) + : etl::iflat_multimap(lookup, storage) + { + this->assign(init.begin(), init.end()); + } +#endif + //************************************************************************* /// Destructor. //************************************************************************* ~flat_multimap() { - etl::iflat_multimap::clear(); + this->clear(); } //************************************************************************* @@ -746,7 +761,7 @@ namespace etl { if (&rhs != this) { - etl::iflat_multimap::assign(rhs.cbegin(), rhs.cend()); + this->assign(rhs.cbegin(), rhs.cend()); } return *this; diff --git a/include/etl/flat_multiset.h b/include/etl/flat_multiset.h index 2ec645a1f..c47dff0dd 100644 --- a/include/etl/flat_multiset.h +++ b/include/etl/flat_multiset.h @@ -35,6 +35,10 @@ SOFTWARE. #include "reference_flat_multiset.h" #include "pool.h" +#if ETL_CPP11_SUPPORTED + #include +#endif + #undef ETL_FILE #define ETL_FILE "4" @@ -674,7 +678,7 @@ namespace etl flat_multiset(const flat_multiset& other) : iflat_multiset(lookup, storage) { - etl::iflat_multiset::assign(other.cbegin(), other.cend()); + this->assign(other.cbegin(), other.cend()); } //************************************************************************* @@ -687,15 +691,26 @@ namespace etl flat_multiset(TIterator first, TIterator last) : iflat_multiset(lookup, storage) { - etl::iflat_multiset::assign(first, last); + this->assign(first, last); } +#if ETL_CPP11_SUPPORTED + //************************************************************************* + /// Construct from initializer_list. + //************************************************************************* + flat_multiset(std::initializer_list init) + : iflat_multiset(lookup, storage) + { + this->assign(init.begin(), init.end()); + } +#endif + //************************************************************************* /// Destructor. //************************************************************************* ~flat_multiset() { - etl::iflat_multiset::clear(); + this->clear(); } //************************************************************************* @@ -705,7 +720,7 @@ namespace etl { if (&rhs != this) { - etl::iflat_multiset::assign(rhs.cbegin(), rhs.cend()); + this->assign(rhs.cbegin(), rhs.cend()); } return *this; diff --git a/include/etl/flat_set.h b/include/etl/flat_set.h index 49e8b12fb..5366c0e8d 100644 --- a/include/etl/flat_set.h +++ b/include/etl/flat_set.h @@ -35,6 +35,10 @@ SOFTWARE. #include "reference_flat_set.h" #include "pool.h" +#if ETL_CPP11_SUPPORTED + #include +#endif + #undef ETL_FILE #define ETL_FILE "5" @@ -740,7 +744,7 @@ namespace etl flat_set(const flat_set& other) : etl::iflat_set(lookup, storage) { - etl::iflat_set::assign(other.cbegin(), other.cend()); + this->assign(other.cbegin(), other.cend()); } //************************************************************************* @@ -753,15 +757,26 @@ namespace etl flat_set(TIterator first, TIterator last) : etl::iflat_set(lookup, storage) { - etl::iflat_set::assign(first, last); + this->assign(first, last); } +#if ETL_CPP11_SUPPORTED + //************************************************************************* + /// Construct from initializer_list. + //************************************************************************* + flat_set(std::initializer_list init) + : etl::iflat_set(lookup, storage) + { + this->assign(init.begin(), init.end()); + } +#endif + //************************************************************************* /// Destructor. //************************************************************************* ~flat_set() { - etl::iflat_set::clear(); + this->clear(); } //************************************************************************* @@ -771,7 +786,7 @@ namespace etl { if (&rhs != this) { - etl::iflat_set::assign(rhs.cbegin(), rhs.cend()); + this->assign(rhs.cbegin(), rhs.cend()); } return *this; diff --git a/include/etl/forward_list.h b/include/etl/forward_list.h index e9a2fc08b..eaf5fcd0b 100644 --- a/include/etl/forward_list.h +++ b/include/etl/forward_list.h @@ -46,6 +46,10 @@ SOFTWARE. #include "type_traits.h" #include "parameter_type.h" +#if ETL_CPP11_SUPPORTED + #include +#endif + #ifdef ETL_COMPILER_MICROSOFT #undef min #endif @@ -1382,7 +1386,7 @@ namespace etl forward_list() : etl::iforward_list(node_pool, MAX_SIZE) { - etl::iforward_list::initialise(); + this->initialise(); } //************************************************************************* @@ -1391,7 +1395,7 @@ namespace etl explicit forward_list(size_t initial_size, typename etl::iforward_list::parameter_t value = T()) : etl::iforward_list(node_pool, MAX_SIZE) { - etl::iforward_list::assign(initial_size, value); + this->assign(initial_size, value); } //************************************************************************* @@ -1400,7 +1404,7 @@ namespace etl forward_list(const forward_list& other) : etl::iforward_list(node_pool, MAX_SIZE) { - etl::iforward_list::assign(other.cbegin(), other.cend()); + this->assign(other.cbegin(), other.cend()); } //************************************************************************* @@ -1410,15 +1414,26 @@ namespace etl forward_list(TIterator first, TIterator last) : etl::iforward_list(node_pool, MAX_SIZE) { - etl::iforward_list::assign(first, last); + this->assign(first, last); } +#if ETL_CPP11_SUPPORTED + //************************************************************************* + /// Construct from initializer_list. + //************************************************************************* + forward_list(std::initializer_list init) + : etl::iforward_list(node_pool, MAX_SIZE) + { + this->assign(init.begin(), init.end()); + } +#endif + //************************************************************************* /// Destructor. //************************************************************************* ~forward_list() { - etl::iforward_list::initialise(); + this->initialise(); } //************************************************************************* @@ -1428,7 +1443,7 @@ namespace etl { if (&rhs != this) { - etl::iforward_list::assign(rhs.cbegin(), rhs.cend()); + this->assign(rhs.cbegin(), rhs.cend()); } return *this; diff --git a/include/etl/list.h b/include/etl/list.h index 65f9efc09..8ed4e267e 100644 --- a/include/etl/list.h +++ b/include/etl/list.h @@ -47,8 +47,12 @@ SOFTWARE. #include "parameter_type.h" #include "algorithm.h" +#if ETL_CPP11_SUPPORTED + #include +#endif + #ifdef ETL_COMPILER_MICROSOFT -#undef min + #undef min #endif #undef ETL_FILE @@ -1602,7 +1606,7 @@ namespace etl list() : etl::ilist(node_pool, MAX_SIZE) { - etl::ilist::initialise(); + this->initialise(); } //************************************************************************* @@ -1610,7 +1614,7 @@ namespace etl //************************************************************************* ~list() { - etl::ilist::initialise(); + this->initialise(); } //************************************************************************* @@ -1619,7 +1623,7 @@ namespace etl explicit list(size_t initial_size) : etl::ilist(node_pool, MAX_SIZE) { - etl::ilist::assign(initial_size, T()); + this->assign(initial_size, T()); } //************************************************************************* @@ -1628,7 +1632,7 @@ namespace etl list(size_t initial_size, typename ilist::parameter_t value) : etl::ilist(node_pool, MAX_SIZE) { - etl::ilist::assign(initial_size, value); + this->assign(initial_size, value); } //************************************************************************* @@ -1639,7 +1643,7 @@ namespace etl { if (this != &other) { - etl::ilist::assign(other.cbegin(), other.cend()); + this->assign(other.cbegin(), other.cend()); } } @@ -1650,9 +1654,20 @@ namespace etl list(TIterator first, TIterator last) : ilist(node_pool, MAX_SIZE) { - etl::ilist::assign(first, last); + this->assign(first, last); } +#if ETL_CPP11_SUPPORTED + //************************************************************************* + /// Construct from initializer_list. + //************************************************************************* + list(std::initializer_list init) + : ilist(node_pool, MAX_SIZE) + { + this->assign(init.begin(), init.end()); + } +#endif + //************************************************************************* /// Assignment operator. //************************************************************************* @@ -1660,7 +1675,7 @@ namespace etl { if (&rhs != this) { - etl::ilist::assign(rhs.cbegin(), rhs.cend()); + this->assign(rhs.cbegin(), rhs.cend()); } return *this; diff --git a/include/etl/map.h b/include/etl/map.h index 61695cec8..19e04f439 100644 --- a/include/etl/map.h +++ b/include/etl/map.h @@ -47,8 +47,12 @@ SOFTWARE. #include "type_traits.h" #include "parameter_type.h" +#if ETL_CPP11_SUPPORTED + #include +#endif + #ifdef ETL_COMPILER_MICROSOFT -#undef min + #undef min #endif #undef ETL_FILE @@ -2036,7 +2040,7 @@ namespace etl map() : etl::imap(node_pool, MAX_SIZE) { - etl::imap::initialise(); + this->initialise(); } //************************************************************************* @@ -2045,7 +2049,7 @@ namespace etl map(const map& other) : etl::imap(node_pool, MAX_SIZE) { - etl::imap::assign(other.cbegin(), other.cend()); + this->assign(other.cbegin(), other.cend()); } //************************************************************************* @@ -2058,15 +2062,26 @@ namespace etl map(TIterator first, TIterator last) : etl::imap(node_pool, MAX_SIZE) { - etl::imap::assign(first, last); + this->assign(first, last); } +#if ETL_CPP11_SUPPORTED + //************************************************************************* + /// Constructor, from an initializer_list. + //************************************************************************* + map(std::initializer_list::value_type> init) + : etl::imap(node_pool, MAX_SIZE) + { + this->assign(init.begin(), init.end()); + } +#endif + //************************************************************************* /// Destructor. //************************************************************************* ~map() { - etl::imap::initialise(); + this->initialise(); } //************************************************************************* @@ -2077,7 +2092,7 @@ namespace etl // Skip if doing self assignment if (this != &rhs) { - etl::imap::assign(rhs.cbegin(), rhs.cend()); + this->assign(rhs.cbegin(), rhs.cend()); } return *this; diff --git a/include/etl/multimap.h b/include/etl/multimap.h index ebb93c895..fa032c0af 100644 --- a/include/etl/multimap.h +++ b/include/etl/multimap.h @@ -46,6 +46,10 @@ SOFTWARE. #include "type_traits.h" #include "parameter_type.h" +#if ETL_CPP11_SUPPORTED + #include +#endif + #ifdef ETL_COMPILER_MICROSOFT #undef min #endif @@ -1921,7 +1925,7 @@ namespace etl multimap() : etl::imultimap(node_pool, MAX_SIZE) { - etl::imultimap::initialise(); + this->initialise(); } //************************************************************************* @@ -1930,7 +1934,7 @@ namespace etl multimap(const multimap& other) : etl::imultimap(node_pool, MAX_SIZE) { - etl::imultimap::assign(other.cbegin(), other.cend()); + this->assign(other.cbegin(), other.cend()); } //************************************************************************* @@ -1943,15 +1947,26 @@ namespace etl multimap(TIterator first, TIterator last) : etl::imultimap(node_pool, MAX_SIZE) { - etl::imultimap::assign(first, last); + this->assign(first, last); } +#if ETL_CPP11_SUPPORTED + //************************************************************************* + /// Constructor, from an initializer_list. + //************************************************************************* + multimap(std::initializer_list::value_type> init) + : etl::imultimap(node_pool, MAX_SIZE) + { + this->assign(init.begin(), init.end()); + } +#endif + //************************************************************************* /// Destructor. //************************************************************************* ~multimap() { - etl::imultimap::initialise(); + this->initialise(); } //************************************************************************* @@ -1962,7 +1977,7 @@ namespace etl // Skip if doing self assignment if (this != &rhs) { - etl::imultimap::assign(rhs.cbegin(), rhs.cend()); + this->assign(rhs.cbegin(), rhs.cend()); } return *this; diff --git a/include/etl/multiset.h b/include/etl/multiset.h index 3d58d1862..7bb0fff2a 100644 --- a/include/etl/multiset.h +++ b/include/etl/multiset.h @@ -46,6 +46,10 @@ SOFTWARE. #include "nullptr.h" #include "type_traits.h" +#if ETL_CPP11_SUPPORTED + #include +#endif + #ifdef ETL_COMPILER_MICROSOFT #undef min #endif @@ -1901,7 +1905,7 @@ namespace etl multiset() : etl::imultiset(node_pool, MAX_SIZE) { - etl::imultiset::initialise(); + this->initialise(); } //************************************************************************* @@ -1910,7 +1914,7 @@ namespace etl multiset(const multiset& other) : etl::imultiset(node_pool, MAX_SIZE) { - etl::imultiset::assign(other.cbegin(), other.cend()); + this->assign(other.cbegin(), other.cend()); } //************************************************************************* @@ -1923,15 +1927,26 @@ namespace etl multiset(TIterator first, TIterator last) : etl::imultiset(node_pool, MAX_SIZE) { - etl::imultiset::assign(first, last); + this->assign(first, last); } +#if ETL_CPP11_SUPPORTED + //************************************************************************* + /// Constructor, from an initializer_list. + //************************************************************************* + multiset(std::initializer_list::value_type> init) + : etl::imultiset(node_pool, MAX_SIZE) + { + this->assign(init.begin(), init.end()); + } +#endif + //************************************************************************* /// Destructor. //************************************************************************* ~multiset() { - etl::imultiset::initialise(); + this->initialise(); } //************************************************************************* @@ -1942,7 +1957,7 @@ namespace etl // Skip if doing self assignment if (this != &rhs) { - etl::imultiset::assign(rhs.cbegin(), rhs.cend()); + this->assign(rhs.cbegin(), rhs.cend()); } return *this; diff --git a/include/etl/set.h b/include/etl/set.h index a3040c57a..0db42f38c 100644 --- a/include/etl/set.h +++ b/include/etl/set.h @@ -46,6 +46,10 @@ SOFTWARE. #include "type_traits.h" #include "parameter_type.h" +#if ETL_CPP11_SUPPORTED + #include +#endif + #ifdef ETL_COMPILER_MICROSOFT #undef min #endif @@ -1959,7 +1963,7 @@ namespace etl set() : etl::iset(node_pool, MAX_SIZE) { - etl::iset::initialise(); + this->initialise(); } //************************************************************************* @@ -1968,7 +1972,7 @@ namespace etl set(const set& other) : etl::iset(node_pool, MAX_SIZE) { - etl::iset::assign(other.cbegin(), other.cend()); + this->assign(other.cbegin(), other.cend()); } //************************************************************************* @@ -1981,15 +1985,26 @@ namespace etl set(TIterator first, TIterator last) : etl::iset(node_pool, MAX_SIZE) { - etl::iset::assign(first, last); + this->assign(first, last); } +#if ETL_CPP11_SUPPORTED + //************************************************************************* + /// Constructor, from an initializer_list. + //************************************************************************* + set(std::initializer_list::value_type> init) + : etl::iset(node_pool, MAX_SIZE) + { + this->assign(init.begin(), init.end()); + } +#endif + //************************************************************************* /// Destructor. //************************************************************************* ~set() { - etl::iset::initialise(); + this->initialise(); } //************************************************************************* @@ -2000,7 +2015,7 @@ namespace etl // Skip if doing self assignment if (this != &rhs) { - etl::iset::assign(rhs.cbegin(), rhs.cend()); + this->assign(rhs.cbegin(), rhs.cend()); } return *this; diff --git a/include/etl/u16string.h b/include/etl/u16string.h index 107ccfcb9..b9d81f04e 100644 --- a/include/etl/u16string.h +++ b/include/etl/u16string.h @@ -35,6 +35,10 @@ SOFTWARE. #include "basic_string.h" #include "hash.h" +#if ETL_CPP11_SUPPORTED + #include +#endif + #if defined(ETL_COMPILER_MICROSOFT) #undef min #endif @@ -63,7 +67,7 @@ namespace etl u16string() : iu16string(reinterpret_cast(&buffer), MAX_SIZE) { - iu16string::initialise(); + this->initialise(); } //************************************************************************* @@ -73,8 +77,8 @@ namespace etl u16string(const etl::u16string& other) : iu16string(reinterpret_cast(&buffer), MAX_SIZE) { - iu16string::initialise(); - iu16string::assign(other.begin(), other.end()); + this->initialise(); + this->assign(other.begin(), other.end()); } //************************************************************************* @@ -91,8 +95,8 @@ namespace etl // Set the length to the exact amount. length_ = (length_ > MAX_SIZE_) ? MAX_SIZE_ : length_; - iu16string::initialise(); - iu16string::assign(other.begin() + position, other.begin() + position + length_); + this->initialise(); + this->assign(other.begin() + position, other.begin() + position + length_); } //************************************************************************* @@ -102,8 +106,8 @@ namespace etl u16string(const value_type* text) : iu16string(reinterpret_cast(&buffer), MAX_SIZE) { - iu16string::initialise(); - iu16string::assign(text, text + etl::char_traits::length(text)); + this->initialise(); + this->assign(text, text + etl::char_traits::length(text)); } //************************************************************************* @@ -114,8 +118,8 @@ namespace etl u16string(const value_type* text, size_t count) : iu16string(reinterpret_cast(&buffer), MAX_SIZE) { - iu16string::initialise(); - iu16string::assign(text, text + count); + this->initialise(); + this->assign(text, text + count); } //************************************************************************* @@ -126,8 +130,8 @@ namespace etl u16string(size_t count, value_type c) : iu16string(reinterpret_cast(&buffer), MAX_SIZE) { - iu16string::initialise(); - iu16string::resize(count, c); + this->initialise(); + this->resize(count, c); } //************************************************************************* @@ -140,9 +144,20 @@ namespace etl u16string(TIterator first, TIterator last) : iu16string(reinterpret_cast(&buffer), MAX_SIZE) { - iu16string::assign(first, last); + this->assign(first, last); } +#if ETL_CPP11_SUPPORTED + //************************************************************************* + /// Construct from initializer_list. + //************************************************************************* + u16string(std::initializer_list init) + : iu16string(reinterpret_cast(&buffer), MAX_SIZE) + { + this->assign(init.begin(), init.end()); + } +#endif + //************************************************************************* /// Returns a sub-string. ///\param position The position of the first character. Default = 0. @@ -171,7 +186,7 @@ namespace etl { if (&rhs != this) { - iu16string::assign(rhs.cbegin(), rhs.cend()); + this->assign(rhs.cbegin(), rhs.cend()); } return *this; diff --git a/include/etl/u32string.h b/include/etl/u32string.h index 590c75344..8df0ccd66 100644 --- a/include/etl/u32string.h +++ b/include/etl/u32string.h @@ -35,6 +35,10 @@ SOFTWARE. #include "basic_string.h" #include "hash.h" +#if ETL_CPP11_SUPPORTED + #include +#endif + #if defined(ETL_COMPILER_MICROSOFT) #undef min #endif @@ -63,7 +67,7 @@ namespace etl u32string() : iu32string(reinterpret_cast(&buffer), MAX_SIZE) { - iu32string::initialise(); + this->initialise(); } //************************************************************************* @@ -73,8 +77,8 @@ namespace etl u32string(const etl::u32string& other) : iu32string(reinterpret_cast(&buffer), MAX_SIZE) { - iu32string::initialise(); - iu32string::assign(other.begin(), other.end()); + this->initialise(); + this->assign(other.begin(), other.end()); } //************************************************************************* @@ -91,8 +95,8 @@ namespace etl // Set the length to the exact amount. length_ = (length_ > MAX_SIZE_) ? MAX_SIZE_ : length_; - iu32string::initialise(); - iu32string::assign(other.begin() + position, other.begin() + position + length_); + this->initialise(); + this->assign(other.begin() + position, other.begin() + position + length_); } //************************************************************************* @@ -102,8 +106,8 @@ namespace etl u32string(const value_type* text) : iu32string(reinterpret_cast(&buffer), MAX_SIZE) { - iu32string::initialise(); - iu32string::assign(text, text + etl::char_traits::length(text)); + this->initialise(); + this->assign(text, text + etl::char_traits::length(text)); } //************************************************************************* @@ -114,8 +118,8 @@ namespace etl u32string(const value_type* text, size_t count) : iu32string(reinterpret_cast(&buffer), MAX_SIZE) { - iu32string::initialise(); - iu32string::assign(text, text + count); + this->initialise(); + this->assign(text, text + count); } //************************************************************************* @@ -126,8 +130,8 @@ namespace etl u32string(size_t count, value_type c) : iu32string(reinterpret_cast(&buffer), MAX_SIZE) { - iu32string::initialise(); - iu32string::resize(count, c); + this->initialise(); + this->resize(count, c); } //************************************************************************* @@ -140,9 +144,20 @@ namespace etl u32string(TIterator first, TIterator last) : iu32string(reinterpret_cast(&buffer), MAX_SIZE) { - iu32string::assign(first, last); + this->assign(first, last); } +#if ETL_CPP11_SUPPORTED + //************************************************************************* + /// Construct from initializer_list. + //************************************************************************* + u32string(std::initializer_list init) + : iu32string(reinterpret_cast(&buffer), MAX_SIZE) + { + this->assign(init.begin(), init.end()); + } +#endif + //************************************************************************* /// Returns a sub-string. ///\param position The position of the first character. Default = 0. @@ -171,7 +186,7 @@ namespace etl { if (&rhs != this) { - iu32string::assign(rhs.cbegin(), rhs.cend()); + this->assign(rhs.cbegin(), rhs.cend()); } return *this; diff --git a/include/etl/vector.h b/include/etl/vector.h index bbc8b8201..4a7a9e737 100644 --- a/include/etl/vector.h +++ b/include/etl/vector.h @@ -53,8 +53,12 @@ SOFTWARE. #include "debug_count.h" #include "private/vector_base.h" +#if ETL_CPP11_SUPPORTED + #include +#endif + #ifdef ETL_COMPILER_GCC -#pragma GCC diagnostic ignored "-Wunused-variable" + #pragma GCC diagnostic ignored "-Wunused-variable" #endif //***************************************************************************** @@ -1071,7 +1075,7 @@ namespace etl vector() : etl::ivector(reinterpret_cast(&buffer), MAX_SIZE) { - etl::ivector::initialise(); + this->initialise(); } //************************************************************************* @@ -1081,8 +1085,8 @@ namespace etl explicit vector(size_t initial_size) : etl::ivector(reinterpret_cast(&buffer), MAX_SIZE) { - etl::ivector::initialise(); - etl::ivector::resize(initial_size); + this->initialise(); + this->resize(initial_size); } //************************************************************************* @@ -1093,8 +1097,8 @@ namespace etl vector(size_t initial_size, typename etl::ivector::parameter_t value) : etl::ivector(reinterpret_cast(&buffer), MAX_SIZE) { - etl::ivector::initialise(); - etl::ivector::resize(initial_size, value); + this->initialise(); + this->resize(initial_size, value); } //************************************************************************* @@ -1107,8 +1111,19 @@ namespace etl vector(TIterator first, TIterator last) : etl::ivector(reinterpret_cast(&buffer), MAX_SIZE) { - etl::ivector::assign(first, last); + this->assign(first, last); + } + +#if ETL_CPP11_SUPPORTED + //************************************************************************* + /// Constructor, from an initializer_list. + //************************************************************************* + vector(std::initializer_list init) + : etl::ivector(reinterpret_cast(&buffer), MAX_SIZE) + { + this->assign(init.begin(), init.end()); } +#endif //************************************************************************* /// Copy constructor. @@ -1116,7 +1131,7 @@ namespace etl vector(const vector& other) : etl::ivector(reinterpret_cast(&buffer), MAX_SIZE) { - etl::ivector::assign(other.begin(), other.end()); + this->assign(other.begin(), other.end()); } //************************************************************************* @@ -1124,7 +1139,7 @@ namespace etl //************************************************************************* ~vector() { - etl::ivector::clear(); + this->clear(); } //************************************************************************* @@ -1134,7 +1149,7 @@ namespace etl { if (&rhs != this) { - etl::ivector::assign(rhs.cbegin(), rhs.cend()); + this->assign(rhs.cbegin(), rhs.cend()); } return *this; @@ -1176,7 +1191,7 @@ namespace etl vector() : etl::ivector(reinterpret_cast(&buffer), MAX_SIZE) { - etl::ivector::initialise(); + this->initialise(); } //************************************************************************* @@ -1186,8 +1201,8 @@ namespace etl explicit vector(size_t initial_size) : etl::ivector(reinterpret_cast(&buffer), MAX_SIZE) { - etl::ivector::initialise(); - etl::ivector::resize(initial_size); + this->initialise(); + this->resize(initial_size); } //************************************************************************* @@ -1198,8 +1213,8 @@ namespace etl vector(size_t initial_size, typename etl::ivector::parameter_t value) : etl::ivector(reinterpret_cast(&buffer), MAX_SIZE) { - etl::ivector::initialise(); - etl::ivector::resize(initial_size, value); + this->initialise(); + this->resize(initial_size, value); } //************************************************************************* @@ -1212,8 +1227,19 @@ namespace etl vector(TIterator first, TIterator last) : etl::ivector(reinterpret_cast(&buffer), MAX_SIZE) { - etl::ivector::assign(first, last); + this->assign(first, last); + } + +#if ETL_CPP11_SUPPORTED + //************************************************************************* + /// Constructor, from an initializer_list. + //************************************************************************* + vector(std::initializer_list init) + : etl::ivector(reinterpret_cast(&buffer), MAX_SIZE) + { + this->assign(init.begin(), init.end()); } +#endif //************************************************************************* /// Copy constructor. @@ -1221,7 +1247,7 @@ namespace etl vector(const vector& other) : etl::ivector(reinterpret_cast(&buffer), MAX_SIZE) { - etl::ivector::assign(other.begin(), other.end()); + this->assign(other.begin(), other.end()); } //************************************************************************* @@ -1231,7 +1257,7 @@ namespace etl { if (&rhs != this) { - etl::ivector::assign(rhs.cbegin(), rhs.cend()); + this->assign(rhs.cbegin(), rhs.cend()); } return *this; diff --git a/include/etl/wstring.h b/include/etl/wstring.h index 99b1979a6..7a2a94ceb 100644 --- a/include/etl/wstring.h +++ b/include/etl/wstring.h @@ -35,6 +35,10 @@ SOFTWARE. #include "basic_string.h" #include "hash.h" +#if ETL_CPP11_SUPPORTED + #include +#endif + #if defined(ETL_COMPILER_MICROSOFT) #undef min #endif @@ -63,7 +67,7 @@ namespace etl wstring() : iwstring(reinterpret_cast(&buffer), MAX_SIZE) { - iwstring::initialise(); + this->initialise(); } //************************************************************************* @@ -92,8 +96,8 @@ namespace etl // Set the length to the exact amount. length_ = (length_ > MAX_SIZE_) ? MAX_SIZE_ : length_; - iwstring::initialise(); - iwstring::assign(other.begin() + position, other.begin() + position + length_); + this->initialise(); + this->assign(other.begin() + position, other.begin() + position + length_); } //************************************************************************* @@ -103,8 +107,8 @@ namespace etl wstring(const value_type* text) : iwstring(reinterpret_cast(&buffer), MAX_SIZE) { - iwstring::initialise(); - iwstring::assign(text, text + etl::char_traits::length(text)); + this->initialise(); + this->assign(text, text + etl::char_traits::length(text)); } //************************************************************************* @@ -115,8 +119,8 @@ namespace etl wstring(const value_type* text, size_t count) : iwstring(reinterpret_cast(&buffer), MAX_SIZE) { - iwstring::initialise(); - iwstring::assign(text, text + count); + this->initialise(); + this->assign(text, text + count); } //************************************************************************* @@ -127,8 +131,8 @@ namespace etl wstring(size_t count, value_type c) : iwstring(reinterpret_cast(&buffer), MAX_SIZE) { - iwstring::initialise(); - iwstring::resize(count, c); + this->initialise(); + this->resize(count, c); } //************************************************************************* @@ -141,9 +145,20 @@ namespace etl wstring(TIterator first, TIterator last) : iwstring(reinterpret_cast(&buffer), MAX_SIZE) { - iwstring::assign(first, last); + this->assign(first, last); } +#if ETL_CPP11_SUPPORTED + //************************************************************************* + /// Construct from initializer_list. + //************************************************************************* + wstring(std::initializer_list init) + : iwstring(reinterpret_cast(&buffer), MAX_SIZE) + { + this->assign(init.begin(), init.end()); + } +#endif + //************************************************************************* /// Returns a sub-string. ///\param position The position of the first character. Default = 0. @@ -172,7 +187,7 @@ namespace etl { if (&rhs != this) { - iwstring::assign(rhs.cbegin(), rhs.cend()); + this->assign(rhs.cbegin(), rhs.cend()); } return *this; diff --git a/support/Release notes.txt b/support/Release notes.txt index 58b72831e..a955a9acd 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,9 +1,13 @@ =============================================================================== -11.00.1 +11.1.0 +Added std::initializer_list constructors to containers, if ETL_CPP11_SUPPORTED is set to 1 + +=============================================================================== +11.0.1 Added reset() to etl::optional =============================================================================== -11.00.0 +11.0.0 New directory structure. C & CPP files in src/ H files in include/etl/ diff --git a/test/test_deque.cpp b/test/test_deque.cpp index 0bd71a7ef..869bdfcd4 100644 --- a/test/test_deque.cpp +++ b/test/test_deque.cpp @@ -136,6 +136,16 @@ namespace CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin())); } + //************************************************************************* + TEST(test_constructor_initializer_list) + { + Compare_Data compare_data = { N0, N1, N2, N3 }; + DataNDC data = { N0, N1, N2, N3 }; + + CHECK_EQUAL(compare_data.size(), data.size()); + CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin())); + } + //************************************************************************* TEST(test_copy_constructor) { diff --git a/test/test_flat_map.cpp b/test/test_flat_map.cpp index d00387e07..c290da7ff 100644 --- a/test/test_flat_map.cpp +++ b/test/test_flat_map.cpp @@ -189,22 +189,6 @@ namespace return true; } - //************************************************************************* -// std::ostream& operator <<(std::ostream& os, const DataDC::iterator& itr) -// { -// os << itr->first; - -// return os; -// } - - //************************************************************************* -// std::ostream& operator <<(std::ostream& os, const DataDC::const_iterator& itr) -// { -// os << itr->first; - -// return os; -// } - //************************************************************************* std::ostream& operator <<(std::ostream& os, const DataNDC::iterator& itr) { @@ -351,6 +335,22 @@ namespace CHECK(!data.empty()); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_initializer_list) + { + Compare_DataNDC compare_data = { ElementNDC(0, N0), ElementNDC(1, N1), ElementNDC(2, N2), ElementNDC(3, N3), ElementNDC(4, N4) }; + + DataNDC data = { ElementNDC(0, N0), ElementNDC(1, N1), ElementNDC(2, N2), ElementNDC(3, N3), ElementNDC(4, N4) }; + + CHECK_EQUAL(compare_data.size(), data.size()); + CHECK(!data.empty()); + + bool isEqual = std::equal(data.begin(), + data.end(), + compare_data.begin()); + CHECK(isEqual); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assignment) { diff --git a/test/test_flat_multimap.cpp b/test/test_flat_multimap.cpp index afec18e1e..2c2486cb1 100644 --- a/test/test_flat_multimap.cpp +++ b/test/test_flat_multimap.cpp @@ -215,22 +215,6 @@ namespace return true; } - //************************************************************************* -// std::ostream& operator <<(std::ostream& os, const DataDC::iterator& itr) -// { -// os << itr->first; - -// return os; -// } - - //************************************************************************* -// std::ostream& operator <<(std::ostream& os, const DataDC::const_iterator& itr) -// { -// os << itr->first; - -// return os; -// } - //************************************************************************* std::ostream& operator <<(std::ostream& os, const DataNDC::iterator& itr) { @@ -326,6 +310,28 @@ namespace CHECK(data.size() == SIZE); CHECK(!data.empty()); + + + bool isEqual = std::equal(data.begin(), + data.end(), + compare_data.begin()); + CHECK(isEqual); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_initializer_list) + { + Compare_DataNDC compare_data = { ElementNDC(0, N0), ElementNDC(1, N1), ElementNDC(2, N2), ElementNDC(3, N3), ElementNDC(4, N4) }; + + DataNDC data = { ElementNDC(0, N0), ElementNDC(1, N1), ElementNDC(2, N2), ElementNDC(3, N3), ElementNDC(4, N4) }; + + CHECK_EQUAL(compare_data.size(), data.size()); + CHECK(!data.empty()); + + bool isEqual = std::equal(data.begin(), + data.end(), + compare_data.begin()); + CHECK(isEqual); } //************************************************************************* diff --git a/test/test_flat_multiset.cpp b/test/test_flat_multiset.cpp index 447de1877..e9bccba05 100644 --- a/test/test_flat_multiset.cpp +++ b/test/test_flat_multiset.cpp @@ -281,6 +281,22 @@ namespace CHECK(!data.empty()); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_initializer_list) + { + Compare_DataNDC compare_data = { N0, N0, N1, N2, N3, N1, N3, N3, N4, N2 }; + + DataNDC data = { N0, N0, N1, N2, N3, N1, N3, N3, N4, N2 }; + + CHECK_EQUAL(compare_data.size(), data.size()); + CHECK(!data.empty()); + + bool isEqual = std::equal(data.begin(), + data.end(), + compare_data.begin()); + CHECK(isEqual); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assignment) { diff --git a/test/test_flat_set.cpp b/test/test_flat_set.cpp index b7530a6d8..1e0e9982f 100644 --- a/test/test_flat_set.cpp +++ b/test/test_flat_set.cpp @@ -293,6 +293,22 @@ namespace CHECK(!data.empty()); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_initializer_list) + { + Compare_DataNDC compare_data = { N0, N1, N2, N3, N4, N5, N6, N7, N8, N9 }; + + DataNDC data = { N0, N1, N2, N3, N4, N5, N6, N7, N8, N9 }; + + CHECK_EQUAL(compare_data.size(), data.size()); + CHECK(!data.empty()); + + bool isEqual = std::equal(data.begin(), + data.end(), + compare_data.begin()); + CHECK(isEqual); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assignment) { diff --git a/test/test_forward_list.cpp b/test/test_forward_list.cpp index c6e81f6ce..98827bb31 100644 --- a/test/test_forward_list.cpp +++ b/test/test_forward_list.cpp @@ -124,9 +124,26 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_range) { + CompareDataNDC compare(sorted_data.begin(), sorted_data.end()); DataNDC data(sorted_data.begin(), sorted_data.end()); CHECK(!data.empty()); + + are_equal = std::equal(data.begin(), data.end(), compare.begin()); + + CHECK(are_equal); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_initializer_list) + { + CompareDataNDC compare = { ItemNDC("0"), ItemNDC("1"), ItemNDC("2"), ItemNDC("3") }; + DataNDC data = { ItemNDC("0"), ItemNDC("1"), ItemNDC("2"), ItemNDC("3") }; + + CHECK(!data.empty()); + + are_equal = std::equal(data.begin(), data.end(), compare.begin()); + CHECK(are_equal); } //************************************************************************* diff --git a/test/test_list.cpp b/test/test_list.cpp index c0aaf9bde..a96e11279 100644 --- a/test/test_list.cpp +++ b/test/test_list.cpp @@ -162,6 +162,21 @@ namespace CHECK(!data.empty()); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_initializer_list) + { + DataNDC data = { ItemNDC("0"), ItemNDC("1"), ItemNDC("2"), ItemNDC("3") }; + + CHECK_EQUAL(4U, data.size()); + + DataNDC::const_iterator i_item = data.begin(); + + CHECK_EQUAL(ItemNDC("0"), *i_item++); + CHECK_EQUAL(ItemNDC("1"), *i_item++); + CHECK_EQUAL(ItemNDC("2"), *i_item++); + CHECK_EQUAL(ItemNDC("3"), *i_item++); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { diff --git a/test/test_map.cpp b/test/test_map.cpp index a23397b41..1881f0e2d 100644 --- a/test/test_map.cpp +++ b/test/test_map.cpp @@ -206,6 +206,25 @@ namespace CHECK(!data.empty()); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_initializer_list) + { + Compare_Data compare_data = { Data::value_type(std::string("0"), 0), Data::value_type(std::string("1"), 1), + Data::value_type(std::string("2"), 2), Data::value_type(std::string("3"), 3) }; + + Data data = { Data::value_type(std::string("0"), 0), Data::value_type(std::string("1"), 1), + Data::value_type(std::string("2"), 2), Data::value_type(std::string("3"), 3) }; + + CHECK_EQUAL(compare_data.size(), data.size()); + CHECK(!data.empty()); + + bool isEqual = Check_Equal(data.begin(), + data.end(), + compare_data.begin()); + + CHECK(isEqual); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assignment) { diff --git a/test/test_multimap.cpp b/test/test_multimap.cpp index d71dc01e5..9954afbc5 100644 --- a/test/test_multimap.cpp +++ b/test/test_multimap.cpp @@ -203,6 +203,25 @@ namespace CHECK(!data.empty()); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_initializer_list) + { + Compare_Data compare_data = { Data::value_type(std::string("0"), 0), Data::value_type(std::string("1"), 1), + Data::value_type(std::string("2"), 2), Data::value_type(std::string("3"), 3) }; + + Data data = { Data::value_type(std::string("0"), 0), Data::value_type(std::string("1"), 1), + Data::value_type(std::string("2"), 2), Data::value_type(std::string("3"), 3) }; + + CHECK_EQUAL(compare_data.size(), data.size()); + CHECK(!data.empty()); + + bool isEqual = Check_Equal(data.begin(), + data.end(), + compare_data.begin()); + + CHECK(isEqual); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assignment) { diff --git a/test/test_multiset.cpp b/test/test_multiset.cpp index ab454fbda..03813ba05 100644 --- a/test/test_multiset.cpp +++ b/test/test_multiset.cpp @@ -195,6 +195,20 @@ namespace CHECK(!data.empty()); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_initializer_list) + { + Compare_Data compare_data = { 0, 1, 1, 3, 4, 4, 6, 7, 7, 9 }; + + Data data = { 0, 1, 1, 3, 4, 4, 6, 7, 7, 9 }; + + CHECK_EQUAL(compare_data.size(), data.size()); + CHECK(!data.empty()); + + bool isEqual = std::equal(data.begin(), data.end(), compare_data.begin()); + CHECK(isEqual); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assignment) { diff --git a/test/test_reference_flat_map.cpp b/test/test_reference_flat_map.cpp index 976b28eaf..bfcd7cda8 100644 --- a/test/test_reference_flat_map.cpp +++ b/test/test_reference_flat_map.cpp @@ -78,22 +78,6 @@ namespace return true; } - //************************************************************************* -// std::ostream& operator <<(std::ostream& os, const DataDC::iterator& itr) -// { -// os << itr->first; - -// return os; -// } - - //************************************************************************* -// std::ostream& operator <<(std::ostream& os, const DataDC::const_iterator& itr) -// { -// os << itr->first; - -// return os; -// } - //************************************************************************* std::ostream& operator <<(std::ostream& os, const DataNDC::iterator& itr) { diff --git a/test/test_reference_flat_multimap.cpp b/test/test_reference_flat_multimap.cpp index f433cea26..c9bc8e557 100644 --- a/test/test_reference_flat_multimap.cpp +++ b/test/test_reference_flat_multimap.cpp @@ -58,22 +58,6 @@ namespace typedef std::multimap Compare_DataDC; typedef std::multimap Compare_DataNDC; - //************************************************************************* - // std::ostream& operator <<(std::ostream& os, const DataDC::iterator& itr) - // { - // os << itr->first - // - // return os; - // } - - //************************************************************************* - // std::ostream& operator <<(std::ostream& os, const DataDC::const_iterator& itr) - // { - // os << itr->first; - // - // return os; - // } - //************************************************************************* std::ostream& operator <<(std::ostream& os, const DataNDC::iterator& itr) { diff --git a/test/test_reference_flat_multiset.cpp b/test/test_reference_flat_multiset.cpp index f3ad4a347..72c1511b1 100644 --- a/test/test_reference_flat_multiset.cpp +++ b/test/test_reference_flat_multiset.cpp @@ -83,22 +83,6 @@ namespace std::vector different_data; std::vector multi_data; - //************************************************************************* -// std::ostream& operator <<(std::ostream& os, const DataDC::iterator& itr) -// { -// os << itr->value; -// -// return os; -// } - - //************************************************************************* -// std::ostream& operator <<(std::ostream& os, const DataDC::const_iterator& itr) -// { -// os << itr->value; -// -// return os; -// } - //************************************************************************* std::ostream& operator <<(std::ostream& os, const DataNDC::iterator& itr) { diff --git a/test/test_set.cpp b/test/test_set.cpp index 98422f6f6..773aeea5a 100644 --- a/test/test_set.cpp +++ b/test/test_set.cpp @@ -204,6 +204,23 @@ namespace CHECK(data.size() == MAX_SIZE); CHECK(!data.empty()); + + bool isEqual = std::equal(data.begin(), data.end(), compare_data.begin()); + CHECK(isEqual); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_initializer_list) + { + Compare_Data compare_data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + + Data data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + + CHECK_EQUAL(compare_data.size(), data.size()); + CHECK(!data.empty()); + + bool isEqual = std::equal(data.begin(), data.end(), compare_data.begin()); + CHECK(isEqual); } //************************************************************************* diff --git a/test/test_string_char.cpp b/test/test_string_char.cpp index 1e8968dd4..d93d6d4d9 100644 --- a/test/test_string_char.cpp +++ b/test/test_string_char.cpp @@ -217,6 +217,16 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_construct_initializer_list) + { + Compare_Text compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; + Text text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assignment) { diff --git a/test/test_string_u16.cpp b/test/test_string_u16.cpp index 09b932934..aeff4cc2b 100644 --- a/test/test_string_u16.cpp +++ b/test/test_string_u16.cpp @@ -216,6 +216,16 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_construct_initializer_list) + { + Compare_Text compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; + Text text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assignment) { diff --git a/test/test_string_u32.cpp b/test/test_string_u32.cpp index ce1579b08..03d0912f9 100644 --- a/test/test_string_u32.cpp +++ b/test/test_string_u32.cpp @@ -216,6 +216,16 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_construct_initializer_list) + { + Compare_Text compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; + Text text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assignment) { diff --git a/test/test_string_wchar_t.cpp b/test/test_string_wchar_t.cpp index 191f53d33..1ae194aa6 100644 --- a/test/test_string_wchar_t.cpp +++ b/test/test_string_wchar_t.cpp @@ -216,6 +216,16 @@ namespace CHECK(is_equal); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_construct_initializer_list) + { + Compare_Text compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; + Text text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assignment) { diff --git a/test/test_vector.cpp b/test/test_vector.cpp index 23770eac4..e581faf05 100644 --- a/test/test_vector.cpp +++ b/test/test_vector.cpp @@ -142,6 +142,16 @@ namespace CHECK(!data.empty()); } + //************************************************************************* + TEST(test_constructor_initializer_list) + { + Compare_Data compare_data = { 0, 1, 2, 3 }; + Data data = { 0, 1, 2, 3 }; + + CHECK_EQUAL(compare_data.size(), data.size()); + CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin())); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { diff --git a/test/test_vector_non_trivial.cpp b/test/test_vector_non_trivial.cpp index 88c1e7f49..2d1d89e32 100644 --- a/test/test_vector_non_trivial.cpp +++ b/test/test_vector_non_trivial.cpp @@ -167,6 +167,16 @@ namespace CHECK(!data.empty()); } + //************************************************************************* + TEST(test_constructor_initializer_list) + { + CompareDataNDC compare_data = { NDC("0"), NDC("1"), NDC("2"), NDC("3") }; + DataNDC data = { NDC("0"), NDC("1"), NDC("2"), NDC("3") }; + + CHECK_EQUAL(compare_data.size(), data.size()); + CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin())); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { diff --git a/test/test_vector_pointer.cpp b/test/test_vector_pointer.cpp index 232faa212..970d22638 100644 --- a/test/test_vector_pointer.cpp +++ b/test/test_vector_pointer.cpp @@ -152,6 +152,22 @@ namespace CHECK(data.size() == SIZE); CHECK(!data.empty()); + CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin())); + } + + //************************************************************************* + TEST(test_constructor_initializer_list) + { + int a = 0; + int b = 1; + int c = 3; + int d = 4; + + Compare_Data compare_data = { &a, &b, &c, &d }; + Data data = { &a, &b, &c, &d }; + + CHECK_EQUAL(compare_data.size(), data.size()); + CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin())); } //*************************************************************************