Changeset 958 for trunk/yat/utility


Ignore:
Timestamp:
Oct 10, 2007, 5:44:06 PM (14 years ago)
Author:
Peter
Message:

allowing mixture of weighted and unweighted iterators in vector_distance

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/iterator_traits.h

    r937 r958  
    5656
    5757  // but specialized to return weighted type for some things
     58  //
     59  // if you add a new weighted iterator, add a new specialization like
     60  // this one.
    5861  template <class U, class V>
    5962  struct weighted_iterator_traits<yat::utility::IteratorWeighted<U,V> > {
     
    6467
    6568  /*
    66     struct used to determine if a pair of iterators should be treated
    67     as weighted
    68 
     69    Metafunction that works on a pair weighted-unweighted types and
     70    return weighted_type. The metafunction is specialized for
     71    unweighted unweighted in which case unweighted is returned.
     72   */
    6973  template <class T1, class T2>
    70   struct weighted_iterator_traits2 {
     74  struct unweighted_type_and {
    7175    typedef weighted_type type;
    7276  };
    7377
    74   // but specialized to return weighted type for some things
     78  /*
     79    Specialization that sets type to be unweighted when both arguments
     80    are unweighted
     81   */
     82  template <>
     83  struct unweighted_type_and<unweighted_type, unweighted_type> {
     84    typedef unweighted_type type;
     85  };
     86
     87  /*
     88    struct used to determine if a pair of iterators should be treated
     89    as weighted. If both iterators are unweighted, type is set to
     90    unweighted else weighted.
     91  */
    7592  template <class T1, class T2>
    76   struct weighted_iterator_traits2<yat::utility::IteratorWeighted<U,V> > {
    77     typedef weighted_type type;
     93  struct weighted_if_any2 {
     94    typedef typename weighted_iterator_traits<T1>::type w_type1;
     95    typedef typename weighted_iterator_traits<T2>::type w_type2;
     96    typedef typename unweighted_type_and<w_type1, w_type2>::type type;
    7897  };
    79   */
     98
     99  /*
     100    Same as weighted_iterator_traits2 but for 3 arguments.
     101   */
     102  template <class T1, class T2, class T3>
     103  struct weighted_if_any3 {
     104    typedef typename weighted_if_any2<T1, T2>::type tmp;
     105    typedef typename weighted_iterator_traits<T3>::type w_type3;
     106    typedef typename unweighted_type_and<tmp, w_type3>::type type;
     107  };
    80108
    81109  // check (at compile time) that iterator is unweighted.
Note: See TracChangeset for help on using the changeset viewer.