mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 19:05:31 +08:00
Remove std::iterator (deprecated in C++17)
This commit is contained in:
@@ -26,9 +26,18 @@ namespace BlackMisc
|
|||||||
/*!
|
/*!
|
||||||
* Configurable output iterator using a provided functor to do the insertion.
|
* Configurable output iterator using a provided functor to do the insertion.
|
||||||
*/
|
*/
|
||||||
template <class F> class OutputIterator : public std::iterator<std::output_iterator_tag, void, void, void, void>
|
template <class F> class OutputIterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
//! Types
|
||||||
|
//! @{
|
||||||
|
using iterator_category = std::output_iterator_tag;
|
||||||
|
using value_type = void;
|
||||||
|
using difference_type = void;
|
||||||
|
using pointer = void;
|
||||||
|
using reference = void;
|
||||||
|
//! @}
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
//! @{
|
//! @{
|
||||||
explicit OutputIterator(const F &func) : m_func(func) {}
|
explicit OutputIterator(const F &func) : m_func(func) {}
|
||||||
@@ -101,10 +110,16 @@ namespace BlackMisc
|
|||||||
* By creating a CRange from such iterators, it is possible to perform a transformation on a container without copying elements.
|
* By creating a CRange from such iterators, it is possible to perform a transformation on a container without copying elements.
|
||||||
*/
|
*/
|
||||||
template <class I, class F> class TransformIterator
|
template <class I, class F> class TransformIterator
|
||||||
: public std::iterator<std::forward_iterator_tag,
|
|
||||||
std::decay_t<decltype(std::declval<F>()(std::declval<typename std::iterator_traits<I>::value_type>()))>>
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
//! Types
|
||||||
|
//! @{
|
||||||
|
using iterator_category = std::forward_iterator_tag;
|
||||||
|
using value_type = std::decay_t<decltype(std::declval<F>()(std::declval<typename std::iterator_traits<I>::value_type>()))>;
|
||||||
|
using difference_type = typename std::iterator_traits<I>::difference_type;
|
||||||
|
using reference = typename std::iterator_traits<I>::reference;
|
||||||
|
//! @}
|
||||||
|
|
||||||
//! The type returned by the transformation function, which may or may not be a reference.
|
//! The type returned by the transformation function, which may or may not be a reference.
|
||||||
using undecayed_type = decltype(std::declval<F>()(std::declval<typename std::iterator_traits<I>::value_type>()));
|
using undecayed_type = decltype(std::declval<F>()(std::declval<typename std::iterator_traits<I>::value_type>()));
|
||||||
|
|
||||||
@@ -166,9 +181,18 @@ namespace BlackMisc
|
|||||||
*
|
*
|
||||||
* By creating a CRange from such iterators, it is possible to return the results of predicate methods without copying elements.
|
* By creating a CRange from such iterators, it is possible to return the results of predicate methods without copying elements.
|
||||||
*/
|
*/
|
||||||
template <class I, class F> class ConditionalIterator : public std::iterator<std::forward_iterator_tag, typename std::iterator_traits<I>::value_type>
|
template <class I, class F> class ConditionalIterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
//! Types
|
||||||
|
//! @{
|
||||||
|
using iterator_category = std::forward_iterator_tag;
|
||||||
|
using value_type = typename std::iterator_traits<I>::value_type;
|
||||||
|
using difference_type = typename std::iterator_traits<I>::difference_type;
|
||||||
|
using pointer = typename std::iterator_traits<I>::pointer;
|
||||||
|
using reference = typename std::iterator_traits<I>::reference;
|
||||||
|
//! @}
|
||||||
|
|
||||||
//! Constructor.
|
//! Constructor.
|
||||||
ConditionalIterator(I iterator, I end, F predicate) : m_iterator(iterator), m_end(end), m_predicate(predicate)
|
ConditionalIterator(I iterator, I end, F predicate) : m_iterator(iterator), m_end(end), m_predicate(predicate)
|
||||||
{
|
{
|
||||||
@@ -230,9 +254,18 @@ namespace BlackMisc
|
|||||||
/*!
|
/*!
|
||||||
* Iterator wrapper which concatenates zero or more pairs of begin and end iterators.
|
* Iterator wrapper which concatenates zero or more pairs of begin and end iterators.
|
||||||
*/
|
*/
|
||||||
template <class I> class ConcatIterator : public std::iterator<std::forward_iterator_tag, typename std::iterator_traits<I>::value_type>
|
template <class I> class ConcatIterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
//! Types
|
||||||
|
//! @{
|
||||||
|
using iterator_category = std::forward_iterator_tag;
|
||||||
|
using value_type = typename std::iterator_traits<I>::value_type;
|
||||||
|
using difference_type = typename std::iterator_traits<I>::difference_type;
|
||||||
|
using pointer = typename std::iterator_traits<I>::pointer;
|
||||||
|
using reference = typename std::iterator_traits<I>::reference;
|
||||||
|
//! @}
|
||||||
|
|
||||||
//! Constructor.
|
//! Constructor.
|
||||||
ConcatIterator(QVector<I> iterators) : m_iterators(std::move(iterators))
|
ConcatIterator(QVector<I> iterators) : m_iterators(std::move(iterators))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user