Boost logo

Boost Users :

Subject: [Boost-users] boost.iterators - iterator_facade issue with aligned types.
From: Christoph Heindl (christoph.heindl_at_[hidden])
Date: 2011-01-19 08:36:24


Hi,

It seems to me that boost::iterator_facade cannot cope with aligned types
when the 'Reference = use_default' template argument is not a reference,
which can happen if transform_iterator is used to return the result of a
temporay calculation (by value of course).

Inside iterator_facade.hpp

struct operator_arrow_result {
  //...
        static type make(Reference x)
        {
            return implicit_cast<type>(&x);
        }
};

Reference here is passed by value. Since Reference has alignment the compiler
reports an error.

The issue was resolved once i changed that code to

struct operator_arrow_result {
  //...
        typedef typename mpl::if_<
            is_reference<Reference>
          , Reference
          , typename add_reference<Reference>::type
>::type input_type;

        static type make(input_type x)
        {
            return implicit_cast<type>(&x);
        }
};

I wonder about any side effects this would cause? My lousy research is based
boost 1.43. That part of the code seems to be unchanged for the current trunk.

Best regards,
Christoph


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net