Boost logo

Boost Users :

Subject: [Boost-users] iterator adaptor (complex->real)
From: Neal Becker (ndbecker2_at_[hidden])
Date: 2009-12-23 07:22:21

I've been using an iterator adaptor to reinterpret between vectors of scalar
and vectors of complex. Problem is, it relies on
returning an lvalue. This is true in current gnu libstdc++, but looks like
it's not in the current standard, and appears to be going away (real(z) will
return rvalue).

I need some help fixing this code in my complex_to_real iterator adaptor:

  template<typename BaseIterator>
  class const_c_to_r_adapt : public boost::iterator_adaptor<
    typename std::iterator_traits<BaseIterator>::value_type::value_type,
    typename std::iterator_traits<BaseIterator>::value_type::value_type


    scalar_type & dereference() const {
      return (cnt % 2 == 0) ? real (const_cast<complex_type&>(*this-
>base_reference())) : imag (const_cast<complex_type&>(*this-

Changing it to return an rvalue is not acceptable. I need the functionality
of returning an lvalue. Any ideas?

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at