This is the mail archive of the gcc@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]

Re: RFC: New C++ Attribute: final


On Wed, Mar 03, 2004 at 01:42:42AM +0100, Gabriel Dos Reis wrote:
> But, the pointer to member is a *constant*, in a given scope with
> defined lifetime.  That GCC does not take advantage of that is another
> problem. 

Consider this testcase:

----------------------------------------------------
#include <functional>
#include <string>
#include <iterator>
#include <vector>
#include <iostream>

int main() {
    std::vector<std::string> words;
    words.push_back("one");
    words.push_back("two");
    words.push_back("three");
    std::transform(words.begin(),
		   words.end(),
		   std::ostream_iterator<size_t>(std::cout, "\n"),
		   std::mem_fun_ref(&std::string::length));
}
----------------------------------------------------

Here we have a pointer to member function that is a constant: this
program writes the lengths of the words in the words array to standard
out.  And sure enough, with -O2, GCC 3.3.3 doesn't leave any indirect
or direct call to std::string::length around.


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