This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: unsafe STL patch


On 02/04/2010 10:04 PM, François Dumont wrote:
> Thanks, it is a good workaround but I had plan to introduce this
> function in debug/functions.h:
>
>  template<typename _Iterator>
>  typename __siter_base<_Iterator>::iterator_type
>  __base(_Iterator __it)
>  { return __siter_base<_Iterator>::__b(__it); }
>
> __base is easier to use through out the debug containers. But in this
> case the __iter_base declaration is not enough.
>
> Do you have an other solution or I will be forced to write
> __siter_base<_InputIterator>::__b(__first) rather than __base(__first)
> everywhere ?
I don't, but the above cannot work without an appropriate typedef in
__iter_base, like (only lightly tested):

  template<typename _Iterator, bool _HasBase>
    struct __iter_base
    {
      typedef _Iterator iterator_type;

      static iterator_type
      __b(_Iterator __it)
      { return __it; }
    };

  template<typename _Iterator>
    struct __iter_base<_Iterator, true>
    {
      typedef typename _Iterator::iterator_type iterator_type;

      static iterator_type
      __b(_Iterator __it)
      { return __it.base(); }
    };

Paolo.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]