Prev: Programatically rearranging icons
Next: utime() and GMT
From: Triple-DES on 11 Nov 2009 03:21 On 10 Nov, 13:51, "Igor Tandetnik" <itandet...(a)mvps.org> wrote: > Triple-DES wrote: > > In some instances, Comeau (online) is more lenient with typename than > > the Standard. Example: > > > template <typename T> > > struct A > > { > > struct B { }; > > B b1_; // ok > > A::B b2_; // ill-formed, 'typename' required > > > }; > > > Comeau online compiles this without a diagnostic. > > typename keyword is not required here. There's an example in 14.6 that shows this exact situation, and no typename keyword: > > 14.6p2 A name used in a template declaration or definition and that is dependent on a template-parameter is assumed not to name a type *unless the applicable name lookup finds a type name* [emphasis mine] or the name is qualified by the keyword typename. [Example: > // no B declared here > class X; > template<class T> class Y { > class Z; // forward declaration of member class > void f() { > X* a1; // declare pointer to X > T* a2; // declare pointer to T > Y* a3; // declare pointer to Y<T> > > // ****** This is the part similar to your example. > Z* a4; // declare pointer to Z > > typedef typename T::A TA; > TA* a5; // declare pointer to T's A > typename T::A* a6; // declare pointer to T's A > T::A* a7; // T::A is not a type name: > // multiply T::A by a7; ill-formed, > // no visible declaration of a7 > B* a8; // B is not a type name: > // multiply B by a8; ill-formed, > // no visible declarations of B and a8 > }}; > > -end example] This is not the same situation. In my example, a previously declared member, B, is referred to _using a qualified name_, in which case the keyword typename is always required. While Z* a4; // is well-formed, Y::Z * a4 // is ill-formed. 'typename' is required here.
From: Igor Tandetnik on 11 Nov 2009 08:07
Triple-DES wrote: > This is not the same situation. In my example, a previously declared > member, B, is referred to _using a qualified name_, in which case the > keyword typename is always required. I suppose you refer to 14.6p6: "...The keyword typename shall always be specified when the member is referred to using a qualified name..." Apparently, Comeau follows DRs 409 and 224, which remove this sentence as well as the rationale for the requirement: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#409 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#224 -- With best wishes, Igor Tandetnik With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925 |