No, the principle of members to pointers is to access members at offset unknown at compile time.
Of course in your example if you compile with optimisations a decent compiler can guess it since pvec is invariant.
Take this example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
class A
{
public:
int a;
};
int main()
{
A a = {5};
A* pa = &a;
int A::*p = &A::a;
int i;
i = pa->*p;
i = pa->a;
return 0;
}
|
If you compile this in Debug in Visual 2010 and disassemble, you can see that line
i = pa->*p
generate 1 extra "add" instruction to add the value of p to the register which hold the adress of pa. Line
i = pa->a
doesn't need this instruction because the compiler know the offset of a. In fact members to pointers are just integers which hold the offset of the member variable into the class but i don't think you need it for your problem.
And don't think too much about the performances between two similar pieces of code, the compiler can do optimisations you can't even imagine. For the example of cire, it will have a performance gain without optimisation but with optimisations decent compilers are able to see the expression
vec_pst1[i]->vec
is invariant within the second for so it will transform your code like the one proposed by cire to avoid recomputing it each time.