Typename lookup of return parameter

I was recently asked by a student about a compile issue. The answer was quite simple but right now I am struggling about the reason. A simple example:

#include <iostream>
#include <vector>

struct MyStruct
{
    typedef std::vector<int> MyIntVector;

    MyIntVector CopyVector(MyIntVector const& vector);
};


MyStruct::MyIntVector MyStruct::CopyVector(MyIntVector const& vector)
^^^^^^^^
{
    MyIntVector vec;
    return vec;
}

int main(int /*argc*/, char** /*argv*/)
{
    MyStruct st;
}

To be valid c++ code the return parameter has to be fully qualified. So much to the answer and to make the compiler/student happy.

But why has the return value to be qualified with the class and the parameter to the function not?

I always did this and I know that it has to do with the ADL lookup, but now that I was asked I searching for a better answer.
Can anyone give a me reference to the spec or a hint where I can find some more information?

7
задан mkaes 14 April 2011 в 11:47
поделиться