This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: gcc and using declarations


> ------------------------------------
> #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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]