Given the following simple example:
Title:
#ifndef A_HPP
#define A_HPP
#include <memory>
class A
{
public:
A();
int foo();
private:
struct Imp;
std::auto_ptr< Imp > pimpl;
};
#endif
Implementation:
#include "a.hpp"
struct A::Imp
{
int foo()
{
}
};
A::A() : pimpl( new Imp )
{}
int A::foo()
{
return pimpl->foo();
}
Main:
#include "header.hpp"
int main()
{
A a;
return a.foo();
}
Questions:
Is the method able to A::Imp::fooget in A::foo?
Does it depend on the implementation of what is in this method?
PS I am using gcc (4.3.0 if that matters).
EDIT
I think I didn’t explain very well. That I meant just that. If I use the maximum level of optimization, will it be // do something and return the resultplaced in A::foo()or A::Imp::foo()?
Without optimization, I see that this is not done ( the pimpl->foo()still being called).
I understand that A :: foo () will never go into main (), but that is not what I am asking for.
source
share