2004-01-12 20:58:22 +00:00
|
|
|
// Copyright David Abrahams 2004. Use, modification and distribution is
|
|
|
|
// subject to the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
#ifndef NODE_ITERATOR3_DWA2004110_HPP
|
|
|
|
# define NODE_ITERATOR3_DWA2004110_HPP
|
|
|
|
|
|
|
|
# include "node.hpp"
|
|
|
|
# include <boost/iterator/iterator_adaptor.hpp>
|
2025-01-26 15:17:36 +03:00
|
|
|
# include <type_traits>
|
2004-01-12 20:58:22 +00:00
|
|
|
|
|
|
|
template <class Value>
|
|
|
|
class node_iter
|
|
|
|
: public boost::iterator_adaptor<
|
|
|
|
node_iter<Value> // Derived
|
|
|
|
, Value* // Base
|
|
|
|
, boost::use_default // Value
|
|
|
|
, boost::forward_traversal_tag // CategoryOrTraversal
|
|
|
|
>
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
struct enabler {}; // a private type avoids misuse
|
|
|
|
|
|
|
|
typedef boost::iterator_adaptor<
|
|
|
|
node_iter<Value>, Value*, boost::use_default, boost::forward_traversal_tag
|
|
|
|
> super_t;
|
2022-01-13 17:32:11 +03:00
|
|
|
|
2004-01-12 20:58:22 +00:00
|
|
|
public:
|
|
|
|
node_iter()
|
|
|
|
: super_t(0) {}
|
|
|
|
|
|
|
|
explicit node_iter(Value* p)
|
|
|
|
: super_t(p) {}
|
|
|
|
|
|
|
|
template <class OtherValue>
|
|
|
|
node_iter(
|
|
|
|
node_iter<OtherValue> const& other
|
2025-01-26 15:17:36 +03:00
|
|
|
, typename std::enable_if<
|
|
|
|
std::is_convertible<OtherValue*,Value*>::value
|
2004-01-12 20:58:22 +00:00
|
|
|
, enabler
|
|
|
|
>::type = enabler()
|
|
|
|
)
|
2004-01-14 04:38:14 +00:00
|
|
|
: super_t(other.base()) {}
|
2004-01-12 20:58:22 +00:00
|
|
|
|
2004-01-29 13:33:33 +00:00
|
|
|
# if !BOOST_WORKAROUND(__GNUC__, == 2)
|
2022-01-13 17:32:11 +03:00
|
|
|
private: // GCC2 can't grant friendship to template member functions
|
2004-01-12 20:58:22 +00:00
|
|
|
friend class boost::iterator_core_access;
|
2022-01-13 17:32:11 +03:00
|
|
|
# endif
|
2004-01-12 20:58:22 +00:00
|
|
|
void increment() { this->base_reference() = this->base()->next(); }
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef node_iter<node_base> node_iterator;
|
|
|
|
typedef node_iter<node_base const> node_const_iterator;
|
|
|
|
|
|
|
|
#endif // NODE_ITERATOR3_DWA2004110_HPP
|