RFC: New C++ Attribute: final
Joe Buck
Joe.Buck@synopsys.COM
Wed Mar 3 01:51:00 GMT 2004
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.
More information about the Gcc
mailing list