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: [Patch] Qualify with std:: two files


Paolo Carlini <pcarlini@unitus.it> writes:

| Gabriel Dos Reis wrote:
| 
| >Well, that is not a clear issue (as you probably remember), see
| >
| >    http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_active.html#218
| >
| >I would say that qualifiying types are safe.  The only place where
| > there is no much debate is for template-id:  ADL is not performed
| > for template-ids.  I suggest Paolo leaves in the qualification on
| > types.
| >
| Ok, I will commit the stl_function.h changes.
| While we are at it: could you possibly explain in simple terms what
| does it mean 'template-ids'? In this way perhaps I will be able to
| complete the work much more quickly and without bothering again you
| and Martin.

In 

   --- libstdc++-v3/include/bits/stl_function.h	Thu Jul  3 18:09:46 2003
   *************** template <class _Predicate>
   *** 285,291 ****
     inline unary_negate<_Predicate> 
     not1(const _Predicate& __pred)
     {
   !   return unary_negate<_Predicate>(__pred);
     }

     /// One of the @link s20_3_5_negators negation functors@endlink.
   --- 285,291 ----
     inline unary_negate<_Predicate> 
     not1(const _Predicate& __pred)
     {
   !   return std::unary_negate<_Predicate>(__pred);
     }

unary_negate<_Predicate> is a template-id, i.e. a template-name
(unary_negate) followed by explicit template-argument list, so the
qualification is not necessary:  The compiler first looks up
"unary_negate" using ordinary lookup rules; if it finds a template name
then it proceeds on checking whether the argument list is OK,
otherwise it errors. 


However, the change 

*************** namespace std
*** 126,133 ****
        __glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept<
  	    _RandomAccessIterator>)
  
!       __push_heap(__first, _DistanceType((__last - __first) - 1), _DistanceType(0), 
! 		  _ValueType(*(__last - 1)), __comp);
      }
  
    template<typename _RandomAccessIterator, typename _Distance, typename _Tp>
--- 126,133 ----
        __glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept<
  	    _RandomAccessIterator>)
  
!       std::__push_heap(__first, _DistanceType((__last - __first) - 1), _DistanceType(0), 
! 		       _ValueType(*(__last - 1)), __comp);
      }
  

is good because even though __push_heap might be function template: it
appears in the context of "function call syntax", so the compiler

  (a) at the point of the template definition, looks up __push_heap by
      ordinary rules;

  (b) at the point of instantiation, looks up __push_heap with ADL
      rules  and ordinary rules.

Thus, the explicit qualification removes the ADL part in step (b) and
the ordinary rules are applied only for the set of declarations found in
setp (a).

HTH,

-- Gaby


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