Loading...
Searching...
No Matches
fixed_iterator.h
Go to the documentation of this file.
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2015 John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_FIXED_ITERATOR_INCLUDED
#define ETL_FIXED_ITERATOR_INCLUDED
#include "platform.h"
#include "iterator.h"
namespace etl
{
template <typename TIterator>
class fixed_iterator
: etl::iterator<typename etl::iterator_traits<TIterator>::iterator_category, typename etl::iterator_traits<TIterator>::value_type>
{
public:
//***************************************************************************
//***************************************************************************
ETL_CONSTEXPR fixed_iterator()
: it(TIterator())
{
}
//***************************************************************************
//***************************************************************************
ETL_CONSTEXPR fixed_iterator(TIterator it_)
: it(it_)
{
}
//***************************************************************************
//***************************************************************************
ETL_CONSTEXPR fixed_iterator(const fixed_iterator& other)
: it(other.it)
{
}
//***************************************************************************
//***************************************************************************
ETL_CONSTEXPR14 fixed_iterator& operator++()
{
return *this;
}
//***************************************************************************
//***************************************************************************
ETL_CONSTEXPR14 fixed_iterator operator++(int)
{
return *this;
}
//***************************************************************************
//***************************************************************************
ETL_CONSTEXPR14 fixed_iterator& operator--()
{
return *this;
}
//***************************************************************************
//***************************************************************************
ETL_CONSTEXPR14 fixed_iterator operator--(int)
{
return *this;
}
//***************************************************************************
//***************************************************************************
ETL_CONSTEXPR14 typename etl::iterator_traits<TIterator>::reference operator*()
{
return *it;
}
//***************************************************************************
//***************************************************************************
ETL_CONSTEXPR typename etl::iterator_traits<TIterator>::reference operator*() const
{
return *it;
}
//***************************************************************************
//***************************************************************************
ETL_CONSTEXPR14 TIterator operator->()
{
return it;
}
//***************************************************************************
//***************************************************************************
ETL_CONSTEXPR const TIterator operator->() const
{
return it;
}
//***************************************************************************
//***************************************************************************
ETL_CONSTEXPR operator TIterator() const
{
return it;
}
//***************************************************************************
//***************************************************************************
ETL_CONSTEXPR14 fixed_iterator& operator+=(typename etl::iterator_traits<TIterator>::difference_type /*offset*/)
{
return *this;
}
//***************************************************************************
//***************************************************************************
ETL_CONSTEXPR14 fixed_iterator& operator-=(typename etl::iterator_traits<TIterator>::difference_type /*offset*/)
{
return *this;
}
//***************************************************************************
//***************************************************************************
ETL_CONSTEXPR14 fixed_iterator& operator=(TIterator new_it)
{
it = new_it;
return *this;
}
//***************************************************************************
//***************************************************************************
ETL_CONSTEXPR14 fixed_iterator& operator=(fixed_iterator other)
{
it = other.it;
return *this;
}
private:
TIterator it;
};
//*****************************************************************************
//*****************************************************************************
template <typename TIterator>
ETL_CONSTEXPR14 etl::fixed_iterator<TIterator>& operator+(etl::fixed_iterator<TIterator>& lhs,
typename etl::iterator_traits<TIterator>::difference_type /*rhs*/)
{
return lhs;
}
//*****************************************************************************
//*****************************************************************************
template <typename TIterator>
ETL_CONSTEXPR14 etl::fixed_iterator<TIterator>& operator-(etl::fixed_iterator<TIterator>& lhs,
typename etl::iterator_traits<TIterator>::difference_type /*rhs*/)
{
return lhs;
}
//*****************************************************************************
//*****************************************************************************
template <typename TIterator>
ETL_CONSTEXPR typename etl::iterator_traits<TIterator>::difference_type operator-(const etl::fixed_iterator<TIterator>& lhs,
const etl::fixed_iterator<TIterator>& rhs)
{
return TIterator(lhs) - TIterator(rhs);
}
//*****************************************************************************
//*****************************************************************************
template <typename TIterator>
ETL_CONSTEXPR bool operator==(const etl::fixed_iterator<TIterator>& lhs, const etl::fixed_iterator<TIterator>& rhs)
{
return TIterator(lhs) == TIterator(rhs);
}
//*****************************************************************************
//*****************************************************************************
template <typename TIterator>
ETL_CONSTEXPR bool operator==(const etl::fixed_iterator<TIterator>& lhs, TIterator rhs)
{
return TIterator(lhs) == rhs;
}
//*****************************************************************************
//*****************************************************************************
template <typename TIterator>
ETL_CONSTEXPR bool operator==(TIterator lhs, const etl::fixed_iterator<TIterator>& rhs)
{
return lhs == TIterator(rhs);
}
//*****************************************************************************
//*****************************************************************************
template <typename TIterator>
ETL_CONSTEXPR bool operator!=(const etl::fixed_iterator<TIterator>& lhs, const etl::fixed_iterator<TIterator>& rhs)
{
return !(lhs == rhs);
}
//*****************************************************************************
//*****************************************************************************
template <typename TIterator>
ETL_CONSTEXPR bool operator!=(const etl::fixed_iterator<TIterator>& lhs, TIterator rhs)
{
return !(lhs == rhs);
}
//*****************************************************************************
//*****************************************************************************
template <typename TIterator>
ETL_CONSTEXPR bool operator!=(TIterator lhs, const etl::fixed_iterator<TIterator>& rhs)
{
return !(lhs == rhs);
}
} // namespace etl
#endif
etl::fixed_iterator::operator*
ETL_CONSTEXPR etl::iterator_traits< TIterator >::reference operator*() const
Dereference operator.
Definition fixed_iterator.h:119
etl::fixed_iterator::operator-=
ETL_CONSTEXPR14 fixed_iterator & operator-=(typename etl::iterator_traits< TIterator >::difference_type)
-= operator.
Definition fixed_iterator.h:159
etl::fixed_iterator::operator--
ETL_CONSTEXPR14 fixed_iterator operator--(int)
Decrement (Does nothing).
Definition fixed_iterator.h:103
etl::fixed_iterator::operator=
ETL_CONSTEXPR14 fixed_iterator & operator=(TIterator new_it)
Assignment from iterator.
Definition fixed_iterator.h:167
etl::fixed_iterator::operator->
ETL_CONSTEXPR const TIterator operator->() const
-> operator.
Definition fixed_iterator.h:135
etl::fixed_iterator::operator+=
ETL_CONSTEXPR14 fixed_iterator & operator+=(typename etl::iterator_traits< TIterator >::difference_type)
+= operator.
Definition fixed_iterator.h:151
etl::fixed_iterator::fixed_iterator
ETL_CONSTEXPR fixed_iterator(const fixed_iterator &other)
Copy constructor.
Definition fixed_iterator.h:71
etl::fixed_iterator::fixed_iterator
ETL_CONSTEXPR fixed_iterator()
Default constructor.
Definition fixed_iterator.h:55
etl::fixed_iterator::operator--
ETL_CONSTEXPR14 fixed_iterator & operator--()
Decrement (Does nothing).
Definition fixed_iterator.h:95
etl::fixed_iterator::operator++
ETL_CONSTEXPR14 fixed_iterator & operator++()
Increment (Does nothing).
Definition fixed_iterator.h:79
etl::fixed_iterator::operator=
ETL_CONSTEXPR14 fixed_iterator & operator=(fixed_iterator other)
Assignment from fixed_iterator.
Definition fixed_iterator.h:176
etl::fixed_iterator::fixed_iterator
ETL_CONSTEXPR fixed_iterator(TIterator it_)
Construct from iterator.
Definition fixed_iterator.h:63
etl::fixed_iterator::operator*
ETL_CONSTEXPR14 etl::iterator_traits< TIterator >::reference operator*()
Dereference operator.
Definition fixed_iterator.h:111
etl::fixed_iterator::operator->
ETL_CONSTEXPR14 TIterator operator->()
-> operator.
Definition fixed_iterator.h:127
etl::fixed_iterator::operator++
ETL_CONSTEXPR14 fixed_iterator operator++(int)
Increment (Does nothing).
Definition fixed_iterator.h:87
etl::fixed_iterator
Definition fixed_iterator.h:49
iterator.h
etl
Definition absolute.h:40
etl::operator==
ETL_CONSTEXPR14 bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1078
etl::operator-
ETL_CONSTEXPR14 etl::circular_iterator< TIterator > operator-(etl::circular_iterator< TIterator > &lhs, typename etl::iterator_traits< TIterator >::difference_type offset)
Definition circular_iterator.h:675
etl::operator!=
ETL_CONSTEXPR14 bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1090
etl::operator+
ETL_CONSTEXPR14 etl::circular_iterator< TIterator > operator+(etl::circular_iterator< TIterator > &lhs, typename etl::iterator_traits< TIterator >::difference_type offset)
Definition circular_iterator.h:662
platform.h
etl::iterator
iterator
Definition iterator.h:482