diff --git a/conanfile.py b/conanfile.py index 79a6824d..354a25f6 100755 --- a/conanfile.py +++ b/conanfile.py @@ -20,7 +20,7 @@ class EmbeddedTemplateLibraryConan(ConanFile): name = "embedded-template-library" version = get_version_from_git_tag() license = "MIT" - author = "John Wellbelove " + author = "John Wellbelove " url = "https://github.com/ETLCPP/etl" description = "A C++ template library for embedded applications" topics = ("embedded", "template", "container") diff --git a/include/etl/array_view.h b/include/etl/array_view.h index a682b665..2cc99288 100644 --- a/include/etl/array_view.h +++ b/include/etl/array_view.h @@ -115,8 +115,8 @@ namespace etl /// Default constructor. //************************************************************************* ETL_CONSTEXPR array_view() - : mbegin(nullptr), - mend(nullptr) + : mbegin(ETL_NULLPTR), + mend(ETL_NULLPTR) { } @@ -391,7 +391,7 @@ namespace etl //************************************************************************* reference at(const size_t i) { - ETL_ASSERT((mbegin != nullptr && mend != nullptr), ETL_ERROR(array_view_uninitialised)); + ETL_ASSERT((mbegin != ETL_NULLPTR && mend != ETL_NULLPTR), ETL_ERROR(array_view_uninitialised)); ETL_ASSERT(i < size(), ETL_ERROR(array_view_bounds)); return mbegin[i]; } @@ -401,7 +401,7 @@ namespace etl //************************************************************************* const_reference at(const size_t i) const { - ETL_ASSERT((mbegin != nullptr && mend != nullptr), ETL_ERROR(array_view_uninitialised)); + ETL_ASSERT((mbegin != ETL_NULLPTR && mend != ETL_NULLPTR), ETL_ERROR(array_view_uninitialised)); ETL_ASSERT(i < size(), ETL_ERROR(array_view_bounds)); return mbegin[i]; } diff --git a/include/etl/atomic/atomic_gcc_sync.h b/include/etl/atomic/atomic_gcc_sync.h index da86e89e..685e489c 100644 --- a/include/etl/atomic/atomic_gcc_sync.h +++ b/include/etl/atomic/atomic_gcc_sync.h @@ -442,7 +442,7 @@ namespace etl public: atomic() - : value(nullptr) + : value(ETL_NULLPTR) { } diff --git a/include/etl/atomic/atomic_llvm_sync.h b/include/etl/atomic/atomic_llvm_sync.h index 50e0be01..cc10d32d 100644 --- a/include/etl/atomic/atomic_llvm_sync.h +++ b/include/etl/atomic/atomic_llvm_sync.h @@ -435,7 +435,7 @@ SOFTWARE. // public: // // atomic() -// : value(nullptr) +// : value(ETL_NULLPTR) // { // } // diff --git a/include/etl/atomic/atomic_std.h b/include/etl/atomic/atomic_std.h index 9c160f71..45e69304 100644 --- a/include/etl/atomic/atomic_std.h +++ b/include/etl/atomic/atomic_std.h @@ -343,7 +343,7 @@ namespace etl public: atomic() - : value(nullptr) + : value(ETL_NULLPTR) { } diff --git a/include/etl/binary.h b/include/etl/binary.h index 48961fa2..e4a9f0a3 100644 --- a/include/etl/binary.h +++ b/include/etl/binary.h @@ -390,6 +390,21 @@ namespace etl return TResult(unsigned_v_t(value) * (unsigned_r_t(~unsigned_r_t(0U)) / unsigned_v_t(~unsigned_v_t(0U)))); } + //*************************************************************************** + /// Fills a value with a bit pattern. Partial compile time. + ///\ingroup binary + //*************************************************************************** + template + ETL_CONSTEXPR TResult binary_fill() + { + ETL_STATIC_ASSERT(sizeof(TResult) >= sizeof(TValue), "Result must be at least as large as the fill value"); + + typedef typename etl::make_unsigned::type unsigned_r_t; + typedef typename etl::make_unsigned::type unsigned_v_t; + + return TResult(unsigned_v_t(N) * (unsigned_r_t(~unsigned_r_t(0U)) / unsigned_v_t(~unsigned_v_t(0U)))); + } + #if ETL_8BIT_SUPPORT //*************************************************************************** /// Detects the presence of zero bytes. @@ -405,6 +420,20 @@ namespace etl return (temp != 0U); } + //*************************************************************************** + /// Detects the presence of zero bytes. Partial compile time. + ///\ingroup binary + //*************************************************************************** + template + ETL_CONSTEXPR14 bool has_zero_byte() + { + typedef typename etl::make_unsigned::type unsigned_t; + const unsigned_t mask = etl::binary_fill(0x7FU); + const unsigned_t temp = unsigned_t(~((((unsigned_t(N) & mask) + mask) | unsigned_t(N)) | mask)); + + return (temp != 0U); + } + //*************************************************************************** /// Detects the presence of a byte of value N. Run time. ///\ingroup binary @@ -416,7 +445,7 @@ namespace etl } //*************************************************************************** - /// Detects the presence of a byte of value N. Partial time. + /// Detects the presence of a byte of value N. Partial compile time. ///\ingroup binary //*************************************************************************** template diff --git a/include/etl/bit_stream.h b/include/etl/bit_stream.h index 88cffc54..894b9b20 100644 --- a/include/etl/bit_stream.h +++ b/include/etl/bit_stream.h @@ -56,7 +56,7 @@ namespace etl /// Default constructor. //*************************************************************************** bit_stream() - : pdata(nullptr), + : pdata(ETL_NULLPTR), length(0U) { restart(); @@ -163,7 +163,7 @@ namespace etl { bool success = false; - if (pdata != nullptr) + if (pdata != ETL_NULLPTR) { if (bits_remaining > 0) { @@ -234,7 +234,7 @@ namespace etl { bool success = false; - if (pdata != nullptr) + if (pdata != ETL_NULLPTR) { // Do we have enough bits? if (bits_remaining > 0) @@ -257,7 +257,7 @@ namespace etl bool success = false; uint_least8_t bits = width; - if (pdata != nullptr) + if (pdata != ETL_NULLPTR) { // Do we have enough bits? if (bits_remaining >= width) @@ -297,7 +297,7 @@ namespace etl { bool success = false; - if (pdata != nullptr) + if (pdata != ETL_NULLPTR) { uint_least8_t width = CHAR_BIT * sizeof(T); @@ -372,7 +372,7 @@ namespace etl { bool success = false; - if (pdata != nullptr) + if (pdata != ETL_NULLPTR) { // Do we have enough bits? if (bits_remaining >= width) @@ -406,7 +406,7 @@ namespace etl { bool success = false; - if (pdata != nullptr) + if (pdata != ETL_NULLPTR) { // Do we have enough bits? if (bits_remaining >= width) diff --git a/include/etl/bitset.h b/include/etl/bitset.h index 9d71f50d..9be12008 100644 --- a/include/etl/bitset.h +++ b/include/etl/bitset.h @@ -83,7 +83,7 @@ namespace etl }; //*************************************************************************** - /// Bitset nullptr exception. + /// Bitset null pointer exception. ///\ingroup bitset //*************************************************************************** class bitset_nullptr : public bitset_exception @@ -91,7 +91,7 @@ namespace etl public: bitset_nullptr(string_type file_name_, numeric_type line_number_) - : bitset_exception(ETL_ERROR_TEXT("bitset:nullptr", ETL_FILE"A"), file_name_, line_number_) + : bitset_exception(ETL_ERROR_TEXT("bitset:null pointer", ETL_FILE"A"), file_name_, line_number_) { } }; @@ -195,7 +195,7 @@ namespace etl /// Default constructor. //******************************* bit_reference() - : p_bitset(nullptr), + : p_bitset(ETL_NULLPTR), position(0) { } diff --git a/include/etl/callback_service.h b/include/etl/callback_service.h index cd098d5d..6a85f116 100644 --- a/include/etl/callback_service.h +++ b/include/etl/callback_service.h @@ -56,7 +56,7 @@ namespace etl //************************************************************************* callback_service() : unhandled_callback(*this), - p_unhandled(nullptr) + p_unhandled(ETL_NULLPTR) { lookup.fill(&unhandled_callback); } @@ -137,7 +137,7 @@ namespace etl //************************************************************************* void unhandled(size_t id) { - if (p_unhandled != nullptr) + if (p_unhandled != ETL_NULLPTR) { (*p_unhandled)(id); } diff --git a/include/etl/callback_timer.h b/include/etl/callback_timer.h index 07c084e6..6e632c9f 100644 --- a/include/etl/callback_timer.h +++ b/include/etl/callback_timer.h @@ -96,7 +96,7 @@ namespace etl //******************************************* callback_timer_data() - : p_callback(nullptr), + : p_callback(ETL_NULLPTR), period(0), delta(etl::timer::state::INACTIVE), id(etl::timer::id::NO_TIMER), @@ -577,7 +577,7 @@ namespace etl active_list.insert(timer.id); } - if (timer.p_callback != nullptr) + if (timer.p_callback != ETL_NULLPTR) { if (timer.cbk_type == callback_timer_data::C_CALLBACK) { diff --git a/include/etl/delegate.h b/include/etl/delegate.h index 2c92281a..2ff012a5 100644 --- a/include/etl/delegate.h +++ b/include/etl/delegate.h @@ -119,7 +119,7 @@ namespace etl template static delegate create() { - return delegate(nullptr, function_stub); + return delegate(ETL_NULLPTR, function_stub); } //************************************************************************* @@ -238,7 +238,7 @@ namespace etl //************************************************************************* bool is_valid() const { - return invocation.stub != nullptr; + return invocation.stub != ETL_NULLPTR; } //************************************************************************* @@ -280,8 +280,8 @@ namespace etl } //*********************************************************************** - void* object = nullptr; - stub_type stub = nullptr; + void* object = ETL_NULLPTR; + stub_type stub = ETL_NULLPTR; }; //************************************************************************* @@ -298,7 +298,7 @@ namespace etl //************************************************************************* delegate(stub_type stub) { - invocation.object = nullptr; + invocation.object = ETL_NULLPTR; invocation.stub = stub; } diff --git a/include/etl/error_handler.h b/include/etl/error_handler.h index 6d7b9a61..1afe25a3 100644 --- a/include/etl/error_handler.h +++ b/include/etl/error_handler.h @@ -41,6 +41,7 @@ SOFTWARE. #include "platform.h" #include "exception.h" #include "function.h" +#include "nullptr.h" namespace etl { @@ -53,7 +54,7 @@ namespace etl }; template - etl::ifunction* wrapper::p_ifunction = nullptr; + etl::ifunction* wrapper::p_ifunction = ETL_NULLPTR; } //*************************************************************************** @@ -102,7 +103,7 @@ namespace etl //***************************************************************************** static void error(const etl::exception& e) { - if (private_error_handler::wrapper::p_ifunction != nullptr) + if (private_error_handler::wrapper::p_ifunction != ETL_NULLPTR) { (*private_error_handler::wrapper::p_ifunction)(e); } diff --git a/include/etl/forward_list.h b/include/etl/forward_list.h index 86aaa259..31a38b9d 100644 --- a/include/etl/forward_list.h +++ b/include/etl/forward_list.h @@ -153,7 +153,7 @@ namespace etl struct node_t { node_t() - : next(nullptr) + : next(ETL_NULLPTR) { } @@ -184,7 +184,7 @@ namespace etl node_t* p_node = start_node.next; - while (p_node != nullptr) + while (p_node != ETL_NULLPTR) { ++count; p_node = p_node->next; @@ -194,7 +194,7 @@ namespace etl } else { - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(forward_list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(forward_list_no_pool)); return p_node_pool->size(); } } @@ -218,7 +218,7 @@ namespace etl } else { - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(forward_list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(forward_list_no_pool)); return p_node_pool->empty(); } } @@ -228,7 +228,7 @@ namespace etl //************************************************************************* bool full() const { - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(forward_list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(forward_list_no_pool)); return p_node_pool->full(); } @@ -238,7 +238,7 @@ namespace etl //************************************************************************* size_t available() const { - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(forward_list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(forward_list_no_pool)); return p_node_pool->available(); } @@ -256,9 +256,9 @@ namespace etl node_t* p_current = p_last->next; node_t* p_next = p_current->next; - p_current->next = nullptr; + p_current->next = ETL_NULLPTR; - while (p_next != nullptr) + while (p_next != ETL_NULLPTR) { p_last = p_current; p_current = p_next; @@ -276,7 +276,7 @@ namespace etl /// The constructor that is called from derived classes. //************************************************************************* forward_list_base(bool pool_is_shared_) - : p_node_pool(nullptr), + : p_node_pool(ETL_NULLPTR), MAX_SIZE(0), pool_is_shared(pool_is_shared_) { @@ -412,7 +412,7 @@ namespace etl friend class const_iterator; iterator() - : p_node(nullptr) + : p_node(ETL_NULLPTR) { } @@ -500,7 +500,7 @@ namespace etl friend class iforward_list; const_iterator() - : p_node(nullptr) + : p_node(ETL_NULLPTR) { } @@ -687,7 +687,7 @@ namespace etl data_node_t& data_node = allocate_data_node(*first++); join(p_last_node, &data_node); - data_node.next = nullptr; + data_node.next = ETL_NULLPTR; p_last_node = &data_node; } } @@ -708,7 +708,7 @@ namespace etl { data_node_t& data_node = allocate_data_node(value); join(p_last_node, &data_node); - data_node.next = nullptr; + data_node.next = ETL_NULLPTR; p_last_node = &data_node; } } @@ -1058,7 +1058,7 @@ namespace etl p_first = p_next; // Move to the next node. } - if (p_next == nullptr) + if (p_next == ETL_NULLPTR) { return end(); } @@ -1160,7 +1160,7 @@ namespace etl node_t* last = get_head(); node_t* current = last->next; - while (current != nullptr) + while (current != ETL_NULLPTR) { // Is this value the same as the last? if (isEqual(data_cast(current)->value, data_cast(last)->value)) @@ -1305,7 +1305,7 @@ namespace etl p_tail = p_node; } - p_tail.p_node->next = nullptr; + p_tail.p_node->next = ETL_NULLPTR; } // Now left has stepped `list_size' places along, and right has too. @@ -1420,7 +1420,7 @@ namespace etl { if (etl::is_trivially_destructible::value && !has_shared_pool()) { - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(forward_list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(forward_list_no_pool)); p_node_pool->release_all(); ETL_RESET_DEBUG_COUNT } @@ -1430,7 +1430,7 @@ namespace etl node_t* p_next; // Erase the ones in between. - while (p_first != nullptr) + while (p_first != ETL_NULLPTR) { p_next = p_first->next; // Remember the next node. destroy_data_node(static_cast(*p_first)); // Destroy the pool object. @@ -1439,7 +1439,7 @@ namespace etl } } - start_node.next = nullptr; + start_node.next = ETL_NULLPTR; } //************************************************************************* @@ -1490,7 +1490,7 @@ namespace etl data_node_t& data_node = this->allocate_data_node(etl::move(*first++)); join(p_last_node, &data_node); - data_node.next = nullptr; + data_node.next = ETL_NULLPTR; p_last_node = &data_node; } @@ -1541,7 +1541,7 @@ namespace etl // The node to erase. node_t* p_node = node.next; - if (p_node != nullptr) + if (p_node != ETL_NULLPTR) { // Disconnect the node from the forward_list. join(&node, p_node->next); @@ -1853,7 +1853,7 @@ namespace etl void set_pool(etl::ipool& pool) { // Clear the list of any current elements. - if (this->get_node_pool() != nullptr) + if (this->get_node_pool() != ETL_NULLPTR) { this->clear(); } diff --git a/include/etl/fsm.h b/include/etl/fsm.h index 84bb34c7..0c788923 100644 --- a/include/etl/fsm.h +++ b/include/etl/fsm.h @@ -159,7 +159,7 @@ namespace etl //******************************************* ifsm_state(etl::fsm_state_id_t state_id_) : state_id(state_id_), - p_context(nullptr) + p_context(ETL_NULLPTR) { } @@ -212,7 +212,7 @@ namespace etl //******************************************* fsm(etl::message_router_id_t id) : imessage_router(id), - p_state(nullptr) + p_state(ETL_NULLPTR) { } @@ -229,7 +229,7 @@ namespace etl for (etl::fsm_state_id_t i = 0; i < size; ++i) { - ETL_ASSERT((state_list[i] != nullptr), ETL_ERROR(etl::fsm_null_state_exception)); + ETL_ASSERT((state_list[i] != ETL_NULLPTR), ETL_ERROR(etl::fsm_null_state_exception)); state_list[i]->set_fsm_context(*this); } } @@ -243,10 +243,10 @@ namespace etl void start(bool call_on_enter_state = true) { // Can only be started once. - if (p_state == nullptr) + if (p_state == ETL_NULLPTR) { p_state = state_list[0]; - ETL_ASSERT(p_state != nullptr, ETL_ERROR(etl::fsm_null_state_exception)); + ETL_ASSERT(p_state != ETL_NULLPTR, ETL_ERROR(etl::fsm_null_state_exception)); if (call_on_enter_state) { @@ -327,7 +327,7 @@ namespace etl //******************************************* etl::fsm_state_id_t get_state_id() const { - ETL_ASSERT(p_state != nullptr, ETL_ERROR(etl::fsm_null_state_exception)); + ETL_ASSERT(p_state != ETL_NULLPTR, ETL_ERROR(etl::fsm_null_state_exception)); return p_state->get_state_id(); } @@ -336,7 +336,7 @@ namespace etl //******************************************* ifsm_state& get_state() { - ETL_ASSERT(p_state != nullptr, ETL_ERROR(etl::fsm_null_state_exception)); + ETL_ASSERT(p_state != ETL_NULLPTR, ETL_ERROR(etl::fsm_null_state_exception)); return *p_state; } @@ -345,7 +345,7 @@ namespace etl //******************************************* const ifsm_state& get_state() const { - ETL_ASSERT(p_state != nullptr, ETL_ERROR(etl::fsm_null_state_exception)); + ETL_ASSERT(p_state != ETL_NULLPTR, ETL_ERROR(etl::fsm_null_state_exception)); return *p_state; } @@ -354,7 +354,7 @@ namespace etl //******************************************* bool is_started() const { - return p_state != nullptr; + return p_state != ETL_NULLPTR; } //******************************************* @@ -363,12 +363,12 @@ namespace etl //******************************************* void reset(bool call_on_exit_state = false) { - if ((p_state != nullptr) && call_on_exit_state) + if ((p_state != ETL_NULLPTR) && call_on_exit_state) { p_state->on_exit_state(); } - p_state = nullptr; + p_state = ETL_NULLPTR; } //******************************************** diff --git a/include/etl/fsm_generator.h b/include/etl/fsm_generator.h index 4dbe9715..1286a605 100644 --- a/include/etl/fsm_generator.h +++ b/include/etl/fsm_generator.h @@ -171,7 +171,7 @@ namespace etl //******************************************* ifsm_state(etl::fsm_state_id_t state_id_) : state_id(state_id_), - p_context(nullptr) + p_context(ETL_NULLPTR) { } @@ -224,7 +224,7 @@ namespace etl //******************************************* fsm(etl::message_router_id_t id) : imessage_router(id), - p_state(nullptr) + p_state(ETL_NULLPTR) { } @@ -241,7 +241,7 @@ namespace etl for (etl::fsm_state_id_t i = 0; i < size; ++i) { - ETL_ASSERT((state_list[i] != nullptr), ETL_ERROR(etl::fsm_null_state_exception)); + ETL_ASSERT((state_list[i] != ETL_NULLPTR), ETL_ERROR(etl::fsm_null_state_exception)); state_list[i]->set_fsm_context(*this); } } @@ -255,10 +255,10 @@ namespace etl void start(bool call_on_enter_state = true) { // Can only be started once. - if (p_state == nullptr) + if (p_state == ETL_NULLPTR) { p_state = state_list[0]; - ETL_ASSERT(p_state != nullptr, ETL_ERROR(etl::fsm_null_state_exception)); + ETL_ASSERT(p_state != ETL_NULLPTR, ETL_ERROR(etl::fsm_null_state_exception)); if (call_on_enter_state) { @@ -339,7 +339,7 @@ namespace etl //******************************************* etl::fsm_state_id_t get_state_id() const { - ETL_ASSERT(p_state != nullptr, ETL_ERROR(etl::fsm_null_state_exception)); + ETL_ASSERT(p_state != ETL_NULLPTR, ETL_ERROR(etl::fsm_null_state_exception)); return p_state->get_state_id(); } @@ -348,7 +348,7 @@ namespace etl //******************************************* ifsm_state& get_state() { - ETL_ASSERT(p_state != nullptr, ETL_ERROR(etl::fsm_null_state_exception)); + ETL_ASSERT(p_state != ETL_NULLPTR, ETL_ERROR(etl::fsm_null_state_exception)); return *p_state; } @@ -357,7 +357,7 @@ namespace etl //******************************************* const ifsm_state& get_state() const { - ETL_ASSERT(p_state != nullptr, ETL_ERROR(etl::fsm_null_state_exception)); + ETL_ASSERT(p_state != ETL_NULLPTR, ETL_ERROR(etl::fsm_null_state_exception)); return *p_state; } @@ -366,7 +366,7 @@ namespace etl //******************************************* bool is_started() const { - return p_state != nullptr; + return p_state != ETL_NULLPTR; } //******************************************* @@ -375,12 +375,12 @@ namespace etl //******************************************* void reset(bool call_on_exit_state = false) { - if ((p_state != nullptr) && call_on_exit_state) + if ((p_state != ETL_NULLPTR) && call_on_exit_state) { p_state->on_exit_state(); } - p_state = nullptr; + p_state = ETL_NULLPTR; } //******************************************** diff --git a/include/etl/indirect_vector.h b/include/etl/indirect_vector.h index 6d62ff86..bb9e5e1c 100644 --- a/include/etl/indirect_vector.h +++ b/include/etl/indirect_vector.h @@ -972,7 +972,7 @@ namespace etl // Make space for the new lookup pointers. typename etl::ivector::iterator lookup_itr = position.lookup_itr; - lookup.insert(lookup_itr, n, nullptr); + lookup.insert(lookup_itr, n, ETL_NULLPTR); while (n-- != 0U) { @@ -997,7 +997,7 @@ namespace etl // Make space for the new lookup pointers. typename etl::ivector::iterator lookup_itr = position.lookup_itr; - lookup.insert(lookup_itr, count, nullptr); + lookup.insert(lookup_itr, count, ETL_NULLPTR); while (first != last) { diff --git a/include/etl/intrusive_forward_list.h b/include/etl/intrusive_forward_list.h index 9a70e4c8..28a703c5 100644 --- a/include/etl/intrusive_forward_list.h +++ b/include/etl/intrusive_forward_list.h @@ -200,7 +200,7 @@ namespace etl return; } - link_type* first = nullptr; // To keep first link + link_type* first = ETL_NULLPTR; // To keep first link link_type* second = start_link.etl_next; // To keep second link link_type* track = start_link.etl_next; // Track the list @@ -220,7 +220,7 @@ namespace etl //************************************************************************* bool empty() const { - return start_link.etl_next == nullptr; + return start_link.etl_next == ETL_NULLPTR; } //************************************************************************* @@ -249,7 +249,7 @@ namespace etl //************************************************************************* bool is_trivial_list() const { - return (start_link.link_type::etl_next == nullptr) || (start_link.link_type::etl_next->etl_next == nullptr); + return (start_link.link_type::etl_next == ETL_NULLPTR) || (start_link.link_type::etl_next->etl_next == ETL_NULLPTR); } //************************************************************************* @@ -269,7 +269,7 @@ namespace etl { link_type* p_next = link.etl_next; - if (p_next != nullptr) + if (p_next != ETL_NULLPTR) { etl::unlink_after(link); --current_size; @@ -297,7 +297,7 @@ namespace etl //************************************************************************* void initialise() { - start_link.etl_next = nullptr; + start_link.etl_next = ETL_NULLPTR; current_size = 0; } }; @@ -336,7 +336,7 @@ namespace etl friend class const_iterator; iterator() - : p_value(nullptr) + : p_value(ETL_NULLPTR) { } @@ -426,7 +426,7 @@ namespace etl friend class intrusive_forward_list; const_iterator() - : p_value(nullptr) + : p_value(ETL_NULLPTR) { } @@ -661,7 +661,7 @@ namespace etl // Join the ends. etl::link(p_first, p_last); - if (p_next == nullptr) + if (p_next == ETL_NULLPTR) { return end(); } @@ -691,7 +691,7 @@ namespace etl link_type* last = this->get_head(); link_type* current = last->etl_next; - while (current != nullptr) + while (current != ETL_NULLPTR) { // Is this value the same as the last? if (isEqual(*static_cast(current), *static_cast(last))) @@ -835,7 +835,7 @@ namespace etl i_tail = i_link; } - i_tail.p_value->link_type::etl_next = nullptr; + i_tail.p_value->link_type::etl_next = ETL_NULLPTR; } // Now left has stepped `list_size' places along, and right has too. @@ -921,7 +921,7 @@ namespace etl etl::link(before, first); link_type* last = &before; - while (last->link_type::etl_next != nullptr) + while (last->link_type::etl_next != ETL_NULLPTR) { last = last->link_type::etl_next; } @@ -1005,11 +1005,11 @@ namespace etl #endif value_type* other_begin = static_cast(other.get_head()); - value_type* other_terminal = nullptr; + value_type* other_terminal = ETL_NULLPTR; value_type* before = static_cast(&this->start_link); value_type* before_next = get_next(before); - value_type* terminal = nullptr; + value_type* terminal = ETL_NULLPTR; while ((before->link_type::etl_next != terminal) && (other_begin != other_terminal)) { diff --git a/include/etl/intrusive_links.h b/include/etl/intrusive_links.h index c8149514..ad6a9e3c 100644 --- a/include/etl/intrusive_links.h +++ b/include/etl/intrusive_links.h @@ -97,12 +97,12 @@ namespace etl void clear() { - etl_next = nullptr; + etl_next = ETL_NULLPTR; } bool is_linked() const { - return etl_next != nullptr; + return etl_next != ETL_NULLPTR; } forward_link* etl_next; @@ -130,7 +130,7 @@ namespace etl typename etl::enable_if >::value, void>::type link(TLink* lhs, TLink* rhs) { - if (lhs != nullptr) + if (lhs != ETL_NULLPTR) { lhs->etl_next = rhs; } @@ -141,9 +141,9 @@ namespace etl typename etl::enable_if >::value, void>::type link_splice(TLink* lhs, TLink* rhs) { - if (lhs != nullptr) + if (lhs != ETL_NULLPTR) { - if (rhs != nullptr) + if (rhs != ETL_NULLPTR) { rhs->etl_next = lhs->etl_next; } @@ -165,7 +165,7 @@ namespace etl typename etl::enable_if >::value, void>::type link_splice(TLink& lhs, TLink* rhs) { - if (rhs != nullptr) + if (rhs != ETL_NULLPTR) { rhs->etl_next = lhs.etl_next; } @@ -178,7 +178,7 @@ namespace etl typename etl::enable_if >::value, void>::type link(TLink* lhs, TLink& rhs) { - if (lhs != nullptr) + if (lhs != ETL_NULLPTR) { lhs->etl_next = &rhs; } @@ -189,7 +189,7 @@ namespace etl typename etl::enable_if >::value, void>::type link_splice(TLink* lhs, TLink& rhs) { - if (lhs != nullptr) + if (lhs != ETL_NULLPTR) { rhs.etl_next = lhs->etl_next; lhs->etl_next = &rhs; @@ -210,14 +210,14 @@ namespace etl typename etl::enable_if >::value, void>::type link_splice(TLink* lhs, TLink& first, TLink& last) { - if (lhs != nullptr) + if (lhs != ETL_NULLPTR) { last.etl_next = lhs->etl_next; lhs->etl_next = &first; } else { - last.etl_next = nullptr; + last.etl_next = ETL_NULLPTR; } } @@ -226,7 +226,7 @@ namespace etl typename etl::enable_if >::value, void>::type unlink_after(TLink& node) { - if (node.etl_next != nullptr) + if (node.etl_next != ETL_NULLPTR) { TLink* unlinked_node = node.etl_next; node.etl_next = unlinked_node->etl_next; @@ -254,13 +254,13 @@ namespace etl void clear() { - etl_previous = nullptr; - etl_next = nullptr; + etl_previous = ETL_NULLPTR; + etl_next = ETL_NULLPTR; } bool is_linked() const { - return (etl_previous != nullptr) || (etl_next != nullptr); + return (etl_previous != ETL_NULLPTR) || (etl_next != ETL_NULLPTR); } void reverse() @@ -276,13 +276,13 @@ namespace etl void unlink() { // Connect the previous link with the next. - if (etl_previous != nullptr) + if (etl_previous != ETL_NULLPTR) { etl_previous->etl_next = etl_next; } // Connect the next link with the previous. - if (etl_next != nullptr) + if (etl_next != ETL_NULLPTR) { etl_next->etl_previous = etl_previous; } @@ -306,7 +306,7 @@ namespace etl rhs.etl_next = lhs.etl_next; rhs.etl_previous = &lhs; - if (lhs.etl_next != nullptr) + if (lhs.etl_next != ETL_NULLPTR) { lhs.etl_next->etl_previous = &rhs; } @@ -319,12 +319,12 @@ namespace etl typename etl::enable_if >::value, void>::type link(TLink* lhs, TLink* rhs) { - if (lhs != nullptr) + if (lhs != ETL_NULLPTR) { lhs->etl_next = rhs; } - if (rhs != nullptr) + if (rhs != ETL_NULLPTR) { rhs->etl_previous = lhs; } @@ -335,9 +335,9 @@ namespace etl typename etl::enable_if >::value, void>::type link_splice(TLink* lhs, TLink* rhs) { - if (rhs != nullptr) + if (rhs != ETL_NULLPTR) { - if (lhs != nullptr) + if (lhs != ETL_NULLPTR) { rhs->etl_next = lhs->etl_next; } @@ -345,9 +345,9 @@ namespace etl rhs->etl_previous = lhs; } - if (lhs != nullptr) + if (lhs != ETL_NULLPTR) { - if (lhs->etl_next != nullptr) + if (lhs->etl_next != ETL_NULLPTR) { lhs->etl_next->etl_previous = rhs; } @@ -363,7 +363,7 @@ namespace etl { lhs.etl_next = rhs; - if (rhs != nullptr) + if (rhs != ETL_NULLPTR) { rhs->etl_previous = &lhs; } @@ -374,13 +374,13 @@ namespace etl typename etl::enable_if >::value, void>::type link_splice(TLink& lhs, TLink* rhs) { - if (rhs != nullptr) + if (rhs != ETL_NULLPTR) { rhs->etl_next = lhs.etl_next; rhs->etl_previous = &lhs; } - if (lhs.etl_next != nullptr) + if (lhs.etl_next != ETL_NULLPTR) { lhs.etl_next->etl_previous = rhs; } @@ -393,7 +393,7 @@ namespace etl typename etl::enable_if >::value, void>::type link(TLink* lhs, TLink& rhs) { - if (lhs != nullptr) + if (lhs != ETL_NULLPTR) { lhs->etl_next = &rhs; } @@ -406,16 +406,16 @@ namespace etl typename etl::enable_if >::value, void>::type link_splice(TLink* lhs, TLink& rhs) { - if (lhs != nullptr) + if (lhs != ETL_NULLPTR) { rhs.etl_next = lhs->etl_next; } rhs.etl_previous = lhs; - if (lhs != nullptr) + if (lhs != ETL_NULLPTR) { - if (lhs->etl_next != nullptr) + if (lhs->etl_next != ETL_NULLPTR) { lhs->etl_next->etl_previous = &rhs; } @@ -432,7 +432,7 @@ namespace etl last.etl_next = lhs.etl_next; first.etl_previous = &lhs; - if (last.etl_next != nullptr) + if (last.etl_next != ETL_NULLPTR) { last.etl_next->etl_previous = &last; } @@ -445,23 +445,23 @@ namespace etl typename etl::enable_if >::value, void>::type link_splice(TLink* lhs, TLink& first, TLink& last) { - if (lhs != nullptr) + if (lhs != ETL_NULLPTR) { last.etl_next = lhs->etl_next; } else { - last.etl_next = nullptr; + last.etl_next = ETL_NULLPTR; } first.etl_previous = lhs; - if (last.etl_next != nullptr) + if (last.etl_next != ETL_NULLPTR) { last.etl_next->etl_previous = &last; } - if (lhs != nullptr) + if (lhs != ETL_NULLPTR) { lhs->etl_next = &first; } @@ -486,12 +486,12 @@ namespace etl } else { - if (last.etl_next != nullptr) + if (last.etl_next != ETL_NULLPTR) { last.etl_next->etl_previous = first.etl_previous; } - if (first.etl_previous != nullptr) + if (first.etl_previous != ETL_NULLPTR) { first.etl_previous->etl_next = last.etl_next; } @@ -511,14 +511,14 @@ namespace etl void clear() { - etl_parent = nullptr; - etl_left = nullptr; - etl_right = nullptr; + etl_parent = ETL_NULLPTR; + etl_left = ETL_NULLPTR; + etl_right = ETL_NULLPTR; } bool is_linked() const { - return (etl_parent != nullptr) || (etl_left != nullptr) || (etl_right != nullptr); + return (etl_parent != ETL_NULLPTR) || (etl_left != ETL_NULLPTR) || (etl_right != ETL_NULLPTR); } tree_link* etl_parent; @@ -548,12 +548,12 @@ namespace etl typename etl::enable_if >::value, void>::type link_left(TLink* parent, TLink* leaf) { - if (parent != nullptr) + if (parent != ETL_NULLPTR) { parent->etl_left = leaf; } - if (leaf != nullptr) + if (leaf != ETL_NULLPTR) { leaf->etl_parent = parent; } @@ -563,12 +563,12 @@ namespace etl typename etl::enable_if >::value, void>::type link_right(TLink* parent, TLink* leaf) { - if (parent != nullptr) + if (parent != ETL_NULLPTR) { parent->etl_right = leaf; } - if (leaf != nullptr) + if (leaf != ETL_NULLPTR) { leaf->etl_parent = parent; } @@ -581,7 +581,7 @@ namespace etl { parent.etl_left = leaf; - if (leaf != nullptr) + if (leaf != ETL_NULLPTR) { leaf->etl_parent = &parent; } @@ -593,7 +593,7 @@ namespace etl { parent.etl_right = leaf; - if (leaf != nullptr) + if (leaf != ETL_NULLPTR) { leaf->etl_parent = &parent; } @@ -604,7 +604,7 @@ namespace etl typename etl::enable_if >::value, void>::type link_left(TLink* parent, TLink& leaf) { - if (parent != nullptr) + if (parent != ETL_NULLPTR) { parent->etl_left = &leaf; } @@ -616,7 +616,7 @@ namespace etl typename etl::enable_if >::value, void>::type link_right(TLink* parent, TLink& leaf) { - if (parent != nullptr) + if (parent != ETL_NULLPTR) { parent->etl_right = &leaf; } @@ -631,7 +631,7 @@ namespace etl { parent.etl_right = leaf.etl_left; - if (parent.etl_right != nullptr) + if (parent.etl_right != ETL_NULLPTR) { parent.etl_right->etl_parent = &parent; } @@ -647,7 +647,7 @@ namespace etl { parent.etl_left = leaf.etl_right; - if (parent.etl_left != nullptr) + if (parent.etl_left != ETL_NULLPTR) { parent.etl_left->etl_parent = &parent; } @@ -662,7 +662,7 @@ namespace etl typename etl::enable_if >::value, void>::type link_rotate_left(TLink* parent, TLink* leaf) { - if ((parent != nullptr) && (leaf != nullptr)) + if ((parent != ETL_NULLPTR) && (leaf != ETL_NULLPTR)) { link_rotate_left(*parent, *leaf); } @@ -672,7 +672,7 @@ namespace etl typename etl::enable_if >::value, void>::type link_rotate_right(TLink* parent, TLink* leaf) { - if ((parent != nullptr) && (leaf != nullptr)) + if ((parent != ETL_NULLPTR) && (leaf != ETL_NULLPTR)) { link_rotate_right(*parent, *leaf); } @@ -683,7 +683,7 @@ namespace etl typename etl::enable_if >::value, void>::type link_rotate_left(TLink& parent, TLink* leaf) { - if (leaf != nullptr) + if (leaf != ETL_NULLPTR) { link_rotate_left(parent, *leaf); } @@ -693,7 +693,7 @@ namespace etl typename etl::enable_if >::value, void>::type link_rotate_right(TLink& parent, TLink* leaf) { - if (leaf != nullptr) + if (leaf != ETL_NULLPTR) { link_rotate_right(parent, *leaf); } @@ -704,7 +704,7 @@ namespace etl typename etl::enable_if >::value, void>::type link_rotate_left(TLink* parent, TLink& leaf) { - if (parent != nullptr) + if (parent != ETL_NULLPTR) { link_rotate_left(*parent, leaf); } @@ -714,7 +714,7 @@ namespace etl typename etl::enable_if >::value, void>::type link_rotate_right(TLink* parent, TLink& leaf) { - if (parent != nullptr) + if (parent != ETL_NULLPTR) { link_rotate_right(*parent, leaf); } @@ -742,7 +742,7 @@ namespace etl typename etl::enable_if >::value, void>::type link_rotate(TLink* parent, TLink* leaf) { - if ((parent != nullptr) && (leaf != nullptr)) + if ((parent != ETL_NULLPTR) && (leaf != ETL_NULLPTR)) { if (parent->etl_left == leaf) { @@ -761,7 +761,7 @@ namespace etl typename etl::enable_if >::value, void>::type link_rotate(TLink& parent, TLink* leaf) { - if (leaf != nullptr) + if (leaf != ETL_NULLPTR) { if (parent.etl_left == leaf) { @@ -780,7 +780,7 @@ namespace etl typename etl::enable_if >::value, void>::type link_rotate(TLink* parent, TLink& leaf) { - if (parent != nullptr) + if (parent != ETL_NULLPTR) { if (parent->etl_left == &leaf) { diff --git a/include/etl/intrusive_list.h b/include/etl/intrusive_list.h index a2db6f06..0f802903 100644 --- a/include/etl/intrusive_list.h +++ b/include/etl/intrusive_list.h @@ -391,7 +391,7 @@ namespace etl friend class const_iterator; iterator() - : p_value(nullptr) + : p_value(ETL_NULLPTR) { } @@ -496,7 +496,7 @@ namespace etl friend class intrusive_list; const_iterator() - : p_value(nullptr) + : p_value(ETL_NULLPTR) { } diff --git a/include/etl/intrusive_queue.h b/include/etl/intrusive_queue.h index 1b0113ac..0ba8a882 100644 --- a/include/etl/intrusive_queue.h +++ b/include/etl/intrusive_queue.h @@ -92,7 +92,7 @@ namespace etl { value.clear(); - if (p_back != nullptr) + if (p_back != ETL_NULLPTR) { etl::link(p_back, value); } @@ -120,9 +120,9 @@ namespace etl p_front = p_next; // Now empty? - if (p_front == nullptr) + if (p_front == ETL_NULLPTR) { - p_back = nullptr; + p_back = ETL_NULLPTR; } --current_size; @@ -176,8 +176,8 @@ namespace etl /// Constructor //************************************************************************* intrusive_queue_base() - : p_front(nullptr), - p_back(nullptr), + : p_front(ETL_NULLPTR), + p_back(ETL_NULLPTR), current_size(0) { } diff --git a/include/etl/intrusive_stack.h b/include/etl/intrusive_stack.h index e2837f4e..2408705d 100644 --- a/include/etl/intrusive_stack.h +++ b/include/etl/intrusive_stack.h @@ -92,7 +92,7 @@ namespace etl { value.clear(); - if (p_top != nullptr) + if (p_top != ETL_NULLPTR) { etl::link(value, p_top); } @@ -134,11 +134,11 @@ namespace etl //************************************************************************* void reverse() { - link_type* previous = nullptr; + link_type* previous = ETL_NULLPTR; link_type* current = p_top; link_type* next; - while (current != nullptr) + while (current != ETL_NULLPTR) { next = current->etl_next; current->etl_next = previous; @@ -184,7 +184,7 @@ namespace etl /// Constructor //************************************************************************* intrusive_stack_base() - : p_top(nullptr), + : p_top(ETL_NULLPTR), current_size(0) { } diff --git a/include/etl/io_port.h b/include/etl/io_port.h index 09366c34..01c0ec1f 100644 --- a/include/etl/io_port.h +++ b/include/etl/io_port.h @@ -347,7 +347,7 @@ namespace etl /// Default constructor. io_port_rw() - : address(nullptr) + : address(ETL_NULLPTR) { } @@ -458,7 +458,7 @@ namespace etl /// Default constructor. io_port_ro() - : address(nullptr) + : address(ETL_NULLPTR) { } @@ -547,7 +547,7 @@ namespace etl /// Default constructor. io_port_wo() - : address(nullptr) + : address(ETL_NULLPTR) { } @@ -699,7 +699,7 @@ namespace etl /// Default constructor. io_port_wos() - : address(nullptr) + : address(ETL_NULLPTR) { } diff --git a/include/etl/list.h b/include/etl/list.h index 77bcf4db..e3acf5fe 100644 --- a/include/etl/list.h +++ b/include/etl/list.h @@ -172,8 +172,8 @@ namespace etl /// Constructor //*********************************************************************** node_t() - : previous(nullptr), - next(nullptr) + : previous(ETL_NULLPTR), + next(ETL_NULLPTR) { } @@ -255,7 +255,7 @@ namespace etl } else { - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); return p_node_pool->size(); } } @@ -271,7 +271,7 @@ namespace etl } else { - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); return p_node_pool->empty(); } } @@ -281,7 +281,7 @@ namespace etl //************************************************************************* bool full() const { - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); return p_node_pool->size() == MAX_SIZE; } @@ -291,7 +291,7 @@ namespace etl //************************************************************************* size_t available() const { - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); return max_size() - p_node_pool->size(); } @@ -360,7 +360,7 @@ namespace etl /// The constructor that is called from derived classes. //************************************************************************* explicit list_base(bool pool_is_shared_) - : p_node_pool(nullptr), + : p_node_pool(ETL_NULLPTR), MAX_SIZE(0), pool_is_shared(pool_is_shared_) { @@ -492,7 +492,7 @@ namespace etl friend class const_iterator; iterator() - : p_node(nullptr) + : p_node(ETL_NULLPTR) { } @@ -593,7 +593,7 @@ namespace etl friend class ilist; const_iterator() - : p_node(nullptr) + : p_node(ETL_NULLPTR) { } @@ -883,7 +883,7 @@ namespace etl #if defined(ETL_CHECK_PUSH_POP) ETL_ASSERT(!full(), ETL_ERROR(list_full)); #endif - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); data_node_t* p_data_node = create_data_node(); ::new (&(p_data_node->value)) T(etl::forward(args)...); @@ -900,7 +900,7 @@ namespace etl #if defined(ETL_CHECK_PUSH_POP) ETL_ASSERT(!full(), ETL_ERROR(list_full)); #endif - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); data_node_t* p_data_node = create_data_node(); ::new (&(p_data_node->value)) T(value1); @@ -917,7 +917,7 @@ namespace etl #if defined(ETL_CHECK_PUSH_POP) ETL_ASSERT(!full(), ETL_ERROR(list_full)); #endif - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); data_node_t* p_data_node = create_data_node(); ::new (&(p_data_node->value)) T(value1, value2); @@ -934,7 +934,7 @@ namespace etl #if defined(ETL_CHECK_PUSH_POP) ETL_ASSERT(!full(), ETL_ERROR(list_full)); #endif - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); data_node_t* p_data_node = create_data_node(); ::new (&(p_data_node->value)) T(value1, value2, value3); @@ -951,7 +951,7 @@ namespace etl #if defined(ETL_CHECK_PUSH_POP) ETL_ASSERT(!full(), ETL_ERROR(list_full)); #endif - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); data_node_t* p_data_node = create_data_node(); ::new (&(p_data_node->value)) T(value1, value2, value3, value4); @@ -1006,7 +1006,7 @@ namespace etl #if defined(ETL_CHECK_PUSH_POP) ETL_ASSERT(!full(), ETL_ERROR(list_full)); #endif - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); data_node_t* p_data_node = create_data_node(); ::new (&(p_data_node->value)) T(etl::forward(args)...); @@ -1020,7 +1020,7 @@ namespace etl #if defined(ETL_CHECK_PUSH_POP) ETL_ASSERT(!full(), ETL_ERROR(list_full)); #endif - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); data_node_t* p_data_node = create_data_node(); ::new (&(p_data_node->value)) T(value1); @@ -1034,7 +1034,7 @@ namespace etl #if defined(ETL_CHECK_PUSH_POP) ETL_ASSERT(!full(), ETL_ERROR(list_full)); #endif - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); data_node_t* p_data_node = create_data_node(); ::new (&(p_data_node->value)) T(value1, value2); @@ -1048,7 +1048,7 @@ namespace etl #if defined(ETL_CHECK_PUSH_POP) ETL_ASSERT(!full(), ETL_ERROR(list_full)); #endif - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); data_node_t* p_data_node = create_data_node(); ::new (&(p_data_node->value)) T(value1, value2, value3); @@ -1062,7 +1062,7 @@ namespace etl #if defined(ETL_CHECK_PUSH_POP) ETL_ASSERT(!full(), ETL_ERROR(list_full)); #endif - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); data_node_t* p_data_node = create_data_node(); ::new (&(p_data_node->value)) T(value1, value2, value3, value4); @@ -1119,7 +1119,7 @@ namespace etl iterator emplace(iterator position, Args && ... args) { ETL_ASSERT(!full(), ETL_ERROR(list_full)); - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); data_node_t* p_data_node = create_data_node(); ::new (&(p_data_node->value)) T(etl::forward(args)...); @@ -1133,7 +1133,7 @@ namespace etl iterator emplace(iterator position, const T1& value1) { ETL_ASSERT(!full(), ETL_ERROR(list_full)); - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); data_node_t* p_data_node = create_data_node(); ::new (&(p_data_node->value)) T(value1); @@ -1147,7 +1147,7 @@ namespace etl iterator emplace(iterator position, const T1& value1, const T2& value2) { ETL_ASSERT(!full(), ETL_ERROR(list_full)); - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); data_node_t* p_data_node = create_data_node(); ::new (&(p_data_node->value)) T(value1, value2); @@ -1161,7 +1161,7 @@ namespace etl iterator emplace(iterator position, const T1& value1, const T2& value2, const T3& value3) { ETL_ASSERT(!full(), ETL_ERROR(list_full)); - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); data_node_t* p_data_node = create_data_node(); ::new (&(p_data_node->value)) T(value1, value2, value3); @@ -1175,7 +1175,7 @@ namespace etl iterator emplace(iterator position, const T1& value1, const T2& value2, const T3& value3, const T4& value4) { ETL_ASSERT(!full(), ETL_ERROR(list_full)); - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); data_node_t* p_data_node = create_data_node(); ::new (&(p_data_node->value)) T(value1, value2, value3, value4); @@ -1802,13 +1802,13 @@ namespace etl //************************************************************************* void initialise() { - if (this->p_node_pool != nullptr) + if (this->p_node_pool != ETL_NULLPTR) { if (!empty()) { if (etl::is_trivially_destructible::value && !has_shared_pool()) { - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); p_node_pool->release_all(); ETL_RESET_DEBUG_COUNT; } @@ -1902,7 +1902,7 @@ namespace etl //************************************************************************* data_node_t& allocate_data_node(const_reference value) { - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); data_node_t* p_data_node = create_data_node(); ::new (&(p_data_node->value)) T(value); @@ -1917,7 +1917,7 @@ namespace etl //************************************************************************* data_node_t& allocate_data_node(rvalue_reference value) { - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); data_node_t* p_data_node = create_data_node(); ::new (&(p_data_node->value)) T(etl::move(value)); @@ -1941,7 +1941,7 @@ namespace etl //************************************************************************* void destroy_data_node(data_node_t& node) { - ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool)); + ETL_ASSERT(p_node_pool != ETL_NULLPTR, ETL_ERROR(list_no_pool)); node.value.~T(); p_node_pool->release(&node); ETL_DECREMENT_DEBUG_COUNT @@ -2276,7 +2276,7 @@ namespace etl void set_pool(etl::ipool& pool) { // Clear the list of any current elements. - if (this->get_node_pool() != nullptr) + if (this->get_node_pool() != ETL_NULLPTR) { this->clear(); } diff --git a/include/etl/map.h b/include/etl/map.h index 33d3077c..7dda0d17 100755 --- a/include/etl/map.h +++ b/include/etl/map.h @@ -220,8 +220,8 @@ namespace etl { weight = uint_least8_t(kNeither); dir = uint_least8_t(kNeither); - children[0] = nullptr; - children[1] = nullptr; + children[0] = ETL_NULLPTR; + children[1] = ETL_NULLPTR; } Node* children[2]; @@ -235,7 +235,7 @@ namespace etl map_base(size_type max_size_) : current_size(0) , CAPACITY(max_size_) - , root_node(nullptr) + , root_node(ETL_NULLPTR) { } @@ -587,14 +587,14 @@ namespace etl friend class const_iterator; iterator() - : p_map(nullptr) - , p_node(nullptr) + : p_map(ETL_NULLPTR) + , p_node(ETL_NULLPTR) { } iterator(imap& map) : p_map(&map) - , p_node(nullptr) + , p_node(ETL_NULLPTR) { } @@ -708,14 +708,14 @@ namespace etl friend class imap; const_iterator() - : p_map(nullptr) - , p_node(nullptr) + : p_map(ETL_NULLPTR) + , p_node(ETL_NULLPTR) { } const_iterator(const imap& map) : p_map(&map) - , p_node(nullptr) + , p_node(ETL_NULLPTR) { } @@ -938,7 +938,7 @@ namespace etl { iterator i_element = find(key); - ETL_ASSERT(i_element.p_node != nullptr, ETL_ERROR(map_out_of_bounds)); + ETL_ASSERT(i_element.p_node != ETL_NULLPTR, ETL_ERROR(map_out_of_bounds)); return i_element->second; } @@ -953,7 +953,7 @@ namespace etl { const_iterator i_element = find(key); - ETL_ASSERT(i_element.p_node != nullptr, ETL_ERROR(map_out_of_bounds)); + ETL_ASSERT(i_element.p_node != ETL_NULLPTR, ETL_ERROR(map_out_of_bounds)); return i_element->second; } @@ -1101,7 +1101,7 @@ namespace etl ETL_OR_STD::pair insert(const_reference value) { // Default to no inserted node - Node* inserted_node = nullptr; + Node* inserted_node = ETL_NULLPTR; bool inserted = false; ETL_ASSERT(!full(), ETL_ERROR(map_full)); @@ -1109,7 +1109,7 @@ namespace etl // Get next available free node Data_Node& node = allocate_data_node(value); - // Obtain the inserted node (might be nullptr if node was a duplicate) + // Obtain the inserted node (might be ETL_NULLPTR if node was a duplicate) inserted_node = insert_node(root_node, node); inserted = inserted_node == &node; @@ -1126,7 +1126,7 @@ namespace etl ETL_OR_STD::pair insert(rvalue_reference value) { // Default to no inserted node - Node* inserted_node = nullptr; + Node* inserted_node = ETL_NULLPTR; bool inserted = false; ETL_ASSERT(!full(), ETL_ERROR(map_full)); @@ -1134,7 +1134,7 @@ namespace etl // Get next available free node Data_Node& node = allocate_data_node(etl::move(value)); - // Obtain the inserted node (might be nullptr if node was a duplicate) + // Obtain the inserted node (might be ETL_NULLPTR if node was a duplicate) inserted_node = insert_node(root_node, node); inserted = inserted_node == &node; @@ -1152,14 +1152,14 @@ namespace etl iterator insert(iterator, const_reference value) { // Default to no inserted node - Node* inserted_node = nullptr; + Node* inserted_node = ETL_NULLPTR; ETL_ASSERT(!full(), ETL_ERROR(map_full)); // Get next available free node Data_Node& node = allocate_data_node(value); - // Obtain the inserted node (might be nullptr if node was a duplicate) + // Obtain the inserted node (might be ETL_NULLPTR if node was a duplicate) inserted_node = insert_node(root_node, node); // Insert node into tree and return iterator to new node location in tree @@ -1176,14 +1176,14 @@ namespace etl iterator insert(iterator, rvalue_reference value) { // Default to no inserted node - Node* inserted_node = nullptr; + Node* inserted_node = ETL_NULLPTR; ETL_ASSERT(!full(), ETL_ERROR(map_full)); // Get next available free node Data_Node& node = allocate_data_node(etl::move(value)); - // Obtain the inserted node (might be nullptr if node was a duplicate) + // Obtain the inserted node (might be ETL_NULLPTR if node was a duplicate) inserted_node = insert_node(root_node, node); // Insert node into tree and return iterator to new node location in tree @@ -1200,14 +1200,14 @@ namespace etl iterator insert(const_iterator, const_reference value) { // Default to no inserted node - Node* inserted_node = nullptr; + Node* inserted_node = ETL_NULLPTR; ETL_ASSERT(!full(), ETL_ERROR(map_full)); // Get next available free node Data_Node& node = allocate_data_node(value); - // Obtain the inserted node (might be nullptr if node was a duplicate) + // Obtain the inserted node (might be ETL_NULLPTR if node was a duplicate) inserted_node = insert_node(root_node, node); // Insert node into tree and return iterator to new node location in tree @@ -1224,14 +1224,14 @@ namespace etl iterator insert(const_iterator, rvalue_reference value) { // Default to no inserted node - Node* inserted_node = nullptr; + Node* inserted_node = ETL_NULLPTR; ETL_ASSERT(!full(), ETL_ERROR(map_full)); // Get next available free node Data_Node& node = allocate_data_node(etl::move(value)); - // Obtain the inserted node (might be nullptr if node was a duplicate) + // Obtain the inserted node (might be ETL_NULLPTR if node was a duplicate) inserted_node = insert_node(root_node, node); // Insert node into tree and return iterator to new node location in tree @@ -1450,7 +1450,7 @@ namespace etl } } - // Return the node found (might be nullptr) + // Return the node found (might be ETL_NULLPTR) return found; } @@ -1483,7 +1483,7 @@ namespace etl } } - // Return the node found (might be nullptr) + // Return the node found (might be ETL_NULLPTR) return found; } @@ -1539,7 +1539,7 @@ namespace etl Node* find_parent_node(Node* position, const Node* node) { // Default to no parent node found - Node* found = nullptr; + Node* found = ETL_NULLPTR; // If the position provided is the same as the node then there is no parent if (position && node && position != node) @@ -1576,7 +1576,7 @@ namespace etl } } - // Return the parent node found (might be nullptr) + // Return the parent node found (might be ETL_NULLPTR) return found; } @@ -1587,7 +1587,7 @@ namespace etl const Node* find_parent_node(const Node* position, const Node* node) const { // Default to no parent node found - const Node* found = nullptr; + const Node* found = ETL_NULLPTR; // If the position provided is the same as the node then there is no parent if (position && node && position != node) @@ -1624,7 +1624,7 @@ namespace etl } } - // Return the parent node found (might be nullptr) + // Return the parent node found (might be ETL_NULLPTR) return found; } @@ -1634,7 +1634,7 @@ namespace etl Node* find_lower_node(Node* position, key_parameter_t key) const { // Something at this position? keep going - Node* lower_node = nullptr; + Node* lower_node = ETL_NULLPTR; while (position) { // Downcast lower node to Data_Node reference for key comparisons @@ -1675,7 +1675,7 @@ namespace etl Node* find_upper_node(Node* position, key_parameter_t key) const { // Keep track of parent of last upper node - Node* upper_node = nullptr; + Node* upper_node = ETL_NULLPTR; // Start with position provided Node* node = position; while (node) @@ -1703,7 +1703,7 @@ namespace etl } } - // Return the upper node position found (might be nullptr) + // Return the upper node position found (might be ETL_NULLPTR) return upper_node; } @@ -1718,8 +1718,8 @@ namespace etl // Was position provided not empty? then find where the node belongs if (position) { - // Find the critical parent node (default to nullptr) - Node* critical_parent_node = nullptr; + // Find the critical parent node (default to ETL_NULLPTR) + Node* critical_parent_node = ETL_NULLPTR; Node* critical_node = root_node; while (found) @@ -1752,7 +1752,7 @@ namespace etl found->dir = kNeither; // Clear critical node value to skip weight step below - critical_node = nullptr; + critical_node = ETL_NULLPTR; // Destroy the node provided (its a duplicate) destroy_data_node(node); @@ -1790,17 +1790,20 @@ namespace etl // Was a critical node found that should be checked for balance? if (critical_node) { - if (critical_parent_node == nullptr && critical_node == root_node) + if (critical_parent_node == ETL_NULLPTR && critical_node == root_node) { balance_node(root_node); } - else if (critical_parent_node == nullptr && critical_node == position) + else if (critical_parent_node == ETL_NULLPTR && critical_node == position) { balance_node(position); } else { - balance_node(critical_parent_node->children[critical_parent_node->dir]); + if (critical_parent_node != ETL_NULLPTR) + { + balance_node(critical_parent_node->children[critical_parent_node->dir]); + } } } } @@ -1813,7 +1816,7 @@ namespace etl found = position; } - // Return the node found (might be nullptr) + // Return the node found (might be ETL_NULLPTR) return found; } @@ -1966,11 +1969,11 @@ namespace etl // Step 1: Find the target node that matches the key provided, the // replacement node (might be the same as target node), and the critical // node to start rebalancing the tree from (up to the replacement node) - Node* found_parent = nullptr; - Node* found = nullptr; - Node* replace_parent = nullptr; + Node* found_parent = ETL_NULLPTR; + Node* found = ETL_NULLPTR; + Node* replace_parent = ETL_NULLPTR; Node* replace = position; - Node* balance_parent = nullptr; + Node* balance_parent = ETL_NULLPTR; Node* balance = root_node; while (replace) { @@ -1999,7 +2002,7 @@ namespace etl } // Replacement node found if its missing a child in the replace->dir // value set above - if (replace->children[replace->dir] == nullptr) + if (replace->children[replace->dir] == ETL_NULLPTR) { // Exit loop once replace node is found (target might not have been) break; @@ -2029,7 +2032,7 @@ namespace etl // Step 2: Update weights from critical node to replacement parent node while (balance) { - if (balance->children[balance->dir] == nullptr) + if (balance->children[balance->dir] == ETL_NULLPTR) { break; } @@ -2049,7 +2052,7 @@ namespace etl if (weight == balance->dir) { // Is the root node being rebalanced (no parent) - if (balance_parent == nullptr) + if (balance_parent == ETL_NULLPTR) { rotate_3node(root_node, 1 - balance->dir, balance->children[1 - balance->dir]->children[balance->dir]->weight); @@ -2065,7 +2068,7 @@ namespace etl else if (weight == kNeither) { // Is the root node being rebalanced (no parent) - if (balance_parent == nullptr) + if (balance_parent == ETL_NULLPTR) { rotate_2node(root_node, 1 - balance->dir); root_node->weight = balance->dir; @@ -2082,7 +2085,7 @@ namespace etl else { // Is the root node being rebalanced (no parent) - if (balance_parent == nullptr) + if (balance_parent == ETL_NULLPTR) { rotate_2node(root_node, 1 - balance->dir); } @@ -2147,7 +2150,7 @@ namespace etl destroy_data_node(found_data_node); } // if(found) - // Return node found (might be nullptr) + // Return node found (might be ETL_NULLPTR) return found; } diff --git a/include/etl/memory.h b/include/etl/memory.h index f5e39e78..2d61360f 100644 --- a/include/etl/memory.h +++ b/include/etl/memory.h @@ -61,7 +61,7 @@ namespace etl template T* addressof(T& t) { -#if ETL_CPP11_SUPPORTED +#if ETL_CPP11_SUPPORTED && !defined(ETL_NO_STL) return std::addressof(t); #else return reinterpret_cast(&const_cast(reinterpret_cast(t))); @@ -1243,7 +1243,7 @@ namespace etl //********************************* ETL_CONSTEXPR unique_ptr() ETL_NOEXCEPT - : p(nullptr) + : p(ETL_NULLPTR) { } @@ -1289,7 +1289,7 @@ namespace etl pointer release() ETL_NOEXCEPT { pointer value = p; - p = nullptr; + p = ETL_NULLPTR; return value; } @@ -1315,9 +1315,10 @@ namespace etl //********************************* ETL_CONSTEXPR operator bool() const ETL_NOEXCEPT { - return (p != nullptr); + return (p != ETL_NULLPTR); } +#if ETL_CPP11_SUPPORTED && !defined(ETL_NO_STL) //********************************* unique_ptr& operator =(std::nullptr_t) ETL_NOEXCEPT { @@ -1325,6 +1326,15 @@ namespace etl return *this; } +#else + //********************************* + unique_ptr& operator =(void*) ETL_NOEXCEPT + { + reset(NULL); + + return *this; + } +#endif #if ETL_CPP11_SUPPORTED //********************************* @@ -1382,7 +1392,7 @@ namespace etl //********************************* ETL_CONSTEXPR unique_ptr() ETL_NOEXCEPT - : p(nullptr) + : p(ETL_NULLPTR) { } @@ -1428,7 +1438,7 @@ namespace etl pointer release() ETL_NOEXCEPT { pointer value = p; - p = nullptr; + p = ETL_NULLPTR; return value; } @@ -1453,7 +1463,7 @@ namespace etl //********************************* ETL_CONSTEXPR operator bool() const ETL_NOEXCEPT { - return (p != nullptr); + return (p != ETL_NULLPTR); } #if ETL_CPP11_SUPPORTED @@ -1533,76 +1543,6 @@ bool operator >=(const etl::unique_ptr&lhs, const etl::unique_ptr -bool operator ==(const etl::unique_ptr&lhs, std::nullptr_t) -{ - return !lhs; -} - -//********************************* -template -bool operator ==(std::nullptr_t, const etl::unique_ptr&rhs) -{ - return !rhs; -} - -//********************************* -template -bool operator <(const etl::unique_ptr&lhs, std::nullptr_t) -{ - return etl::less::pointer>()(lhs.get(), nullptr); -} - -//********************************* -template -bool operator <(std::nullptr_t, const etl::unique_ptr& rhs) -{ - return etl::less::pointer>()(nullptr, rhs.get()); -} - -//********************************* -template -bool operator <=(const etl::unique_ptr&lhs, std::nullptr_t) -{ - return !(nullptr < lhs); -} - -//********************************* -template -bool operator <=(std::nullptr_t, const etl::unique_ptr& rhs) -{ - return !(rhs < nullptr); -} - -//********************************* -template -bool operator >(const etl::unique_ptr&lhs, std::nullptr_t) -{ - return nullptr < lhs; -} - -//********************************* -template -bool operator >(std::nullptr_t, const etl::unique_ptr& rhs) -{ - return rhs < nullptr; -} - -//********************************* -template -bool operator >=(const etl::unique_ptr&lhs, std::nullptr_t) -{ - return !(lhs < nullptr); -} - -//********************************* -template -bool operator >=(std::nullptr_t, const etl::unique_ptr& rhs) -{ - return !(nullptr < rhs); -} - namespace etl { //***************************************************************************** diff --git a/include/etl/message_router.h b/include/etl/message_router.h index fcfaa0e1..4f14360e 100644 --- a/include/etl/message_router.h +++ b/include/etl/message_router.h @@ -134,7 +134,7 @@ namespace etl //******************************************** bool has_successor() const { - return (successor != nullptr); + return (successor != ETL_NULLPTR); } enum @@ -148,7 +148,7 @@ namespace etl protected: imessage_router(etl::message_router_id_t id_) - : successor(nullptr), + : successor(ETL_NULLPTR), message_router_id(id_) { } diff --git a/include/etl/message_router_generator.h b/include/etl/message_router_generator.h index 61951531..e5789fde 100644 --- a/include/etl/message_router_generator.h +++ b/include/etl/message_router_generator.h @@ -146,7 +146,7 @@ namespace etl //******************************************** bool has_successor() const { - return (successor != nullptr); + return (successor != ETL_NULLPTR); } enum @@ -160,7 +160,7 @@ namespace etl protected: imessage_router(etl::message_router_id_t id_) - : successor(nullptr), + : successor(ETL_NULLPTR), message_router_id(id_) { } diff --git a/include/etl/message_timer.h b/include/etl/message_timer.h index 56f3cabf..5213f18f 100644 --- a/include/etl/message_timer.h +++ b/include/etl/message_timer.h @@ -86,8 +86,8 @@ namespace etl { //******************************************* message_timer_data() - : p_message(nullptr), - p_router(nullptr), + : p_message(ETL_NULLPTR), + p_router(ETL_NULLPTR), period(0), delta(etl::timer::state::INACTIVE), destination_router_id(etl::imessage_bus::ALL_MESSAGE_ROUTERS), @@ -471,7 +471,7 @@ namespace etl active_list.insert(timer.id); } - if (timer.p_router != nullptr) + if (timer.p_router != ETL_NULLPTR) { static etl::null_message_router nmr; timer.p_router->receive(nmr, timer.destination_router_id, *(timer.p_message)); diff --git a/include/etl/multimap.h b/include/etl/multimap.h index c7efd040..1b8653a7 100644 --- a/include/etl/multimap.h +++ b/include/etl/multimap.h @@ -214,9 +214,9 @@ namespace etl { weight = (uint_least8_t) kNeither; dir = (uint_least8_t) kNeither; - parent = nullptr; - children[0] = nullptr; - children[1] = nullptr; + parent = ETL_NULLPTR; + children[0] = ETL_NULLPTR; + children[1] = ETL_NULLPTR; } Node* parent; @@ -231,7 +231,7 @@ namespace etl multimap_base(size_type max_size_) : current_size(0) , CAPACITY(max_size_) - , root_node(nullptr) + , root_node(ETL_NULLPTR) { } @@ -595,7 +595,7 @@ namespace etl // otherwise we might lose the other child of the swap node replacement = swap->children[1 - swap->dir]; - if (replacement != nullptr) + if (replacement != ETL_NULLPTR) { replacement->parent = swap->parent; } @@ -745,14 +745,14 @@ namespace etl friend class const_iterator; iterator() - : p_multimap(nullptr) - , p_node(nullptr) + : p_multimap(ETL_NULLPTR) + , p_node(ETL_NULLPTR) { } iterator(imultimap& multimap) : p_multimap(&multimap) - , p_node(nullptr) + , p_node(ETL_NULLPTR) { } @@ -865,14 +865,14 @@ namespace etl friend class imultimap; const_iterator() - : p_multimap(nullptr) - , p_node(nullptr) + : p_multimap(ETL_NULLPTR) + , p_node(ETL_NULLPTR) { } const_iterator(const imultimap& multimap) : p_multimap(&multimap) - , p_node(nullptr) + , p_node(ETL_NULLPTR) { } @@ -1224,14 +1224,14 @@ namespace etl iterator insert(const_reference value) { // Default to no inserted node - Node* inserted_node = nullptr; + Node* inserted_node = ETL_NULLPTR; ETL_ASSERT(!full(), ETL_ERROR(multimap_full)); // Get next available free node Data_Node& node = allocate_data_node(value); - // Obtain the inserted node (might be nullptr if node was a duplicate) + // Obtain the inserted node (might be ETL_NULLPTR if node was a duplicate) inserted_node = insert_node(root_node, node); // Insert node into tree and return iterator to new node location in tree @@ -1247,14 +1247,14 @@ namespace etl iterator insert(rvalue_reference value) { // Default to no inserted node - Node* inserted_node = nullptr; + Node* inserted_node = ETL_NULLPTR; ETL_ASSERT(!full(), ETL_ERROR(multimap_full)); // Get next available free node Data_Node& node = allocate_data_node(etl::move(value)); - // Obtain the inserted node (might be nullptr if node was a duplicate) + // Obtain the inserted node (might be ETL_NULLPTR if node was a duplicate) inserted_node = insert_node(root_node, node); // Insert node into tree and return iterator to new node location in tree @@ -1531,7 +1531,7 @@ namespace etl //************************************************************************* Node* find_node(Node* position, key_parameter_t key) const { - Node* found = nullptr; + Node* found = ETL_NULLPTR; while (position) { // Downcast found to Data_Node class for comparison and other operations @@ -1555,7 +1555,7 @@ namespace etl } } - // Return the node found (might be nullptr) + // Return the node found (might be ETL_NULLPTR) return found; } @@ -1564,7 +1564,7 @@ namespace etl //************************************************************************* const Node* find_node(const Node* position, key_parameter_t key) const { - const Node* found = nullptr; + const Node* found = ETL_NULLPTR; while (position) { // Downcast found to Data_Node class for comparison and other operations @@ -1588,7 +1588,7 @@ namespace etl } } - // Return the node found (might be nullptr) + // Return the node found (might be ETL_NULLPTR) return found; } @@ -1598,7 +1598,7 @@ namespace etl Node* find_lower_node(Node* position, key_parameter_t key) const { // Something at this position? keep going - Node* lower_node = nullptr; + Node* lower_node = ETL_NULLPTR; while (position) { // Downcast lower node to Data_Node reference for key comparisons @@ -1639,7 +1639,7 @@ namespace etl Node* find_upper_node(Node* position, key_parameter_t key) const { // Keep track of parent of last upper node - Node* upper_node = nullptr; + Node* upper_node = ETL_NULLPTR; // Has an equal node been found? start with no bool found = false; while (position) @@ -1672,7 +1672,7 @@ namespace etl } } - // Return the upper node position found (might be nullptr) + // Return the upper node position found (might be ETL_NULLPTR) return upper_node; } @@ -1687,8 +1687,8 @@ namespace etl // Was position provided not empty? then find where the node belongs if (position) { - // Find the critical parent node (default to nullptr) - Node* critical_parent_node = nullptr; + // Find the critical parent node (default to ETL_NULLPTR) + Node* critical_parent_node = ETL_NULLPTR; Node* critical_node = root_node; while (found) @@ -1751,30 +1751,33 @@ namespace etl // Was a critical node found that should be checked for balance? if (critical_node) { - if (critical_parent_node == nullptr && critical_node == root_node) + if (critical_parent_node == ETL_NULLPTR && critical_node == root_node) { balance_node(root_node); } - else if (critical_parent_node == nullptr && critical_node == position) + else if (critical_parent_node == ETL_NULLPTR && critical_node == position) { balance_node(position); } else { - balance_node(critical_parent_node->children[critical_parent_node->dir]); + if (critical_parent_node != ETL_NULLPTR) + { + balance_node(critical_parent_node->children[critical_parent_node->dir]); + } } } } else { // Attach node to current position (which is assumed to be root) - attach_node(nullptr, position, node); + attach_node(ETL_NULLPTR, position, node); // Return newly added node at current position found = position; } - // Return the node found (might be nullptr) + // Return the node found (might be ETL_NULLPTR) return found; } @@ -1848,9 +1851,9 @@ namespace etl node = node->children[node->dir]; } } - // The value for node should not be nullptr at this point otherwise + // The value for node should not be ETL_NULLPTR at this point otherwise // step 1 failed to provide the correct path to found. Step 5 will fail - // (probably subtly) if node should be nullptr at this point + // (probably subtly) if node should be ETL_NULLPTR at this point // Step 3: Find the node (node should be equal to found at this point) // to replace found with (might end up equal to found) while also @@ -1859,7 +1862,7 @@ namespace etl { // Replacement node found if its missing a child in the replace->dir // value set at the end of step 2 above - if (node->children[node->dir] == nullptr) + if (node->children[node->dir] == ETL_NULLPTR) { // Exit loop once node to replace found is determined break; @@ -1906,7 +1909,7 @@ namespace etl while (balance) { // Break when balance node reaches the parent of replacement node - if (balance->children[balance->dir] == nullptr) + if (balance->children[balance->dir] == ETL_NULLPTR) { break; } @@ -1931,7 +1934,7 @@ namespace etl if (weight == balance->dir) { // Is the root node being rebalanced (no parent) - if (balance->parent == nullptr) + if (balance->parent == ETL_NULLPTR) { rotate_3node(root_node, 1 - balance->dir, balance->children[1 - balance->dir]->children[balance->dir]->weight); @@ -1947,7 +1950,7 @@ namespace etl else if (weight == (uint_least8_t) kNeither) { // Is the root node being rebalanced (no parent) - if (balance->parent == nullptr) + if (balance->parent == ETL_NULLPTR) { rotate_2node(root_node, 1 - balance->dir); root_node->weight = balance->dir; @@ -1968,7 +1971,7 @@ namespace etl else { // Is the root node being rebalanced (no parent) - if (balance->parent == nullptr) + if (balance->parent == ETL_NULLPTR) { rotate_2node(root_node, 1 - balance->dir); } diff --git a/include/etl/multiset.h b/include/etl/multiset.h index b5bad6f4..46508c5b 100644 --- a/include/etl/multiset.h +++ b/include/etl/multiset.h @@ -213,9 +213,9 @@ namespace etl { weight = kNeither; dir = kNeither; - parent = nullptr; - children[0] = nullptr; - children[1] = nullptr; + parent = ETL_NULLPTR; + children[0] = ETL_NULLPTR; + children[1] = ETL_NULLPTR; } Node* parent; @@ -230,7 +230,7 @@ namespace etl multiset_base(size_type max_size_) : current_size(0) , CAPACITY(max_size_) - , root_node(nullptr) + , root_node(ETL_NULLPTR) { } @@ -277,7 +277,7 @@ namespace etl // otherwise we might lose the other child of the swap node replacement = swap->children[1 - swap->dir]; - if (replacement != nullptr) + if (replacement != ETL_NULLPTR) { replacement->parent = swap->parent; } @@ -727,14 +727,14 @@ namespace etl friend class const_iterator; iterator() - : p_multiset(nullptr) - , p_node(nullptr) + : p_multiset(ETL_NULLPTR) + , p_node(ETL_NULLPTR) { } iterator(imultiset& multiset) : p_multiset(&multiset) - , p_node(nullptr) + , p_node(ETL_NULLPTR) { } @@ -848,14 +848,14 @@ namespace etl friend class imultiset; const_iterator() - : p_multiset(nullptr) - , p_node(nullptr) + : p_multiset(ETL_NULLPTR) + , p_node(ETL_NULLPTR) { } const_iterator(const imultiset& multiset) : p_multiset(&multiset) - , p_node(nullptr) + , p_node(ETL_NULLPTR) { } @@ -1208,14 +1208,14 @@ namespace etl iterator insert(const_reference value) { // Default to no inserted node - Node* inserted_node = nullptr; + Node* inserted_node = ETL_NULLPTR; ETL_ASSERT(!full(), ETL_ERROR(multiset_full)); // Get next available free node Data_Node& node = allocate_data_node(value); - // Obtain the inserted node (might be nullptr if node was a duplicate) + // Obtain the inserted node (might be ETL_NULLPTR if node was a duplicate) inserted_node = insert_node(root_node, node); // Insert node into tree and return iterator to new node location in tree @@ -1231,14 +1231,14 @@ namespace etl iterator insert(rvalue_reference value) { // Default to no inserted node - Node* inserted_node = nullptr; + Node* inserted_node = ETL_NULLPTR; ETL_ASSERT(!full(), ETL_ERROR(multiset_full)); // Get next available free node Data_Node& node = allocate_data_node(etl::move(value)); - // Obtain the inserted node (might be nullptr if node was a duplicate) + // Obtain the inserted node (might be ETL_NULLPTR if node was a duplicate) inserted_node = insert_node(root_node, node); // Insert node into tree and return iterator to new node location in tree @@ -1515,7 +1515,7 @@ namespace etl //************************************************************************* Node* find_node(Node* position, key_parameter_t key) const { - Node* found = nullptr; + Node* found = ETL_NULLPTR; while (position) { // Downcast found to Data_Node class for comparison and other operations @@ -1539,7 +1539,7 @@ namespace etl } } - // Return the node found (might be nullptr) + // Return the node found (might be ETL_NULLPTR) return found; } @@ -1548,7 +1548,7 @@ namespace etl //************************************************************************* const Node* find_node(const Node* position, key_parameter_t key) const { - const Node* found = nullptr; + const Node* found = ETL_NULLPTR; while (position) { // Downcast found to Data_Node class for comparison and other operations @@ -1572,7 +1572,7 @@ namespace etl } } - // Return the node found (might be nullptr) + // Return the node found (might be ETL_NULLPTR) return found; } @@ -1582,7 +1582,7 @@ namespace etl Node* find_lower_node(Node* position, key_parameter_t key) const { // Something at this position? keep going - Node* lower_node = nullptr; + Node* lower_node = ETL_NULLPTR; while (position) { // Downcast lower node to Data_Node reference for key comparisons @@ -1623,7 +1623,7 @@ namespace etl Node* find_upper_node(Node* position, key_parameter_t key) const { // Keep track of parent of last upper node - Node* upper_node = nullptr; + Node* upper_node = ETL_NULLPTR; // Has an equal node been found? start with no bool found = false; while (position) @@ -1656,7 +1656,7 @@ namespace etl } } - // Return the upper node position found (might be nullptr) + // Return the upper node position found (might be ETL_NULLPTR) return upper_node; } @@ -1671,8 +1671,8 @@ namespace etl // Was position provided not empty? then find where the node belongs if (position) { - // Find the critical parent node (default to nullptr) - Node* critical_parent_node = nullptr; + // Find the critical parent node (default to ETL_NULLPTR) + Node* critical_parent_node = ETL_NULLPTR; Node* critical_node = root_node; while (found) @@ -1735,30 +1735,33 @@ namespace etl // Was a critical node found that should be checked for balance? if (critical_node) { - if (critical_parent_node == nullptr && critical_node == root_node) + if (critical_parent_node == ETL_NULLPTR && critical_node == root_node) { balance_node(root_node); } - else if (critical_parent_node == nullptr && critical_node == position) + else if (critical_parent_node == ETL_NULLPTR && critical_node == position) { balance_node(position); } else { - balance_node(critical_parent_node->children[critical_parent_node->dir]); + if (critical_parent_node != ETL_NULLPTR) + { + balance_node(critical_parent_node->children[critical_parent_node->dir]); + } } } } else { // Attatch node to current position (which is assumed to be root) - attach_node(nullptr, position, node); + attach_node(ETL_NULLPTR, position, node); // Return newly added node at current position found = position; } - // Return the node found (might be nullptr) + // Return the node found (might be ETL_NULLPTR) return found; } @@ -1832,9 +1835,9 @@ namespace etl node = node->children[node->dir]; } } - // The value for node should not be nullptr at this point otherwise + // The value for node should not be ETL_NULLPTR at this point otherwise // step 1 failed to provide the correct path to found. Step 5 will fail - // (probably subtly) if node should be nullptr at this point + // (probably subtly) if node should be ETL_NULLPTR at this point // Step 3: Find the node (node should be equal to found at this point) // to replace found with (might end up equal to found) while also @@ -1843,7 +1846,7 @@ namespace etl { // Replacement node found if its missing a child in the replace->dir // value set at the end of step 2 above - if (node->children[node->dir] == nullptr) + if (node->children[node->dir] == ETL_NULLPTR) { // Exit loop once node to replace found is determined break; @@ -1890,7 +1893,7 @@ namespace etl while (balance) { // Break when balance node reaches the parent of replacement node - if (balance->children[balance->dir] == nullptr) + if (balance->children[balance->dir] == ETL_NULLPTR) { break; } @@ -1915,7 +1918,7 @@ namespace etl if (weight == balance->dir) { // Is the root node being rebalanced (no parent) - if (balance->parent == nullptr) + if (balance->parent == ETL_NULLPTR) { rotate_3node(root_node, 1 - balance->dir, balance->children[1 - balance->dir]->children[balance->dir]->weight); @@ -1931,7 +1934,7 @@ namespace etl else if (weight == kNeither) { // Is the root node being rebalanced (no parent) - if (balance->parent == nullptr) + if (balance->parent == ETL_NULLPTR) { rotate_2node(root_node, 1 - balance->dir); root_node->weight = balance->dir; @@ -1952,7 +1955,7 @@ namespace etl else { // Is the root node being rebalanced (no parent) - if (balance->parent == nullptr) + if (balance->parent == ETL_NULLPTR) { rotate_2node(root_node, 1 - balance->dir); } diff --git a/include/etl/nullptr.h b/include/etl/nullptr.h index df0008c4..b29e1570 100644 --- a/include/etl/nullptr.h +++ b/include/etl/nullptr.h @@ -33,84 +33,18 @@ SOFTWARE. #include "platform.h" -///\defgroup nullptr nullptr -/// A definition of nullptr for compilers that don't support it as standard. -///\ingroup utilities - -#if (ETL_NO_NULLPTR_SUPPORT && !defined(ARDUINO)) || defined(ETL_COMPILER_ARM5) -namespace std -{ - //***************************************************************************** - /// A null pointer type. - ///\ingroup nullptr - //***************************************************************************** - class nullptr_t - { - public: - - // Convertible to any type of null non-member pointer. - template - operator T*() const - { - return 0; - } - - // Or any type of null member pointer. - template - operator T ANYCLASS::*() const - { - return 0; - } - - private: - - // Can't take address of nullptr. - void operator&() const ETL_DELETE; - }; - - template - bool operator==(const T* t, const std::nullptr_t nullptr) { - return t == (T*)0; - } - - template - bool operator==(const std::nullptr_t nullptr, const T* t) { - return t == nullptr; - } - - template - bool operator!=(const T* t, const std::nullptr_t nullptr) { - return !(t == nullptr); - } - - template - bool operator!=(const std::nullptr_t nullptr, const T* t) { - return t != nullptr; - } - -} - -//***************************************************************************** -/// A null pointer. -///\ingroup nullptr -//***************************************************************************** -#if !defined(ETL_STLPORT) -const std::nullptr_t nullptr = {}; -#endif - -#else - #if defined(ARDUINO) - #include - #else - #include - #endif -#endif - #if defined(ARDUINO) -namespace std -{ - typedef ::nullptr_t nullptr_t; -} + #include +#else + #include +#endif + +#if (ETL_CPP11_SUPPORTED == 0) || defined(ETL_NO_STL) + // Use the old style NULL definition. + #define ETL_NULLPTR NULL +#else + // Use the new style nullptr. + #define ETL_NULLPTR nullptr #endif #endif diff --git a/include/etl/pool.h b/include/etl/pool.h index 9f8fba81..13101a7e 100644 --- a/include/etl/pool.h +++ b/include/etl/pool.h @@ -125,7 +125,7 @@ namespace etl //************************************************************************* /// Allocate storage for an object from the pool. /// 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. + /// etl::pool_no_allocation if thrown, otherwise a null pointer is returned. //************************************************************************* template T* allocate() @@ -142,7 +142,7 @@ namespace etl //************************************************************************* /// Allocate storage for an object from the pool and create default. /// 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. + /// etl::pool_no_allocation if thrown, otherwise a null pointer is returned. //************************************************************************* template T* create() @@ -160,7 +160,7 @@ namespace etl //************************************************************************* /// Allocate storage for an object from the pool and create with 1 parameter. /// 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. + /// etl::pool_no_allocation if thrown, otherwise a null pointer is returned. //************************************************************************* template T* create(const T1& value1) @@ -352,7 +352,7 @@ namespace etl //************************************************************************* char* allocate_item() { - char* p_value = nullptr; + char* p_value = ETL_NULLPTR; // Any free space left? if (items_allocated < MAX_SIZE) @@ -378,7 +378,7 @@ namespace etl else { // No more left! - p_next = nullptr; + p_next = ETL_NULLPTR; } } else @@ -397,7 +397,7 @@ namespace etl // Does it belong to us? ETL_ASSERT(is_item_in_pool(p_value), ETL_ERROR(pool_object_not_in_pool)); - if (p_next != nullptr) + if (p_next != ETL_NULLPTR) { // Point it to the current free item. *(uintptr_t*)p_value = reinterpret_cast(p_next); @@ -486,7 +486,7 @@ namespace etl //************************************************************************* /// Allocate an object from the pool. /// 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. + /// etl::pool_no_allocation if thrown, otherwise a null pointer is returned. /// Static asserts if the specified type is too large for the pool. //************************************************************************* template @@ -501,7 +501,7 @@ namespace etl //************************************************************************* /// Allocate storage for an object from the pool and create with default. /// 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. + /// etl::pool_no_allocation if thrown, otherwise a null pointer is returned. //************************************************************************* template U* create() @@ -514,7 +514,7 @@ namespace etl //************************************************************************* /// Allocate storage for an object from the pool and create with 1 parameter. /// 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. + /// etl::pool_no_allocation if thrown, otherwise a null pointer is returned. //************************************************************************* template U* create(const T1& value1) @@ -527,7 +527,7 @@ namespace etl //************************************************************************* /// Allocate storage for an object from the pool and create with 2 parameters. /// 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. + /// etl::pool_no_allocation if thrown, otherwise a null pointer is returned. //************************************************************************* template U* create(const T1& value1, const T2& value2) @@ -540,7 +540,7 @@ namespace etl //************************************************************************* /// Allocate storage for an object from the pool and create with 3 parameters. /// 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. + /// etl::pool_no_allocation if thrown, otherwise a null pointer is returned. //************************************************************************* template U* create(const T1& value1, const T2& value2, const T3& value3) @@ -553,7 +553,7 @@ namespace etl //************************************************************************* /// Allocate storage for an object from the pool and create with 4 parameters. /// 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. + /// etl::pool_no_allocation if thrown, otherwise a null pointer is returned. //************************************************************************* template U* create(const T1& value1, const T2& value2, const T3& value3, const T4& value4) @@ -637,7 +637,7 @@ namespace etl /// Allocate an object from the pool. /// Uses the default constructor. /// 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. + /// etl::pool_no_allocation if thrown, otherwise a null pointer is returned. /// Static asserts if the specified type is too large for the pool. //************************************************************************* template @@ -652,7 +652,7 @@ namespace etl //************************************************************************* /// Allocate storage for an object from the pool and create with default. /// 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. + /// etl::pool_no_allocation if thrown, otherwise a null pointer is returned. //************************************************************************* template U* create() @@ -665,7 +665,7 @@ namespace etl //************************************************************************* /// Allocate storage for an object from the pool and create with 1 parameter. /// 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. + /// etl::pool_no_allocation if thrown, otherwise a null pointer is returned. //************************************************************************* template U* create(const T1& value1) @@ -678,7 +678,7 @@ namespace etl //************************************************************************* /// Allocate storage for an object from the pool and create with 2 parameters. /// 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. + /// etl::pool_no_allocation if thrown, otherwise a null pointer is returned. //************************************************************************* template U* create(const T1& value1, const T2& value2) @@ -691,7 +691,7 @@ namespace etl //************************************************************************* /// Allocate storage for an object from the pool and create with 3 parameters. /// 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. + /// etl::pool_no_allocation if thrown, otherwise a null pointer is returned. //************************************************************************* template U* create(const T1& value1, const T2& value2, const T3& value3) @@ -704,7 +704,7 @@ namespace etl //************************************************************************* /// Allocate storage for an object from the pool and create with 4 parameters. /// 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. + /// etl::pool_no_allocation if thrown, otherwise a null pointer is returned. //************************************************************************* template U* create(const T1& value1, const T2& value2, const T3& value3, const T4& value4) @@ -717,7 +717,7 @@ namespace etl //************************************************************************* /// Allocate storage for an object from the pool and create with variadic parameters. /// 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. + /// etl::pool_no_allocation if thrown, otherwise a null pointer is returned. //************************************************************************* template U* create(Args&&... args) diff --git a/include/etl/scheduler.h b/include/etl/scheduler.h index 3a6f9e85..4e8afa20 100644 --- a/include/etl/scheduler.h +++ b/include/etl/scheduler.h @@ -304,7 +304,7 @@ namespace etl { for (TSize i = 0; i < size; ++i) { - ETL_ASSERT((p_tasks[i] != nullptr), ETL_ERROR(etl::scheduler_null_task_exception)); + ETL_ASSERT((p_tasks[i] != ETL_NULLPTR), ETL_ERROR(etl::scheduler_null_task_exception)); add_task(*(p_tasks[i])); } } @@ -317,8 +317,8 @@ namespace etl ischeduler(etl::ivector& task_list_) : scheduler_running(false), scheduler_exit(false), - p_idle_callback(nullptr), - p_watchdog_callback(nullptr), + p_idle_callback(ETL_NULLPTR), + p_watchdog_callback(ETL_NULLPTR), task_list(task_list_) { } diff --git a/include/etl/set.h b/include/etl/set.h index f6efe53b..eb49cd2d 100755 --- a/include/etl/set.h +++ b/include/etl/set.h @@ -214,8 +214,8 @@ namespace etl { weight = kNeither; dir = kNeither; - children[0] = nullptr; - children[1] = nullptr; + children[0] = ETL_NULLPTR; + children[1] = ETL_NULLPTR; } Node* children[2]; @@ -229,7 +229,7 @@ namespace etl set_base(size_type max_size_) : current_size(0) , CAPACITY(max_size_) - , root_node(nullptr) + , root_node(ETL_NULLPTR) { } @@ -564,14 +564,14 @@ namespace etl friend class const_iterator; iterator() - : p_set(nullptr) - , p_node(nullptr) + : p_set(ETL_NULLPTR) + , p_node(ETL_NULLPTR) { } iterator(iset& set) : p_set(&set) - , p_node(nullptr) + , p_node(ETL_NULLPTR) { } @@ -684,14 +684,14 @@ namespace etl friend class iset; const_iterator() - : p_set(nullptr) - , p_node(nullptr) + : p_set(ETL_NULLPTR) + , p_node(ETL_NULLPTR) { } const_iterator(const iset& set) : p_set(&set) - , p_node(nullptr) + , p_node(ETL_NULLPTR) { } @@ -1063,7 +1063,7 @@ namespace etl ETL_OR_STD::pair insert(const_reference value) { // Default to no inserted node - Node* inserted_node = nullptr; + Node* inserted_node = ETL_NULLPTR; bool inserted = false; ETL_ASSERT(!full(), ETL_ERROR(set_full)); @@ -1071,7 +1071,7 @@ namespace etl // Get next available free node Data_Node& node = allocate_data_node(value); - // Obtain the inserted node (might be nullptr if node was a duplicate) + // Obtain the inserted node (might be ETL_NULLPTR if node was a duplicate) inserted_node = insert_node(root_node, node); inserted = inserted_node == &node; @@ -1088,7 +1088,7 @@ namespace etl ETL_OR_STD::pair insert(rvalue_reference value) { // Default to no inserted node - Node* inserted_node = nullptr; + Node* inserted_node = ETL_NULLPTR; bool inserted = false; ETL_ASSERT(!full(), ETL_ERROR(set_full)); @@ -1096,7 +1096,7 @@ namespace etl // Get next available free node Data_Node& node = allocate_data_node(etl::move(value)); - // Obtain the inserted node (might be nullptr if node was a duplicate) + // Obtain the inserted node (might be ETL_NULLPTR if node was a duplicate) inserted_node = insert_node(root_node, node); inserted = inserted_node == &node; @@ -1114,14 +1114,14 @@ namespace etl iterator insert(iterator, const_reference value) { // Default to no inserted node - Node* inserted_node = nullptr; + Node* inserted_node = ETL_NULLPTR; ETL_ASSERT(!full(), ETL_ERROR(set_full)); // Get next available free node Data_Node& node = allocate_data_node(value); - // Obtain the inserted node (might be nullptr if node was a duplicate) + // Obtain the inserted node (might be ETL_NULLPTR if node was a duplicate) inserted_node = insert_node(root_node, node); // Insert node into tree and return iterator to new node location in tree @@ -1138,14 +1138,14 @@ namespace etl iterator insert(iterator, rvalue_reference value) { // Default to no inserted node - Node* inserted_node = nullptr; + Node* inserted_node = ETL_NULLPTR; ETL_ASSERT(!full(), ETL_ERROR(set_full)); // Get next available free node Data_Node& node = allocate_data_node(etl::move(value)); - // Obtain the inserted node (might be nullptr if node was a duplicate) + // Obtain the inserted node (might be ETL_NULLPTR if node was a duplicate) inserted_node = insert_node(root_node, node); // Insert node into tree and return iterator to new node location in tree @@ -1162,14 +1162,14 @@ namespace etl iterator insert(const_iterator, const_reference value) { // Default to no inserted node - Node* inserted_node = nullptr; + Node* inserted_node = ETL_NULLPTR; ETL_ASSERT(!full(), ETL_ERROR(set_full)); // Get next available free node Data_Node& node = allocate_data_node(value); - // Obtain the inserted node (might be nullptr if node was a duplicate) + // Obtain the inserted node (might be ETL_NULLPTR if node was a duplicate) inserted_node = insert_node(root_node, node); // Insert node into tree and return iterator to new node location in tree @@ -1186,14 +1186,14 @@ namespace etl iterator insert(const_iterator, rvalue_reference value) { // Default to no inserted node - Node* inserted_node = nullptr; + Node* inserted_node = ETL_NULLPTR; ETL_ASSERT(!full(), ETL_ERROR(set_full)); // Get next available free node Data_Node& node = allocate_data_node(etl::move(value)); - // Obtain the inserted node (might be nullptr if node was a duplicate) + // Obtain the inserted node (might be ETL_NULLPTR if node was a duplicate) inserted_node = insert_node(root_node, node); // Insert node into tree and return iterator to new node location in tree @@ -1375,7 +1375,7 @@ namespace etl } } - // Return the node found (might be nullptr) + // Return the node found (might be ETL_NULLPTR) return found; } @@ -1408,7 +1408,7 @@ namespace etl } } - // Return the node found (might be nullptr) + // Return the node found (might be ETL_NULLPTR) return found; } @@ -1464,7 +1464,7 @@ namespace etl Node* find_parent_node(Node* position, const Node* node) { // Default to no parent node found - Node* found = nullptr; + Node* found = ETL_NULLPTR; // If the position provided is the same as the node then there is no parent if (position && node && position != node) @@ -1501,7 +1501,7 @@ namespace etl } } - // Return the parent node found (might be nullptr) + // Return the parent node found (might be ETL_NULLPTR) return found; } @@ -1512,7 +1512,7 @@ namespace etl const Node* find_parent_node(const Node* position, const Node* node) const { // Default to no parent node found - const Node* found = nullptr; + const Node* found = ETL_NULLPTR; // If the position provided is the same as the node then there is no parent if (position && node && position != node) @@ -1549,7 +1549,7 @@ namespace etl } } - // Return the parent node found (might be nullptr) + // Return the parent node found (might be ETL_NULLPTR) return found; } @@ -1559,7 +1559,7 @@ namespace etl Node* find_lower_node(Node* position, key_parameter_t key) const { // Something at this position? keep going - Node* lower_node = nullptr; + Node* lower_node = ETL_NULLPTR; while (position) { // Downcast lower node to Data_Node reference for key comparisons @@ -1600,7 +1600,7 @@ namespace etl Node* find_upper_node(Node* position, key_parameter_t key) const { // Keep track of parent of last upper node - Node* upper_node = nullptr; + Node* upper_node = ETL_NULLPTR; // Start with position provided Node* node = position; while (node) @@ -1628,7 +1628,7 @@ namespace etl } } - // Return the upper node position found (might be nullptr) + // Return the upper node position found (might be ETL_NULLPTR) return upper_node; } @@ -1643,8 +1643,8 @@ namespace etl // Was position provided not empty? then find where the node belongs if (position) { - // Find the critical parent node (default to nullptr) - Node* critical_parent_node = nullptr; + // Find the critical parent node (default to ETL_NULLPTR) + Node* critical_parent_node = ETL_NULLPTR; Node* critical_node = root_node; while (found) @@ -1677,7 +1677,7 @@ namespace etl found->dir = kNeither; // Clear critical node value to skip weight step below - critical_node = nullptr; + critical_node = ETL_NULLPTR; // Destroy the node provided (its a duplicate) destroy_data_node(node); @@ -1715,17 +1715,20 @@ namespace etl // Was a critical node found that should be checked for balance? if (critical_node) { - if (critical_parent_node == nullptr && critical_node == root_node) + if (critical_parent_node == ETL_NULLPTR && critical_node == root_node) { balance_node(root_node); } - else if (critical_parent_node == nullptr && critical_node == position) + else if (critical_parent_node == ETL_NULLPTR && critical_node == position) { balance_node(position); } else { - balance_node(critical_parent_node->children[critical_parent_node->dir]); + if (critical_parent_node != ETL_NULLPTR) + { + balance_node(critical_parent_node->children[critical_parent_node->dir]); + } } } } @@ -1738,7 +1741,7 @@ namespace etl found = position; } - // Return the node found (might be nullptr) + // Return the node found (might be ETL_NULLPTR) return found; } @@ -1891,11 +1894,11 @@ namespace etl // Step 1: Find the target node that matches the key provided, the // replacement node (might be the same as target node), and the critical // node to start rebalancing the tree from (up to the replacement node) - Node* found_parent = nullptr; - Node* found = nullptr; - Node* replace_parent = nullptr; + Node* found_parent = ETL_NULLPTR; + Node* found = ETL_NULLPTR; + Node* replace_parent = ETL_NULLPTR; Node* replace = position; - Node* balance_parent = nullptr; + Node* balance_parent = ETL_NULLPTR; Node* balance = root_node; while (replace) { @@ -1924,7 +1927,7 @@ namespace etl } // Replacement node found if its missing a child in the replace->dir // value set above - if (replace->children[replace->dir] == nullptr) + if (replace->children[replace->dir] == ETL_NULLPTR) { // Exit loop once replace node is found (target might not have been) break; @@ -1954,7 +1957,7 @@ namespace etl // Step 2: Update weights from critical node to replacement parent node while (balance) { - if (balance->children[balance->dir] == nullptr) + if (balance->children[balance->dir] == ETL_NULLPTR) { break; } @@ -1974,7 +1977,7 @@ namespace etl if (weight == balance->dir) { // Is the root node being rebalanced (no parent) - if (balance_parent == nullptr) + if (balance_parent == ETL_NULLPTR) { rotate_3node(root_node, 1 - balance->dir, balance->children[1 - balance->dir]->children[balance->dir]->weight); @@ -1990,7 +1993,7 @@ namespace etl else if (weight == kNeither) { // Is the root node being rebalanced (no parent) - if (balance_parent == nullptr) + if (balance_parent == ETL_NULLPTR) { rotate_2node(root_node, 1 - balance->dir); root_node->weight = balance->dir; @@ -2007,7 +2010,7 @@ namespace etl else { // Is the root node being rebalanced (no parent) - if (balance_parent == nullptr) + if (balance_parent == ETL_NULLPTR) { rotate_2node(root_node, 1 - balance->dir); } @@ -2072,7 +2075,7 @@ namespace etl destroy_data_node(found_data_node); } // if(found) - // Return node found (might be nullptr) + // Return node found (might be ETL_NULLPTR) return found; } diff --git a/include/etl/state_chart.h b/include/etl/state_chart.h index 449e5aa0..b26cf186 100644 --- a/include/etl/state_chart.h +++ b/include/etl/state_chart.h @@ -91,8 +91,8 @@ namespace etl transition(const state_id_t current_state_id_, const event_id_t event_id_, const state_id_t next_state_id_, - void (TObject::* const action_)() = nullptr, - bool (TObject::* const guard_)() = nullptr) + void (TObject::* const action_)() = ETL_NULLPTR, + bool (TObject::* const guard_)() = ETL_NULLPTR) : from_any_state(false), current_state_id(current_state_id_), event_id(event_id_), @@ -104,8 +104,8 @@ namespace etl transition(const event_id_t event_id_, const state_id_t next_state_id_, - void (TObject::* const action_)() = nullptr, - bool (TObject::* const guard_)() = nullptr) + void (TObject::* const action_)() = ETL_NULLPTR, + bool (TObject::* const guard_)() = ETL_NULLPTR) : from_any_state(true), current_state_id(0), event_id(event_id_), @@ -129,8 +129,8 @@ namespace etl struct state { state(const state_id_t state_id_, - void (TObject::* const on_entry_)() = nullptr, - void (TObject::* const on_exit_)() = nullptr) + void (TObject::* const on_entry_)() = ETL_NULLPTR, + void (TObject::* const on_exit_)() = ETL_NULLPTR) : state_id(state_id_), on_entry(on_entry_), on_exit(on_exit_) @@ -254,7 +254,7 @@ namespace etl const state* s = find_state(current_state_id); // If the initial state has an 'on_entry' then call it. - if ((s != state_table.end()) && (s->on_entry != nullptr)) + if ((s != state_table.end()) && (s->on_entry != ETL_NULLPTR)) { (object.*(s->on_entry))(); } @@ -288,13 +288,13 @@ namespace etl if (t != transition_table.end()) { // Shall we execute the transition? - if ((t->guard == nullptr) || ((object.*t->guard)())) + if ((t->guard == ETL_NULLPTR) || ((object.*t->guard)())) { // Remember the next state. next_state_id = t->next_state_id; // Shall we execute the action? - if (t->action != nullptr) + if (t->action != ETL_NULLPTR) { (object.*t->action)(); } @@ -308,7 +308,7 @@ namespace etl s = find_state(current_state_id); // If the current state has an 'on_exit' then call it. - if ((s != state_table.end()) && (s->on_exit != nullptr)) + if ((s != state_table.end()) && (s->on_exit != ETL_NULLPTR)) { (object.*(s->on_exit))(); } @@ -319,7 +319,7 @@ namespace etl s = find_state(next_state_id); // If the new state has an 'on_entry' then call it. - if ((s != state_table.end()) && (s->on_entry != nullptr)) + if ((s != state_table.end()) && (s->on_entry != ETL_NULLPTR)) { (object.*(s->on_entry))(); } diff --git a/include/etl/string_view.h b/include/etl/string_view.h index b580ebe9..58cdd8cd 100644 --- a/include/etl/string_view.h +++ b/include/etl/string_view.h @@ -121,8 +121,8 @@ namespace etl /// Default constructor. //************************************************************************* ETL_CONSTEXPR17 basic_string_view() - : mbegin(nullptr) - , mend(nullptr) + : mbegin(ETL_NULLPTR) + , mend(ETL_NULLPTR) { } @@ -338,7 +338,7 @@ namespace etl //************************************************************************* const_reference at(size_t i) const { - ETL_ASSERT((mbegin != nullptr && mend != nullptr), ETL_ERROR(string_view_uninitialised)); + ETL_ASSERT((mbegin != ETL_NULLPTR && mend != ETL_NULLPTR), ETL_ERROR(string_view_uninitialised)); ETL_ASSERT(i < size(), ETL_ERROR(string_view_bounds)); return mbegin[i]; } diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index 85a21292..6acfce0f 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -339,9 +339,7 @@ namespace etl //*************************************************************************** /// is_fundamental - template struct is_fundamental : integral_constant::value || - is_void::value || - is_same::type>::value> {}; + template struct is_fundamental : integral_constant::value || is_void::value> {}; #if ETL_CPP17_SUPPORTED template diff --git a/include/etl/type_traits_generator.h b/include/etl/type_traits_generator.h index e3696860..b5b924d8 100644 --- a/include/etl/type_traits_generator.h +++ b/include/etl/type_traits_generator.h @@ -351,9 +351,7 @@ namespace etl //*************************************************************************** /// is_fundamental - template struct is_fundamental : integral_constant::value || - is_void::value || - is_same::type>::value> {}; + template struct is_fundamental : integral_constant::value || is_void::value> {}; #if ETL_CPP17_SUPPORTED template diff --git a/include/etl/variant_pool.h b/include/etl/variant_pool.h index 48c34a62..a0dac60a 100644 --- a/include/etl/variant_pool.h +++ b/include/etl/variant_pool.h @@ -143,7 +143,7 @@ namespace etl { ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type"); - T* p = nullptr; + T* p = ETL_NULLPTR; if (pool.full()) { @@ -153,7 +153,7 @@ namespace etl { p = pool.template allocate(); - if (p != nullptr) + if (p != ETL_NULLPTR) { new (p) T(); } @@ -170,7 +170,7 @@ namespace etl { ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type"); - T* p = nullptr; + T* p = ETL_NULLPTR; if (pool.full()) { @@ -180,7 +180,7 @@ namespace etl { p = pool.template allocate(); - if (p != nullptr) + if (p != ETL_NULLPTR) { new (p) T(p1); } @@ -197,7 +197,7 @@ namespace etl { ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type"); - T* p = nullptr; + T* p = ETL_NULLPTR; if (pool.full()) { @@ -207,7 +207,7 @@ namespace etl { p = pool.template allocate(); - if (p != nullptr) + if (p != ETL_NULLPTR) { new (p) T(p1, p2); } @@ -224,7 +224,7 @@ namespace etl { ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type"); - T* p = nullptr; + T* p = ETL_NULLPTR; if (pool.full()) { @@ -234,7 +234,7 @@ namespace etl { p = pool.template allocate(); - if (p != nullptr) + if (p != ETL_NULLPTR) { new (p) T(p1, p2, p3); } @@ -251,7 +251,7 @@ namespace etl { ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type"); - T* p = nullptr; + T* p = ETL_NULLPTR; if (pool.full()) { @@ -261,7 +261,7 @@ namespace etl { p = pool.template allocate(); - if (p != nullptr) + if (p != ETL_NULLPTR) { new (p) T(p1, p2, p3, p4); } @@ -278,7 +278,7 @@ namespace etl { ETL_STATIC_ASSERT((etl::is_one_of::value), "Unsupported type"); - T* p = nullptr; + T* p = ETL_NULLPTR; if (pool.full()) { @@ -288,7 +288,7 @@ namespace etl { p = pool.template allocate(); - if (p != nullptr) + if (p != ETL_NULLPTR) { new (p) T(etl::forward(args)...); } diff --git a/include/etl/variant_pool_generator.h b/include/etl/variant_pool_generator.h index a00f1748..cd9489d1 100644 --- a/include/etl/variant_pool_generator.h +++ b/include/etl/variant_pool_generator.h @@ -160,7 +160,7 @@ namespace etl ]]]*/ /*[[[end]]]*/ - T* p = nullptr; + T* p = ETL_NULLPTR; if (pool.full()) { @@ -170,7 +170,7 @@ namespace etl { p = pool.template allocate(); - if (p != nullptr) + if (p != ETL_NULLPTR) { new (p) T(); } @@ -197,7 +197,7 @@ namespace etl ]]]*/ /*[[[end]]]*/ - T* p = nullptr; + T* p = ETL_NULLPTR; if (pool.full()) { @@ -207,7 +207,7 @@ namespace etl { p = pool.template allocate(); - if (p != nullptr) + if (p != ETL_NULLPTR) { new (p) T(p1); } @@ -234,7 +234,7 @@ namespace etl ]]]*/ /*[[[end]]]*/ - T* p = nullptr; + T* p = ETL_NULLPTR; if (pool.full()) { @@ -244,7 +244,7 @@ namespace etl { p = pool.template allocate(); - if (p != nullptr) + if (p != ETL_NULLPTR) { new (p) T(p1, p2); } @@ -271,7 +271,7 @@ namespace etl ]]]*/ /*[[[end]]]*/ - T* p = nullptr; + T* p = ETL_NULLPTR; if (pool.full()) { @@ -281,7 +281,7 @@ namespace etl { p = pool.template allocate(); - if (p != nullptr) + if (p != ETL_NULLPTR) { new (p) T(p1, p2, p3); } @@ -308,7 +308,7 @@ namespace etl ]]]*/ /*[[[end]]]*/ - T* p = nullptr; + T* p = ETL_NULLPTR; if (pool.full()) { @@ -318,7 +318,7 @@ namespace etl { p = pool.template allocate(); - if (p != nullptr) + if (p != ETL_NULLPTR) { new (p) T(p1, p2, p3, p4); } @@ -345,7 +345,7 @@ namespace etl ]]]*/ /*[[[end]]]*/ - T* p = nullptr; + T* p = ETL_NULLPTR; if (pool.full()) { @@ -355,7 +355,7 @@ namespace etl { p = pool.template allocate(); - if (p != nullptr) + if (p != ETL_NULLPTR) { new (p) T(ETL_OR_STD::forward(args)...); } diff --git a/include/etl/version.h b/include/etl/version.h index a22f20a1..c3e84096 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -38,7 +38,7 @@ SOFTWARE. ///\ingroup utilities #define ETL_VERSION_MAJOR 17 -#define ETL_VERSION_MINOR 0 +#define ETL_VERSION_MINOR 1 #define ETL_VERSION_PATCH 0 #define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH) diff --git a/library.json b/library.json index 3caec6ea..3a843aa5 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library", - "version": "17.0.0", + "version": "17.1.0", "authors": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index 808d2c4a..7b91b37d 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library -version=17.0.0 +version=17.1.0 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/support/Release notes.txt b/support/Release notes.txt index d848f41f..0a722dad 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,11 @@ +=============================================================================== +17.1.0 +Removed ETL's implementation of nullptr for pre C++11 compilers and created the macro +ETL_NULLPTR for internal use. Equates to NULL or nullptr, dependent on the compiler +version and project profile. + +Added partial compile time versions of binary_fill and has_zero_byte. + =============================================================================== 17.0.0 Recoded binary_fill, has_zero_byte and has_byte_n as runtime functions to fix diff --git a/test/test_binary.cpp b/test/test_binary.cpp index e1177707..7373cc6c 100644 --- a/test/test_binary.cpp +++ b/test/test_binary.cpp @@ -765,11 +765,6 @@ namespace } } - size_t xxx() - { - return 4; - } - //************************************************************************* TEST(test_binary_to_gray64_constexpr) { @@ -1580,6 +1575,38 @@ namespace CHECK_EQUAL(int64_t(0x123456789ABCDEF0), int64_t(etl::binary_fill(int64_t(0x123456789ABCDEF0)))); } + //************************************************************************* + TEST(test_binary_fill_partial_compile_time) + { + CHECK_EQUAL(0x12U, (etl::binary_fill())); + CHECK_EQUAL(0x1212U, (etl::binary_fill())); + CHECK_EQUAL(0x12121212U, (etl::binary_fill())); + CHECK_EQUAL(0x1212121212121212U, (etl::binary_fill())); + + CHECK_EQUAL(0x12U, (etl::binary_fill())); + CHECK_EQUAL(0x1212U, (etl::binary_fill())); + CHECK_EQUAL(0x12121212U, (etl::binary_fill())); + CHECK_EQUAL(0x1212121212121212U, (etl::binary_fill())); + + CHECK_EQUAL(0x1234U, (etl::binary_fill())); + CHECK_EQUAL(0x12341234U, (etl::binary_fill())); + CHECK_EQUAL(0x1234123412341234U, (etl::binary_fill())); + + CHECK_EQUAL(0x1234U, (etl::binary_fill())); + CHECK_EQUAL(0x12341234U, (etl::binary_fill())); + CHECK_EQUAL(0x1234123412341234U, (etl::binary_fill())); + + CHECK_EQUAL(0x12345678U, (etl::binary_fill())); + CHECK_EQUAL(0x1234567812345678U, (etl::binary_fill())); + + CHECK_EQUAL(0x12345678U, (etl::binary_fill())); + CHECK_EQUAL(0x1234567812345678U, (etl::binary_fill())); + + CHECK_EQUAL(0x123456789ABCDEF0U, (etl::binary_fill())); + + CHECK_EQUAL(int64_t(0x123456789ABCDEF0), int64_t(etl::binary_fill())); + } + //************************************************************************* TEST(test_has_zero_byte) { @@ -1609,31 +1636,31 @@ namespace } //************************************************************************* - TEST(test_has_byte_n_partial_run_time) + TEST(test_has_zero_byte_partial_compile_time) { - CHECK(!(etl::has_byte_n(uint8_t(0x01)))); - CHECK((etl::has_byte_n(uint8_t(0x01)))); + CHECK(!(etl::has_zero_byte())); + CHECK((etl::has_zero_byte())); - CHECK(!(etl::has_byte_n(int8_t(0x01)))); - CHECK((etl::has_byte_n(int8_t(0x01)))); + CHECK(!(etl::has_zero_byte())); + CHECK((etl::has_zero_byte())); - CHECK(!(etl::has_byte_n(uint16_t(0x0123)))); - CHECK((etl::has_byte_n(uint16_t(0x0123)))); + CHECK(!(etl::has_zero_byte())); + CHECK((etl::has_zero_byte())); - CHECK(!(etl::has_byte_n(int16_t(0x0123)))); - CHECK((etl::has_byte_n(int16_t(0x0123)))); + CHECK(!(etl::has_zero_byte())); + CHECK((etl::has_zero_byte())); - CHECK(!(etl::has_byte_n(uint32_t(0x01234567)))); - CHECK((etl::has_byte_n(uint32_t(0x01234567)))); + CHECK(!(etl::has_zero_byte())); + CHECK((etl::has_zero_byte())); - CHECK(!(etl::has_byte_n(int32_t(0x01234567)))); - CHECK((etl::has_byte_n(int32_t(0x01234567)))); + CHECK(!(etl::has_zero_byte())); + CHECK((etl::has_zero_byte())); - CHECK(!(etl::has_byte_n(uint64_t(0x0123456789ABCDEF)))); - CHECK((etl::has_byte_n(uint64_t(0x0123456789ABCDEF)))); + CHECK(!(etl::has_zero_byte())); + CHECK((etl::has_zero_byte())); - CHECK(!(etl::has_byte_n(int64_t(0x0123456789ABCDEF)))); - CHECK((etl::has_byte_n(int64_t(0x0123456789ABCDEF)))); + CHECK(!(etl::has_zero_byte())); + CHECK((etl::has_zero_byte())); } //************************************************************************* @@ -1664,43 +1691,71 @@ namespace CHECK((etl::has_byte_n(int64_t(0x0123456789ABCDEF), 0xAB))); } - //************************************************************************* - TEST(test_binary_merge) - { - CHECK_EQUAL((etl::binary_merge(uint8_t(0x12), uint8_t(0x34), uint8_t(0xF0))), uint8_t(0x14)); - CHECK_EQUAL((etl::binary_merge(uint8_t(0x12), uint8_t(0x34))), uint8_t(0x14)); + //************************************************************************* + TEST(test_has_byte_n_partial_run_time) + { + CHECK(!(etl::has_byte_n(uint8_t(0x01)))); + CHECK((etl::has_byte_n(uint8_t(0x01)))); - CHECK_EQUAL((etl::binary_merge(uint16_t(0x1234), uint16_t(0x3456), uint16_t(0xF0F0))), uint16_t(0x1436)); - CHECK_EQUAL((etl::binary_merge(uint16_t(0x1234), uint16_t(0x3456))), uint16_t(0x1436)); + CHECK(!(etl::has_byte_n(int8_t(0x01)))); + CHECK((etl::has_byte_n(int8_t(0x01)))); - CHECK_EQUAL((etl::binary_merge(uint32_t(0x12345678), uint32_t(0x3456789A), uint32_t(0xF0F0F0F0))), uint32_t(0x1436587A)); - CHECK_EQUAL((etl::binary_merge(uint32_t(0x12345678), uint32_t(0x3456789A))), uint32_t(0x1436587A)); + CHECK(!(etl::has_byte_n(uint16_t(0x0123)))); + CHECK((etl::has_byte_n(uint16_t(0x0123)))); - CHECK_EQUAL((etl::binary_merge(uint64_t(0x123456789ABCDEF0), uint64_t(0x3456789ABCDEF012), uint64_t(0xF0F0F0F0F0F0F0F0))), uint64_t(0x1436587A9CBED0F2)); - CHECK_EQUAL((etl::binary_merge(uint64_t(0x123456789ABCDEF0), uint64_t(0x3456789ABCDEF012))), uint64_t(0x1436587A9CBED0F2)); - } + CHECK(!(etl::has_byte_n(int16_t(0x0123)))); + CHECK((etl::has_byte_n(int16_t(0x0123)))); - //************************************************************************* - TEST(test_binary_interleave) - { - CHECK_EQUAL((etl::binary_interleave(uint8_t(0x5A), uint8_t(0xA5))), uint16_t(0x9966)); - CHECK_EQUAL((etl::binary_interleave(uint16_t(0x5A5A), uint16_t(0xA5A5))), uint32_t(0x99669966)); - CHECK_EQUAL((etl::binary_interleave(uint32_t(0x5A5A5A5A), uint32_t(0xA5A5A5A5))), uint64_t(0x9966996699669966)); - } + CHECK(!(etl::has_byte_n(uint32_t(0x01234567)))); + CHECK((etl::has_byte_n(uint32_t(0x01234567)))); - //************************************************************************* - TEST(test_is_odd) - { - CHECK(etl::is_odd(1)); - CHECK(!etl::is_odd(2)); - } + CHECK(!(etl::has_byte_n(int32_t(0x01234567)))); + CHECK((etl::has_byte_n(int32_t(0x01234567)))); - //************************************************************************* - TEST(test_is_even) - { - CHECK(!etl::is_even(1)); - CHECK(etl::is_even(2)); - } + CHECK(!(etl::has_byte_n(uint64_t(0x0123456789ABCDEF)))); + CHECK((etl::has_byte_n(uint64_t(0x0123456789ABCDEF)))); + + CHECK(!(etl::has_byte_n(int64_t(0x0123456789ABCDEF)))); + CHECK((etl::has_byte_n(int64_t(0x0123456789ABCDEF)))); + } + + //************************************************************************* + TEST(test_binary_merge) + { + CHECK_EQUAL((etl::binary_merge(uint8_t(0x12), uint8_t(0x34), uint8_t(0xF0))), uint8_t(0x14)); + CHECK_EQUAL((etl::binary_merge(uint8_t(0x12), uint8_t(0x34))), uint8_t(0x14)); + + CHECK_EQUAL((etl::binary_merge(uint16_t(0x1234), uint16_t(0x3456), uint16_t(0xF0F0))), uint16_t(0x1436)); + CHECK_EQUAL((etl::binary_merge(uint16_t(0x1234), uint16_t(0x3456))), uint16_t(0x1436)); + + CHECK_EQUAL((etl::binary_merge(uint32_t(0x12345678), uint32_t(0x3456789A), uint32_t(0xF0F0F0F0))), uint32_t(0x1436587A)); + CHECK_EQUAL((etl::binary_merge(uint32_t(0x12345678), uint32_t(0x3456789A))), uint32_t(0x1436587A)); + + CHECK_EQUAL((etl::binary_merge(uint64_t(0x123456789ABCDEF0), uint64_t(0x3456789ABCDEF012), uint64_t(0xF0F0F0F0F0F0F0F0))), uint64_t(0x1436587A9CBED0F2)); + CHECK_EQUAL((etl::binary_merge(uint64_t(0x123456789ABCDEF0), uint64_t(0x3456789ABCDEF012))), uint64_t(0x1436587A9CBED0F2)); + } + + //************************************************************************* + TEST(test_binary_interleave) + { + CHECK_EQUAL((etl::binary_interleave(uint8_t(0x5A), uint8_t(0xA5))), uint16_t(0x9966)); + CHECK_EQUAL((etl::binary_interleave(uint16_t(0x5A5A), uint16_t(0xA5A5))), uint32_t(0x99669966)); + CHECK_EQUAL((etl::binary_interleave(uint32_t(0x5A5A5A5A), uint32_t(0xA5A5A5A5))), uint64_t(0x9966996699669966)); + } + + //************************************************************************* + TEST(test_is_odd) + { + CHECK(etl::is_odd(1)); + CHECK(!etl::is_odd(2)); + } + + //************************************************************************* + TEST(test_is_even) + { + CHECK(!etl::is_even(1)); + CHECK(etl::is_even(2)); + } }; } diff --git a/test/test_type_traits.cpp b/test/test_type_traits.cpp index 31554695..d3ee4576 100644 --- a/test/test_type_traits.cpp +++ b/test/test_type_traits.cpp @@ -389,7 +389,9 @@ namespace CHECK(etl::is_fundamental::value == std::is_fundamental::value); CHECK(etl::is_fundamental::value == std::is_fundamental::value); CHECK(etl::is_fundamental::value == std::is_fundamental::value); +#if !defined(ETL_NO_STL) CHECK(etl::is_fundamental::value == std::is_fundamental::value); +#endif } //************************************************************************* diff --git a/test/vs2017/cpp.hint b/test/vs2017/cpp.hint index f90cc3ba..c602985c 100644 --- a/test/vs2017/cpp.hint +++ b/test/vs2017/cpp.hint @@ -2,17 +2,25 @@ // such as names of functions and macros. // For more information see https://go.microsoft.com/fwlink/?linkid=865984 #define ETL_CONSTEXPR +#define ETL_CONSTEXPR14 #define ETL_CONSTEXPR17 #define ETL_IF_CONSTEXPR #define ETL_DELETE #define ETL_NOEXCEPT #define ETL_NOEXCEPT_EXPR #define ETL_NODISCARD +#define ETL_OVERRIDE #define ETL_ERROR_TEXT #define ETL_ASSERT #define ETL_ERROR #define ETL_VERBOSE_ERRORS #define ETL_FILE +#define ETL_NULLPTR #define ETL_CPP11_SUPPORTED #define ETL_CPP14_SUPPORTED -#define ETL_CPP17_SUPPORTED \ No newline at end of file +#define ETL_CPP17_SUPPORTED + +#define TEST +#define CHECK +#define CHECK_EQUAL +#define CHECK_THROW \ No newline at end of file