Changeset 2282


Ignore:
Timestamp:
Jun 26, 2010, 3:38:17 AM (11 years ago)
Author:
Peter
Message:

document and test that DataIterator? and WeightIterator? works with/requires input_iterator. closes #633

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/iterator_test.cc

    r2277 r2282  
    6666
    6767void test_data_iterator(test::Suite& suite);
     68void test_weight_iterator(test::Suite& suite);
    6869void test_iterator_traits(test::Suite& suite);
    6970void test_stride_iterator(test::Suite& suite);
     
    8788  test_weighted_iterator(suite);
    8889  test_data_iterator(suite);
     90  test_weight_iterator(suite);
    8991  return suite.return_value();
    9092}
     
    311313            data_iterator(forward_it));
    312314
    313 #ifdef YAT_TICKET_633
    314   input_iterator_archetype<utility::DataWeight> input_it_w;
     315  boost::input_iterator_archetype_no_proxy<utility::DataWeight> input_it_w;
    315316  mutable_forward_iterator_archetype<utility::DataWeight> forward_it_w;
    316317  std::copy(data_iterator(input_it_w),
    317318            data_iterator(input_it_w),
    318319            data_iterator(forward_it_w));
    319 #endif
     320
     321}
     322
     323
     324void test_weight_iterator(test::Suite& suite)
     325{
     326  // do not run compile test
     327  return;
     328
     329  using utility::WeightIterator;
     330  using boost::input_iterator_archetype;
     331  input_iterator_archetype<double> input_it;
     332  using boost::mutable_forward_iterator_archetype;
     333 
     334  // we are using weighted here because unweighted WeightIterator is
     335  // always const (not mutable)
     336  mutable_forward_iterator_archetype<utility::DataWeight> forward_it_w;
     337
     338  using utility::weight_iterator;
     339  std::copy(weight_iterator(input_it),
     340            weight_iterator(input_it),
     341            weight_iterator(forward_it_w));
     342
     343  boost::input_iterator_archetype_no_proxy<utility::DataWeight> input_it_w;
     344  std::copy(weight_iterator(input_it_w),
     345            weight_iterator(input_it_w),
     346            weight_iterator(forward_it_w));
    320347}
    321348
     
    347374  w = traits2.weight(&dwp);
    348375  delete trivial_iter;
     376
     377  // do not run compile test
     378  return;
     379  using utility::DataWeight;
     380  using utility::iterator_traits;
     381  // iterator_traits does not work with a proxy that lacks member
     382  // function data() so we test with no_proxy archetype instead.
     383  typedef boost::input_iterator_archetype_no_proxy<DataWeight> input;
     384  utility::iterator_traits<input> traits3;
     385  w = traits3.weight(input());
     386  typedef boost::output_iterator_archetype<DataWeight> output; 
     387  utility::iterator_traits<output> traits4;
     388  w = traits4.weight(boost::detail::dummy_constructor());
    349389}
    350390
  • trunk/yat/utility/DataIterator.h

    r2202 r2282  
    2626#include "iterator_traits.h"
    2727
     28#include <boost/concept_check.hpp>
    2829#include <boost/iterator/iterator_adaptor.hpp>
    2930#include <boost/type_traits/remove_reference.hpp>
     
    5455
    5556     \endcode
     57
     58    Type Requirement: \c BASE must be an \input_iterator
    5659  */
    5760  template<typename Base>
     
    7174     */
    7275    explicit DataIterator(Base b)
    73       : DataIterator::iterator_adaptor_(b) {}
     76      : DataIterator::iterator_adaptor_(b)
     77    {
     78      BOOST_CONCEPT_ASSERT((boost::InputIterator<Base>));
     79    }
    7480
    7581    /**
     
    7985     */
    8086    DataIterator(void)
    81       : DataIterator::iterator_adaptor_() {}
     87      : DataIterator::iterator_adaptor_()
     88    {
     89      BOOST_CONCEPT_ASSERT((boost::InputIterator<Base>));
     90    }
    8291
    8392    /**
  • trunk/yat/utility/WeightIterator.h

    r2202 r2282  
    2424*/
    2525
     26#include "iterator_traits.h"
     27
     28#include <boost/concept_check.hpp>
    2629#include <boost/iterator/iterator_adaptor.hpp>
    2730#include <boost/type_traits/remove_reference.hpp>
     
    5255
    5356     \endcode
     57
     58    Type Requirement: \c BASE must be an \input_iterator
    5459  */
    5560  template<typename Base>
     
    7176     */
    7277    WeightIterator(void)
    73       : WeightIterator::iterator_adaptor_() {}
     78      : WeightIterator::iterator_adaptor_()
     79    {
     80      BOOST_CONCEPT_ASSERT((boost::InputIterator<Base>));
     81    }
    7482
    7583    /**
     
    7785     */
    7886    explicit WeightIterator(Base b)
    79       : WeightIterator::iterator_adaptor_(b) {}
     87      : WeightIterator::iterator_adaptor_(b)
     88    {
     89      BOOST_CONCEPT_ASSERT((boost::InputIterator<Base>));
     90    }
    8091
    8192    /**
Note: See TracChangeset for help on using the changeset viewer.