gcc and using declarations

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Wed Apr 12 00:06:00 GMT 2000


> ------------------------------------
> #include <iostream>
> 
> struct A
> {
>         struct B { int i; };
> };
>  
> int main()
> {
> 	using A::B;
> 	B b;
> 
> 	std::cout << b.i << std::endl;
> 
> 	return 0;
> };
> ----------------------------------
> 
> IMHO it is also legal C++ ('using' inside function definition).

No, it is not. 7.3.3, [namespace.udecl]/6 says

# A using­declaration for a class member shall be a
# member­declaration. [Example:
#
# struct X { int i; static int s; };
# void f() {
#   using X::i; // error: X::i is a class member
#               // and this is not a member declaration.
#   using X::s; // error: X::s is a class member
#               // and this is not a member declaration.
# }
# - end example]

If you question this interpretation, please discuss it in one of the
public C++ fora first, eg. comp.lang.c++.moderated, or comp.std.c++.

Regards,
Martin


More information about the Gcc mailing list