Paragraph 7.3.3. of C++2003 standard states that
Using declaration for a class member shall be a member declaration.
This means that the following gives a syntax error:
struct S1
{
static int var1;
};
using S1::var1;
While the following compiles fine:
namespace N2
{
int var2;
}
using N2::var2;
Does anybody know the rationale (if any) behind that?
Even more, the standard gives explicit example with static data member of the struct and tells that it should cause syntax error. MS C++ gives this error:
cpptest1.cxx(9) : error C2885: 'S1::var1': not a valid using-declaration at non-class scope
It is still not clear why this should be banned.