diff --git a/include/etl/generators/type_lookup_generator.h b/include/etl/generators/type_lookup_generator.h index 9a5e9552..b024bf8d 100644 --- a/include/etl/generators/type_lookup_generator.h +++ b/include/etl/generators/type_lookup_generator.h @@ -244,7 +244,7 @@ namespace etl cog.outl(" template ") cog.outl(" struct type_from_id") cog.outl(" {") - cog.outl(" typedef ") + cog.outl(" typedef") for n in range(1, int(NTypes) + 1): cog.outl(" typename etl::conditional >") @@ -311,7 +311,7 @@ namespace etl cog.outl(" template ") cog.outl(" struct type_from_type") cog.outl(" {") - cog.outl(" typedef ") + cog.outl(" typedef") for n in range(1, int(NTypes) + 1): cog.outl(" typename etl::conditional::value, typename T%s::type2," %(n, n)) cog.out(" etl::null_type<0> >") diff --git a/include/etl/iterator.h b/include/etl/iterator.h index b3cfd3f7..9243aac8 100644 --- a/include/etl/iterator.h +++ b/include/etl/iterator.h @@ -38,7 +38,7 @@ SOFTWARE. #include "private/addressof.h" #if ETL_USING_STL || defined(ETL_IN_UNIT_TEST) - #include +#include #endif ///\defgroup iterator iterator @@ -142,8 +142,7 @@ namespace etl template ETL_CONSTEXPR14 void advance_helper(TIterator& itr, TDistance n, ETL_OR_STD::random_access_iterator_tag) { - typedef typename etl::iterator_traits::difference_type diff_t; - itr += static_cast(n); + itr += n; } template @@ -667,8 +666,8 @@ namespace etl //*************************************************************************** template ETL_NODISCARD - ETL_CONSTEXPR14 - etl::back_insert_iterator back_inserter(TContainer& container) + ETL_CONSTEXPR14 + etl::back_insert_iterator back_inserter(TContainer& container) { return etl::back_insert_iterator(container); } @@ -749,8 +748,8 @@ namespace etl //*************************************************************************** template ETL_NODISCARD - ETL_CONSTEXPR14 - etl::front_insert_iterator front_inserter(TContainer& container) + ETL_CONSTEXPR14 + etl::front_insert_iterator front_inserter(TContainer& container) { return etl::front_insert_iterator(container); } @@ -901,9 +900,9 @@ namespace etl struct is_input_iterator_concept { static ETL_CONSTANT bool value = etl::is_input_iterator::value || - etl::is_forward_iterator::value || - etl::is_bidirectional_iterator::value || - etl::is_random_iterator::value; + etl::is_forward_iterator::value || + etl::is_bidirectional_iterator::value || + etl::is_random_iterator::value; }; template @@ -913,9 +912,9 @@ namespace etl struct is_output_iterator_concept { static ETL_CONSTANT bool value = etl::is_output_iterator::value || - etl::is_forward_iterator::value || - etl::is_bidirectional_iterator::value || - etl::is_random_iterator::value; + etl::is_forward_iterator::value || + etl::is_bidirectional_iterator::value || + etl::is_random_iterator::value; }; template @@ -925,8 +924,8 @@ namespace etl struct is_forward_iterator_concept { static ETL_CONSTANT bool value = etl::is_forward_iterator::value || - etl::is_bidirectional_iterator::value || - etl::is_random_iterator::value; + etl::is_bidirectional_iterator::value || + etl::is_random_iterator::value; }; template @@ -936,7 +935,7 @@ namespace etl struct is_bidirectional_iterator_concept { static ETL_CONSTANT bool value = etl::is_bidirectional_iterator::value || - etl::is_random_iterator::value; + etl::is_random_iterator::value; }; template @@ -1355,7 +1354,7 @@ namespace etl template::value || etl::is_output_iterator_concept::value) && !etl::is_same::value>> - constexpr etl::iter_difference_t operator()(I first, S last) const + constexpr etl::iter_difference_t operator()(I first, S last) const { etl::iter_difference_t n = 0; while (!(first == last)) @@ -1382,8 +1381,8 @@ namespace etl { using iter_type = decltype(ETL_OR_STD::begin(t)); static_assert(etl::is_forward_iterator_concept::value, - "ranges::size requires a sized range or at least a forward range; " - "single-pass input ranges are not supported"); + "ranges::size requires a sized range or at least a forward range; " + "single-pass input ranges are not supported"); return static_cast(distance{}(ETL_OR_STD::begin(t), ETL_OR_STD::end(t))); } } @@ -1404,8 +1403,8 @@ namespace etl { using iter_type = decltype(ETL_OR_STD::begin(t)); static_assert(etl::is_forward_iterator_concept::value, - "ranges::ssize requires a sized range or at least a forward range; " - "single-pass input ranges are not supported"); + "ranges::ssize requires a sized range or at least a forward range; " + "single-pass input ranges are not supported"); return static_cast(distance{}(ETL_OR_STD::begin(t), ETL_OR_STD::end(t))); } } @@ -1541,7 +1540,7 @@ namespace etl template::value || etl::is_output_iterator_concept::value>> constexpr etl::iter_difference_t - operator()(I& i, etl::iter_difference_t n, S bound) const + operator()(I& i, etl::iter_difference_t n, S bound) const { if constexpr (etl::is_same_v && etl::is_random_access_iterator_concept::value) { @@ -1704,216 +1703,212 @@ namespace etl template class counted_iterator { - template friend class counted_iterator; + template friend class counted_iterator; - public: - using iterator_type = I; - using value_type = etl::iter_value_t; - using difference_type = etl::iter_difference_t; - using iterator_category = typename etl::iterator_traits::iterator_category; - using pointer = typename etl::iterator_traits::pointer; - using reference = typename etl::iterator_traits::reference; + public: + using iterator_type = I; + using value_type = etl::iter_value_t; + using difference_type = etl::iter_difference_t; + using iterator_category = typename etl::iterator_traits::iterator_category; + using pointer = typename etl::iterator_traits::pointer; + using reference = typename etl::iterator_traits::reference; - constexpr counted_iterator() = default; + constexpr counted_iterator() = default; - constexpr counted_iterator(I x, etl::iter_difference_t n): current(etl::move(x)), length(n) - { - } + constexpr counted_iterator(I x, etl::iter_difference_t n): current(etl::move(x)), length(n) + { + } - template - constexpr counted_iterator(const counted_iterator& other): current(other.current), length(other.length) - { - } + template + constexpr counted_iterator(const counted_iterator& other): current(other.current), length(other.length) + { + } - template - constexpr counted_iterator& operator=(const counted_iterator& other) - { - current = other.current; - length = other.length; - return *this; - } + template + constexpr counted_iterator& operator=(const counted_iterator& other) + { + current = other.current; + length = other.length; + return *this; + } - constexpr const I& base() const& noexcept - { - return current; - } + constexpr const I& base() const& noexcept + { + return current; + } - constexpr I base() && - { - return etl::move(current); - } + constexpr I base() && + { + return etl::move(current); + } - constexpr etl::iter_difference_t count() const noexcept - { - return length; - } + constexpr etl::iter_difference_t count() const noexcept + { + return length; + } - constexpr decltype(auto) operator*() const - { - return *current; - } + constexpr decltype(auto) operator*() const + { + return *current; + } - // operator-> for iterator types that provide a member operator-> - template::value || etl::is_output_iterator_concept::value) && - private_iterator::has_arrow_operator::value, int> = 0> - constexpr auto operator->() const noexcept - { - return current.operator->(); - } + // operator-> for iterator types that provide a member operator-> + template::value || etl::is_output_iterator_concept::value) && + private_iterator::has_arrow_operator::value, int> = 0> + constexpr auto operator->() const noexcept + { + return current.operator->(); + } - // operator-> fallback for raw-pointer iterators (addressof is always safe) - template::value || etl::is_output_iterator_concept::value) && - !private_iterator::has_arrow_operator::value && - etl::is_pointer::value, int> = 0> - constexpr auto operator->() const noexcept - { - return current; - } + // operator-> fallback for raw-pointer iterators (addressof is always safe) + template::value || etl::is_output_iterator_concept::value) && + !private_iterator::has_arrow_operator::value && + etl::is_pointer::value, int> = 0> + constexpr auto operator->() const noexcept + { + return current; + } - // operator-> fallback for class-type iterators without member operator-> - // When *current yields an lvalue reference, just take its address. - template::value || etl::is_output_iterator_concept::value) && - !private_iterator::has_arrow_operator::value && - !etl::is_pointer::value && - etl::is_lvalue_reference())>::value, int> = 0> - constexpr auto operator->() const noexcept - { - return etl::addressof(*current); - } + // operator-> fallback for class-type iterators without member operator-> + // When *current yields an lvalue reference, just take its address. + template::value || etl::is_output_iterator_concept::value) && + !private_iterator::has_arrow_operator::value && + !etl::is_pointer::value && + etl::is_lvalue_reference())>::value, int> = 0> + constexpr auto operator->() const noexcept + { + return etl::addressof(*current); + } - // operator-> fallback for class-type iterators without member operator-> - // When *current yields a prvalue / proxy, use an owning proxy so the - // address remains valid. - template::value || etl::is_output_iterator_concept::value) && - !private_iterator::has_arrow_operator::value && - !etl::is_pointer::value && - !etl::is_lvalue_reference())>::value, int> = 0> - constexpr auto operator->() const - { - return private_iterator::arrow_proxy{*current}; - } + // operator-> fallback for class-type iterators without member operator-> + // When *current yields a prvalue / proxy, use an owning proxy so the + // address remains valid. + template::value || etl::is_output_iterator_concept::value) && + !private_iterator::has_arrow_operator::value && + !etl::is_pointer::value && + !etl::is_lvalue_reference())>::value, int> = 0> + constexpr auto operator->() const + { + return private_iterator::arrow_proxy{*current}; + } - template::value, int> = 0> - constexpr decltype(auto) operator[](etl::iter_difference_t n) const - { - return current[n]; - } + template::value, int> = 0> + constexpr decltype(auto) operator[](etl::iter_difference_t n) const + { + return current[n]; + } - constexpr counted_iterator& operator++() - { - ++current; - --length; - return *this; - } + constexpr counted_iterator& operator++() + { + ++current; + --length; + return *this; + } - constexpr counted_iterator operator++(int) - { - counted_iterator tmp = *this; - current++; - length--; - return tmp; - } + constexpr counted_iterator operator++(int) + { + counted_iterator tmp = *this; + current++; + length--; + return tmp; + } - template::value, int> = 0> - constexpr counted_iterator& operator+=(etl::iter_difference_t n) - { - current += n; - length -= n; - return *this; - } + template::value, int> = 0> + constexpr counted_iterator& operator+=(etl::iter_difference_t n) + { + current += n; + length -= n; + return *this; + } - template::value, int> = 0> - constexpr counted_iterator operator+(etl::iter_difference_t n) const - { - counted_iterator result{*this}; - result += n; - return result; - } + template::value, int> = 0> + constexpr counted_iterator operator+(etl::iter_difference_t n) const + { + counted_iterator result{*this}; + result += n; + return result; + } - constexpr counted_iterator& operator--() - { - --current; - ++length; - return *this; - } + constexpr counted_iterator& operator--() + { + --current; + ++length; + return *this; + } - constexpr counted_iterator operator--(int) - { - counted_iterator tmp = *this; - current--; - length++; - return tmp; - } + constexpr counted_iterator operator--(int) + { + counted_iterator tmp = *this; + current--; + length++; + return tmp; + } - template::value, int> = 0> - constexpr counted_iterator& operator-=(etl::iter_difference_t n) - { - current -= n; - length += n; - return *this; - } + template::value, int> = 0> + constexpr counted_iterator& operator-=(etl::iter_difference_t n) + { + current -= n; + length += n; + return *this; + } - template::value, int> = 0> - constexpr counted_iterator operator-(etl::iter_difference_t n) const - { - counted_iterator result{*this}; - result -= n; - return result; - } + template::value, int> = 0> + constexpr counted_iterator operator-(etl::iter_difference_t n) const + { + counted_iterator result{*this}; + result -= n; + return result; + } - friend constexpr bool operator==(const counted_iterator& x, const counted_iterator& y) - { - return x.length == y.length; - } + friend constexpr bool operator==(const counted_iterator& x, const counted_iterator& y) + { + return x.length == y.length; + } - friend constexpr bool operator==(const counted_iterator& x, etl::default_sentinel_t) - { - return x.count() == 0; - } + friend constexpr bool operator==(const counted_iterator& x, etl::default_sentinel_t) + { + return x.count() == 0; + } - friend constexpr bool operator==(etl::default_sentinel_t, const counted_iterator& x) - { - return x.count() == 0; - } + friend constexpr bool operator==(etl::default_sentinel_t, const counted_iterator& x) + { + return x.count() == 0; + } - friend constexpr bool operator!=(const counted_iterator& x, etl::default_sentinel_t) - { - return x.count() != 0; - } + friend constexpr bool operator!=(const counted_iterator& x, etl::default_sentinel_t) + { + return x.count() != 0; + } - friend constexpr bool operator!=(etl::default_sentinel_t, const counted_iterator& y) - { - return y.count() != 0; - } + friend constexpr bool operator!=(etl::default_sentinel_t, const counted_iterator& y) + { + return y.count() != 0; + } - template::value, int> = 0> - friend constexpr counted_iterator operator+(etl::iter_difference_t n, const counted_iterator& x) - { - return counted_iterator(x.current + n, x.length - n); - } + template::value, int> = 0> + friend constexpr counted_iterator operator+(etl::iter_difference_t n, const counted_iterator& x) + { + return counted_iterator(x.current + n, x.length - n); + } - friend constexpr etl::iter_difference_t operator-(const counted_iterator& x, const counted_iterator& y) - { - return y.length - x.length; - } + friend constexpr etl::iter_difference_t operator-(const counted_iterator& x, const counted_iterator& y) + { + return y.length - x.length; + } - friend constexpr etl::iter_difference_t operator-(const counted_iterator& x, etl::default_sentinel_t) - { - return -x.length; - } + friend constexpr etl::iter_difference_t operator-(const counted_iterator& x, etl::default_sentinel_t) + { + return -x.length; + } - friend constexpr etl::iter_difference_t operator-(etl::default_sentinel_t, const counted_iterator& y) - { - return y.length; - } + friend constexpr etl::iter_difference_t operator-(etl::default_sentinel_t, const counted_iterator& y) + { + return y.length; + } - private: - I current{}; - difference_type length{}; + private: + I current{}; + difference_type length{}; }; template, TIterator>::value>>