Topic: A::A::A::A
Author: johnchx2@yahoo.com (johnchx)
Date: Tue, 5 Oct 2004 23:12:46 GMT Raw View
gdr@cs.tamu.edu (Gabriel Dos Reis) wrote
> AlbertoBarbati@libero.it (Alberto Barbati) writes:
>
> A::A is valid. It designates the constructor.
>
> | Notice that it doesn't even refer to the
> | class constructor, because constructors have no name.
>
Yes...the trick is to notice that A::A is not actually a name. A name
is the use of an identifier (3/4) and an identifier may not include
the ":" character. IIRC, A::A is a qualified-id (A.4). And yes, it
designates the ctor.
---
[ 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: gdr@cs.tamu.edu (Gabriel Dos Reis)
Date: Wed, 6 Oct 2004 02:17:28 GMT Raw View
news@news.newshosting.com ("news") writes:
| "Gabriel Dos Reis" <gdr@cs.tamu.edu> wrote in message news:m3sm8tvqdb.fsf@merlin.cs.tamu.edu...
|
| > A::A designates the constructor for class A. GCC is defective in not
| > implementing the rules. I've filled a PR a long time ago.
|
| Only in the special case of defining that function.
No, the meaning of A::A is independent of whether you're defining the
constructor. The meaning is what it is; only the *use* is valid in
context of constructor definition out of class definition.
For example, the following is invalid
A::A a;
Applying you reasoning, it would be valid; alas it is not. See 3.4.3.1.
--
Gabriel Dos Reis
gdr@cs.tamu.edu
Texas A&M University -- Computer Science Department
301, Bright Building -- College Station, TX 77843-3112
---
[ 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: gdr@cs.tamu.edu (Gabriel Dos Reis)
Date: Wed, 6 Oct 2004 03:48:58 GMT Raw View
AlbertoBarbati@libero.it (Alberto Barbati) writes:
[...]
| > | the name A is injected in the scope of A, it's not a member of A, so
| > | writing A::A is illegal.
| > That is wrong.
| > A::A is valid. It designates the constructor.
| > | Notice that it doesn't even refer to the
| > | class constructor, because constructors have no name.
| > That is not true. The standard specifically says that it designates
| > the constructor.
| >
|
| Of course I may have been mistaken, but I couldn't find where the
| standard says that. Could you enlighten me, please?
3.4.3.1/1a
If the nested-name-specifier nominates a class C, and the name
specified after the nested-name-specifier, when looked up in C, is
the injected-class-name of C (clause 9), the name is instead
considered to name the constructor of class C. Such a constructor
name shall be used only in the declarator-id of a constructor
definition that appears outside of the class definition. [Example:
struct A { A(); };
struct B: public A { B(); };
A::A() { }
B::B() { }
B::A ba; // object of type A
A::A a; // error A::A is a not a type name
--end example]
So, if a constructor does not have a name, how can "the name is
instead considered to name the constructor"? That is a rhetorical
question :-)
--
Gabriel Dos Reis
gdr@cs.tamu.edu
Texas A&M University -- Computer Science Department
301, Bright Building -- College Station, TX 77843-3112
---
[ 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: gdr@cs.tamu.edu (Gabriel Dos Reis)
Date: Wed, 6 Oct 2004 03:49:11 GMT Raw View
sgganesh@gmail.com (Ganesh) writes:
| > Is this code really valid?
| > a.A::A::A::A::A::A::foo();
| >From 3.4.5[4], "If the name is found only in the scope of the class of
| the object expression, the name shall refer to a class-name". Since
| the qualifying "class-name-or-namespace-name" is not a class-name, it
| is not valid.
|
| However, in the compilers I checked the code with, g++ 3.2, aCC 3.55,
| comeau online, it passed. In VC++, it gives a misleading error "error
| 2039: '__ctor' : is not a member of 'A'"; might be that the vc++
| compiler confuses series of A::A as constructors and tries to
| interpret it.
I believe VC++ correctly rejects the code because it implements DR
#whatever, that went into the TC1 as 3.4.3.1/1a.
G++ does not implement that rule.
--
Gabriel Dos Reis
gdr@cs.tamu.edu
Texas A&M University -- Computer Science Department
301, Bright Building -- College Station, TX 77843-3112
---
[ 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: AlbertoBarbati@libero.it (Alberto Barbati)
Date: Wed, 6 Oct 2004 17:23:23 GMT Raw View
Gabriel Dos Reis wrote:
> AlbertoBarbati@libero.it (Alberto Barbati) writes:
>
> [...]
>
> | > | the name A is injected in the scope of A, it's not a member of A, so
> | > | writing A::A is illegal.
> | > That is wrong.
> | > A::A is valid. It designates the constructor.
> | > | Notice that it doesn't even refer to the
> | > | class constructor, because constructors have no name.
> | > That is not true. The standard specifically says that it designates
> | > the constructor.
> | >
> |
> | Of course I may have been mistaken, but I couldn't find where the
> | standard says that. Could you enlighten me, please?
>
> 3.4.3.1/1a
>
> If the nested-name-specifier nominates a class C, and the name
> specified after the nested-name-specifier, when looked up in C, is
> the injected-class-name of C (clause 9), the name is instead
> considered to name the constructor of class C. Such a constructor
> name shall be used only in the declarator-id of a constructor
> definition that appears outside of the class definition. [Example:
>
> struct A { A(); };
> struct B: public A { B(); };
>
> A::A() { }
> B::B() { }
>
> B::A ba; // object of type A
> A::A a; // error A::A is a not a type name
>
> --end example]
>
So what I said wasn't completely wrong as you stated. I wrote "writing
A::A is illegal" and *in that context* (which wasn't "in the
declarator-id of a constructor definition that appears outside of the
class definition") it was in fact illegal. ;-)
> So, if a constructor does not have a name, how can "the name is
> instead considered to name the constructor"? That is a rhetorical
> question :-)
:-D
Alberto
---
[ 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: kanze@gabi-soft.fr
Date: Wed, 6 Oct 2004 17:23:34 GMT Raw View
gdr@cs.tamu.edu (Gabriel Dos Reis) wrote in message
news:<m3ekkcpvce.fsf@merlin.cs.tamu.edu>...
> So, if a constructor does not have a name, how can "the name is
> instead considered to name the constructor"? That is a rhetorical
> question :-)
Not so rhetorical. To name has several meanings in English. One of
them is to designate, which doesn't imply that what is designated
actually has a name. (The example in the American Heritage Dictionary
is "to name the time for our meeting" -- certainly the time named
doesn't have a name.) That would seem to be the meaning here.
Otherwise, why the "instead", which suggests that the name actually
names something else (perhaps the injected class name).
--
James Kanze GABI Software http://www.gabi-soft.fr
Conseils en informatique orient e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S mard, 78210 St.-Cyr-l' cole, France, +33 (0)1 30 23 00 34
---
[ 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: noway@sorry.com ("Giovanni Bajo")
Date: Mon, 4 Oct 2004 15:16:04 GMT Raw View
Is this code really valid?
struct A {
void foo() {}
};
void bar() {
A a;
a.A::A::A::A::A::A::foo();
}
--
Giovanni Bajo
---
[ 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: AlbertoBarbati@libero.it (Alberto Barbati)
Date: Tue, 5 Oct 2004 04:37:26 GMT Raw View
Giovanni Bajo wrote:
> Is this code really valid?
>
> struct A {
> void foo() {}
> };
>
> void bar() {
> A a;
> a.A::A::A::A::A::A::foo();
> }
>
AFAIK, the syntax A::whatever refers to a member of class A. Although
the name A is injected in the scope of A, it's not a member of A, so
writing A::A is illegal. Notice that it doesn't even refer to the class
constructor, because constructors have no name.
That said, applying ::A a second or more times won't improve the
situation, so the answer is definitely no.
Alberto
---
[ 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: gdr@cs.tamu.edu (Gabriel Dos Reis)
Date: Tue, 5 Oct 2004 04:37:36 GMT Raw View
noway@sorry.com ("Giovanni Bajo") writes:
| Is this code really valid?
|
| struct A {
| void foo() {}
| };
|
| void bar() {
| A a;
| a.A::A::A::A::A::A::foo();
No.
A::A designates the constructor for class A. GCC is defective in not
implementing the rules. I've filled a PR a long time ago.
--
Gabriel Dos Reis
gdr@cs.tamu.edu
Texas A&M University -- Computer Science Department
301, Bright Building -- College Station, TX 77843-3112
---
[ 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: invalid@bigfoot.com (Bob Hairgrove)
Date: Tue, 5 Oct 2004 15:27:12 GMT Raw View
On Mon, 4 Oct 2004 15:16:04 GMT, noway@sorry.com ("Giovanni Bajo")
wrote:
>Is this code really valid?
>
>struct A {
> void foo() {}
>};
>
>void bar() {
> A a;
> a.A::A::A::A::A::A::foo();
>}
Why shouldn't it be?
--
Bob Hairgrove
NoSpamPlease@Home.com
---
[ 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: sgganesh@gmail.com (Ganesh)
Date: Tue, 5 Oct 2004 15:27:47 GMT Raw View
> Is this code really valid?
> a.A::A::A::A::A::A::foo();
>From 3.4.5[4], "If the name is found only in the scope of the class of
the object expression, the name shall refer to a class-name". Since
the qualifying "class-name-or-namespace-name" is not a class-name, it
is not valid.
However, in the compilers I checked the code with, g++ 3.2, aCC 3.55,
comeau online, it passed. In VC++, it gives a misleading error "error
2039: '__ctor' : is not a member of 'A'"; might be that the vc++
compiler confuses series of A::A as constructors and tries to
interpret it.
-Ganesh
---
[ 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: news@news.newshosting.com ("news")
Date: Tue, 5 Oct 2004 15:28:02 GMT Raw View
"Gabriel Dos Reis" <gdr@cs.tamu.edu> wrote in message news:m3sm8tvqdb.fsf@merlin.cs.tamu.edu...
> A::A designates the constructor for class A. GCC is defective in not
> implementing the rules. I've filled a PR a long time ago.
Only in the special case of defining that function. Since the constructors
don't "have names" you can't do
a.A::A()
or even
a.A();
---
[ 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: swelef@post.sk (Vladimir Marko)
Date: Tue, 5 Oct 2004 16:34:18 GMT Raw View
noway@sorry.com ("Giovanni Bajo") wrote in message news:<mQb8d.23473$N45.607983@twister2.libero.it>...
> Is this code really valid?
>
> struct A {
> void foo() {}
> };
>
> void bar() {
> A a;
> a.A::A::A::A::A::A::foo();
> }
I believe it is valid. See thread
``How to avoid / check typing mistake ":" instead of "::" , with C++ ?''
from April 2004.
Regards,
Vladimir Marko
---
[ 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: gdr@cs.tamu.edu (Gabriel Dos Reis)
Date: Tue, 5 Oct 2004 17:26:02 GMT Raw View
AlbertoBarbati@libero.it (Alberto Barbati) writes:
| Giovanni Bajo wrote:
| > Is this code really valid?
| > struct A {
| > void foo() {}
| > };
| > void bar() {
| > A a;
| > a.A::A::A::A::A::A::foo();
| > }
| >
|
| AFAIK, the syntax A::whatever refers to a member of class A. Although
| the name A is injected in the scope of A, it's not a member of A, so
| writing A::A is illegal.
That is wrong.
A::A is valid. It designates the constructor.
| Notice that it doesn't even refer to the
| class constructor, because constructors have no name.
That is not true. The standard specifically says that it designates
the constructor.
--
Gabriel Dos Reis
gdr@cs.tamu.edu
Texas A&M University -- Computer Science Department
301, Bright Building -- College Station, TX 77843-3112
---
[ 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: gdr@cs.tamu.edu (Gabriel Dos Reis)
Date: Tue, 5 Oct 2004 19:23:36 GMT Raw View
invalid@bigfoot.com (Bob Hairgrove) writes:
| On Mon, 4 Oct 2004 15:16:04 GMT, noway@sorry.com ("Giovanni Bajo")
| wrote:
|
| >Is this code really valid?
| >
| >struct A {
| > void foo() {}
| >};
| >
| >void bar() {
| > A a;
| > a.A::A::A::A::A::A::foo();
| >}
|
| Why shouldn't it be?
Why should it be?
--
Gabriel Dos Reis
gdr@cs.tamu.edu
Texas A&M University -- Computer Science Department
301, Bright Building -- College Station, TX 77843-3112
---
[ 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: AlbertoBarbati@libero.it (Alberto Barbati)
Date: Tue, 5 Oct 2004 22:18:48 GMT Raw View
Gabriel Dos Reis wrote:
> AlbertoBarbati@libero.it (Alberto Barbati) writes:
>
> | Giovanni Bajo wrote:
> | > Is this code really valid?
> | > struct A {
> | > void foo() {}
> | > };
> | > void bar() {
> | > A a;
> | > a.A::A::A::A::A::A::foo();
> | > }
> | >
> |
> | AFAIK, the syntax A::whatever refers to a member of class A. Although
> | the name A is injected in the scope of A, it's not a member of A, so
> | writing A::A is illegal.
>
> That is wrong.
>
> A::A is valid. It designates the constructor.
>
> | Notice that it doesn't even refer to the
> | class constructor, because constructors have no name.
>
> That is not true. The standard specifically says that it designates
> the constructor.
>
Of course I may have been mistaken, but I couldn't find where the
standard says that. Could you enlighten me, please?
Alberto
---
[ 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 ]