Boost logo

Boost Users :

From: Becher, Jochen (jochen.becher_at_[hidden])
Date: 2008-05-28 11:23:10


Hi John,

thank you, you are right, remove_reference fixes the problem. I do not understand why MSVC print the reference type without the reference symbol (I checked this twice) but internally it seems to be a reference type (and that is what you expect for typedef ...::reference).

My final code is this:

template<class ITERATOR>
class SecondIterator_TC : public boost::iterator_adaptor<
  SecondIterator_TC<ITERATOR>,
  ITERATOR,
  typename ITERATOR::value_type::second_type,
  boost::use_default,
  typename boost::mpl::eval_if<
    typename boost::is_const<typename boost::remove_reference<
      typename ITERATOR::reference>::type>::type,
    boost::mpl::identity<typename ITERATOR::value_type::second_type const&>,
    boost::mpl::identity<typename ITERATOR::value_type::second_type &>
>::type,
  boost::use_default>
{
...
};

It is my first attempt to use iterator_adaptor. It allows iterators over maps (and other iterators that dereference to a pair) to use like iterators on most other containers. The Reference template parameter now looks really complex, is there any simpler solution?

Regards, Jochen

-----Urspruengliche Nachricht-----
Von: boost-users-bounces_at_[hidden] [mailto:boost-users-bounces_at_[hidden]] Im Auftrag von John Maddock
Gesendet: Mittwoch, 28. Mai 2008 16:39
An: boost-users_at_[hidden]
Betreff: Re: [Boost-users] boost::is_const does not recognize constant type

Becher, Jochen wrote:
>
> The following type expression evaluates to the false_ type:
>
> boost::is_const<std::map<std::string,std::string>::const_iterator::refer
> ence>::type
>
>
>
> It should evaluate to the true type because ...::reference is
>
>
>
> const std::pair<const std::string,std::string>

Nope, wouldn't that be:

const std::pair<const std::string,std::string>&

which is a reference type and can be neither const nor volatile qualified
(the const qualifier in the above refers to the thing being referenced not
the reference itself). If you feed it through remove_reference before
passing to is_const then you should get true as the result.

HTH, John.

_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Stryker Leibinger GmbH & Co. KG
Sitz: Freiburg - Handelsregister: AG Freiburg HRA 4375
Komplementaerin: Stryker Beteiligungs GmbH
Geschaeftsfuehrer: Dr. Heinrich W. Dreyer, Klaus Welte
Sitz: Freiburg - Handelsregister: AG Freiburg HRB 5441
Bankverbindung: Bank of America N.A. Frankfurt 17 362 010 - BLZ 500 109 00, IBAN: DE04 5001 0900 0017 3620 10

 

Diese Nachricht und etwaige Dateianhaenge sind vertrauliche Informationen, die besonderen Geheimhaltungsvereinbarungen oder -vorschriften unterliegen koennen. Falls Sie nicht der beabsichtigte Empfaenger der Nachricht sind, werden Sie gebeten, den Absender telefonisch oder durch E-Mail zu unterrichten und die Nachricht und etwaige Dateianhaenge vollstaendig und endgueltig zu loeschen. Die Nachricht und ihr Inhalt duerfen in diesem Fall nicht kopiert, ausgedruckt oder weitergeleitet werden.

This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient, please telephone or e-mail the sender and delete this message and any attachment from your system. If you are not the intended recipient you must not copy this message or attachment or disclose the contents to any other person.


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