Topic: Class declarations and using-declarations
Author: d.r.hulswit@stu_dent.utw_ente.nl (Rob Hulswit)
Date: Tue, 8 Jul 2003 18:27:20 +0000 (UTC) Raw View
After doing some reading in the standard, I was wondering if the
following code is legal:
namespace A
{
struct B;
}
using A::B;
namespace A
{
struct B
{
static int C;
};
}
int main()
{
B::C = 4; // < the problem
}
As I see it, 7.3.3/9 applies here (The entity declared by a using-
declaration shall be known in the context using it according to its
definition at the point of the using-declaration.). At the point of the
using-declaration, A::B is not defined. Because of the last rule,
::B would stay undefined after A::B is defined; rendering the use of B::C
in the global namespace illegal.
Am I seeing this right? Or have I missed something?
(Comeau online accepts this code without complaining, so do gcc 3.3 and
Borland Builder 5.)
--
To reply, remove the underscores from my reply-to address
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: ron@sensor.com ("Ron Natalie")
Date: Tue, 8 Jul 2003 18:38:51 +0000 (UTC) Raw View
"Rob Hulswit" <d.r.hulswit@stu_dent.utw_ente.nl> wrote in message news:MPG.1975261bff7f3394989686@news.cs.utwente.nl...
> As I see it, 7.3.3/9 applies here (The entity declared by a using-
> declaration shall be known in the context using it according to its
> definition at the point of the using-declaration.).
Known doesn't mean fully defined. The partial definition suffices.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]