Changeset 1377 for trunk


Ignore:
Timestamp:
Jul 16, 2008, 10:09:06 PM (13 years ago)
Author:
Peter
Message:

allow conversion in DataIterator? and WeightIterator?

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/iterator_test.cc

    r1376 r1377  
    106106  suite.add(*data_iter3 == 1.0);
    107107
     108  // testing constness conversion
     109  std::vector<double>::const_iterator c_iter(stl_vec.begin());
     110  std::vector<double>::iterator iter(stl_vec.begin());
     111  suite.add(iter==c_iter);
     112  utility::DataIterator<std::vector<double>::const_iterator> 
     113    data_iter4(c_iter);
     114  utility::DataIterator<std::vector<double>::iterator> 
     115    data_iter5(iter);
     116  suite.add(data_iter2 == data_iter5);
     117  suite.add(data_iter4 == data_iter5);
     118
    108119  classifier::MatrixLookup ml(m);
    109120  classifier::DataLookup1D dl1(ml,0,true);
  • trunk/yat/utility/DataIterator.h

    r1376 r1377  
    5656
    5757    /**
     58       \brief Conversion constructor.
     59
     60       Create a DataIterator<Base> from a DataIterator<B2>. Possible
     61       if B2 is convertible to a Base. Constructor allows implicit
     62       conversions such as iterator to const_iterator.
     63     */
     64    template<typename B2>
     65    DataIterator(DataIterator<B2> other,
     66                 typename boost::enable_if_convertible<B2, Base>::type* = 0 )
     67      : DataIterator::iterator_adaptor_(other.base()) {}
     68
     69    /**
    5870       using iterator_traits::data on Base iterator
    5971
  • trunk/yat/utility/WeightIterator.h

    r1376 r1377  
    5454
    5555    /**
     56       \brief Conversion constructor.
     57
     58       Create a WeightIterator<Base> from a
     59       WeightIterator<B2>. Possible if B2 is convertible to a
     60       Base. Constructor allows implicit conversions such as iterator
     61       to const_iterator.
     62     */
     63    template<typename B2>
     64    WeightIterator(WeightIterator<B2> other,
     65                   typename boost::enable_if_convertible<B2, Base>::type* = 0 )
     66      : WeightIterator::iterator_adaptor_(other.base()) {}
     67
     68    /**
    5669       using iterator_traits::data on Base iterator
    5770
Note: See TracChangeset for help on using the changeset viewer.