File indexing completed on 2025-01-18 09:52:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_TEST_UTILS_INPUT_ITERATOR_FACADE_HPP
0013 #define BOOST_TEST_UTILS_INPUT_ITERATOR_FACADE_HPP
0014
0015
0016 #include <boost/iterator/iterator_facade.hpp>
0017
0018 #include <boost/test/detail/suppress_warnings.hpp>
0019
0020
0021
0022 namespace boost {
0023 namespace unit_test {
0024 namespace utils {
0025
0026
0027
0028
0029
0030 class input_iterator_core_access
0031 {
0032 #if defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) || BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
0033 public:
0034 #else
0035 template <class I, class V, class R, class TC> friend class input_iterator_facade;
0036 #endif
0037
0038 template <class Facade>
0039 static bool get( Facade& f )
0040 {
0041 return f.get();
0042 }
0043
0044 private:
0045
0046 input_iterator_core_access();
0047 };
0048
0049
0050
0051
0052
0053 template<typename Derived,
0054 typename ValueType,
0055 typename Reference = ValueType const&,
0056 typename Traversal = single_pass_traversal_tag>
0057 class input_iterator_facade : public iterator_facade<Derived,ValueType,Traversal,Reference>
0058 {
0059 public:
0060
0061 input_iterator_facade() : m_valid( false ), m_value() {}
0062
0063 protected:
0064 void init()
0065 {
0066 m_valid = true;
0067 increment();
0068 }
0069
0070
0071 mutable bool m_valid;
0072 ValueType m_value;
0073
0074 private:
0075 friend class boost::iterator_core_access;
0076
0077
0078 void increment()
0079 {
0080
0081 if( m_valid )
0082 m_valid = input_iterator_core_access::get( *static_cast<Derived*>(this) );
0083 }
0084 Reference dereference() const
0085 {
0086 return m_value;
0087 }
0088
0089
0090 bool equal( input_iterator_facade const& rhs ) const
0091 {
0092
0093 return !m_valid && !rhs.m_valid;
0094 }
0095 };
0096
0097 }
0098 }
0099 }
0100
0101
0102
0103 #include <boost/test/detail/enable_warnings.hpp>
0104
0105 #endif