This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug c++/15469] Unable to compile valid code including transform() algorithm: <unknown type> is reported for the forth parameter


------- Additional Comments From gdr at integrable-solutions dot net  2004-05-17 07:27 -------
Subject: Re:  Unable to compile valid code including transform() algorithm: <unknown type> is reported for the forth parameter

"relf at os2 dot ru" <gcc-bugzilla@gcc.gnu.org> writes:

| Wolfgang, could you please explain the difference with the following example
| from B.Stroustrup "The C++ Programming Language" 3rd edition, section 18.6.2:
| 
| template<class T> T* delete_ptr(T* p) { delete p; return 0; }
| void purge(deque<Shape*>& s)
| {
|     transform(s.begin(),s.end(),s.begin(),delete_ptr);
|     // ...
| }

Wolfgang is right.  We don't have types for address of function
templates or overload functions (not that a function template is
treated ini many cases as an infinite overload set).

| Note that here we pass just `delete_ptr' but not `delete_ptr<Shape>' as the
| forth parameter. Why this code does not reqire explicit template class
| specification while my code (that is not much different, in fact) does?

In my copy of TC++PL3, special edition, the code reads:

   struct Delete_ptr { // use function object to get inlining
        template<class T> T* operator()(T* p) { delete p; return 0; }
   };

   void purge(deque<Shape*>& s)
   {
        transform(s.begin(), s.end(), s.begin(), Delete_ptr());
   }

-- Gaby


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15469


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