Changeset 3197


Ignore:
Timestamp:
Apr 29, 2014, 3:40:53 AM (7 years ago)
Author:
Peter
Message:

refs #790. workaround for old boost

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/bam_pair_iterator.cc

    r3196 r3197  
    2727#include "yat/omic/BamWriteIterator.h"
    2828#endif
    29 
    30 #include <boost/version.hpp>
    3129
    3230#include <algorithm>
     
    7674  for (; piter!=pend; ++piter) {
    7775    result.push_back(*piter);
     76    result.back() = *piter;
    7877    // This code doesn't work with boost 1.48 (or older). See
    7978    // https://svn.boost.org/trac/boost/ticket/5697 for details. It's
     
    8180    // and if it wasn't modify this test accordingly and update the
    8281    // docs in 'yat/omic/BamPairIterator.h'.
    83 #if BOOST_VERSION > 104800
    8482    result.back().first() = piter->first();
    8583    result.back().second() = piter->second();
    86 #endif
    8784  }
    8885  // not really doing anything since we've already iterated through
  • trunk/yat/omic/BamPairIterator.h

    r3193 r3197  
    2727#include "BamPair.h"
    2828#include "BamRead.h"
     29
     30#include <yat/utility/yat_assert.h>
    2931
    3032#include <boost/concept/assert.hpp>
     
    8486     */
    8587    explicit BamPairIterator(Base begin, Base end);
     88
     89#if BOOST_VERSION < 104900
     90    /**
     91       This is workaround implementation of operator-> when
     92       implementation in base class (boost) does not compile. This
     93       implementation may be slow, so when using old boost it often
     94       prefereble to use operator*.
     95     */
     96    typename BamPairIterator::pointer operator->(void) const
     97    {
     98      // older versions of boost mandates pointer to be
     99      // value_type*. To accomplish that we implement this slow thing
     100      // which keeps a copy of a value_type as member.
     101      // See https://svn.boost.org/trac/boost/ticket/5697 for discussion.
     102
     103      // Possibly stupid to assign each time, but why bother optimize
     104      // for old bugs in boost. Users who are eager for speed, should
     105      // either upgrade their boost or use (*iterator).function()
     106      // rather than iterator->function().
     107      YAT_ASSERT(mate_);
     108      YAT_ASSERT(iter_ != end_);
     109      dummie_.first() = *mate_;
     110      dummie_.second() = *iter_;
     111      return &dummie_;
     112    }
     113  private:
     114    mutable BamPair dummie_;
     115#endif
     116
    86117  private:
    87118    Base iter_;
Note: See TracChangeset for help on using the changeset viewer.