15 #ifndef PAAL_SINGLETON_ITERATOR_HPP
16 #define PAAL_SINGLETON_ITERATOR_HPP
18 #include <boost/iterator/iterator_facade.hpp>
19 #include <boost/optional/optional.hpp>
20 #include <boost/range/iterator_range.hpp>
29 template <
typename Elem>
31 singleton_iterator<Elem>, typename std::decay<Elem>::type,
32 boost::forward_traversal_tag, Elem> {
46 friend class boost::iterator_core_access;
48 void increment() { m_elem = boost::none; }
52 return (!m_elem && !other.m_elem) || (m_elem && other.m_elem);
55 Elem dereference()
const {
return m_elem.get(); }
57 boost::optional<Elem> m_elem;
76 template <
typename Elem>
88 template <
typename Elem>
101 template <
typename Elem>
103 -> decltype(boost::make_iterator_range(
105 make_singleton_iterator_end<Elem>()
107 return boost::make_iterator_range(
109 make_singleton_iterator_end<Elem>()
116 #endif // PAAL_SINGLETON_ITERATOR_HPP
auto make_singleton_range(Elem &&elem) -> decltype(boost::make_iterator_range(make_singleton_iterator_begin(std::forward< Elem >(elem)), make_singleton_iterator_end< Elem >()))
function to create a singleton range
friend singleton_iterator< E > make_singleton_iterator_end()
function to create end of singleton_iterator
singleton_iterator()
public constructor to satisfy the concept requirements. However one should use make_singleton_iterato...
singleton_iterator< Elem > make_singleton_iterator_end()
function to create end of singleton_iterator
Iterator to range containing single element.
singleton_iterator< Elem > make_singleton_iterator_begin(Elem &&elem)
function to create begin of singleton_iterator