On Mar 26, 4:36 am, Nikolay Ivchenkov <ts...@mail.ru> wrote:
> Consider the following example:
>
> template <class T>
> struct A {};
>
> struct B : private A<void> {};
>
> struct C : B
> {
> A<void> a; // A is the injected-class-name of A<void>
> };
>
> int main() {}
>
> As far as I understand, in the declaration of C::a identifier A
> denotes the injected-class-name of A<void> (i.e. ::A<void>::A) which
> is inaccessible within C (thus, the program is ill-formed and a
> diagnostic message is required). Is my understanding correct?
>
> The behavior of compilers differs:
>
> 1) GNU C++ 4.8.0, Clang 3.0, and VC++ 10.0 do not issue any error or
> warning.
>
> 2) Intel C++ 12.1 issues the following diagnostic message:
>
> (8): error #308: type "A<T>::A [with T=void]" (declared at line 2)
> is inaccessible
> A<void> a;
> ^
{trailing banner removed - mod/we}
In my perception, it shouldn't throw any compilation error.
Becuase in class C, A<T> class is instantiated for T = void, which is
in global namespace.
For this instantiation inheritance will not play any role.
Daya
--
[ See
http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]