That code won't remotely compile. Was it so hard to try compiling it before posting here? This will:
#include <list>
struct bar {
void foo() {}
};
int main() {
std::list< bar> foobar;
foobar.push_back(bar());
foobar.begin()->foo();
bar bar1;
bar1.foo();
}
You are right that trying to find the declaration of foo() via:
won't work - I assume it's because it takes too much knowledge of what begin() returns. Interestingly, declaring a function like this:
bar * f() {
return new bar;
}
and using:
will work, but it won't if f() is a template function, so I guess template parsing or the lack of it is the issue.