f



Is qualified name allowed in member declaration?

In the following code: 

struct A {
   void A::func() {}
};

Isn't it valid to declare the member as a qualified name, as A::func,
within scope of A? However I get "error: qualified name is not allowed
in member declaration" when using Comeau (online version 4.3.3)
compiler? Isn't that 3.4.3.1 allow a class member to be referred to
using a qualified-id at any point in its scope?

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

0
sgganesh
7/29/2004 12:29:49 PM
comp.std.c++ 2720 articles. 1 followers. Post Follow

1 Replies
1190 Views

Similar Articles

[PageSpeed] 21

Ganesh wrote:
> In the following code: 
> 
> struct A {
>    void A::func() {}
> };
> 
> Isn't it valid to declare the member as a qualified name, as A::func,
> within scope of A? However I get "error: qualified name is not allowed
> in member declaration" when using Comeau (online version 4.3.3)
> compiler? Isn't that 3.4.3.1 allow a class member to be referred to
> using a qualified-id at any point in its scope?
> 

If I read 3.3.6 correctly, the potential scope of a class member name 
does not include that name's declarator (in 3.3.6/1 it is explicitly 
said "the declarative region following the name's declarator"), so 
3.4.3.1 does not apply in this case.

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                       ]

0
AlbertoBarbati
7/29/2004 3:58:48 PM
Reply:

Similar Artilces:

qualified names in namespace member declarations
There is some previous discussion of this; but, I could not find definitive and unanimous agreement and interpretation of the standard. namespace A { class A::SomeClass { } ; A::SomeClass A::some_func() ; } namespace A { A::SomeClass A::some_func() { return A::SomeClass() ; } } Which of the redundant A:: qualifications above are legal? Is section 8.3 of the standard relevant? What other sections bear on this question? On our system, g++ and the Sun compiler allow the above while the Intel compiler gives the "qualified name not allowed in namespace member declarati...

qualified names in namespace member declarations
There is some previous discussion of this; but, I could not find definitive and unanimous agreement and interpretation of the standard. namespace A { class A::SomeClass { } ; A::SomeClass A::some_func() ; } namespace A { A::SomeClass A::some_func() { return A::SomeClass() ; } } Which of the redundant A:: qualifications above are legal? Is section 8.3 of the standard relevant? What other sections bear on this question? On our system, g++ and the Sun compiler allow the above while the Intel compiler gives the "qualified name not allowed in namespace member declaration" error discussed here a few years back. Finally, is it legal to define some_func without wrapping in namespace A { } as one does for class member functions? A::SomeClass A::some_func() { return A::SomeClass() ; } Thanks in advance! -- Keith -- Fraud 6 --- [ 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.comeaucomputing.com/csc/faq.html ] Keith H Duggar wrote: > There is some previous discussion of this; but, I could not > find definitive and unanimous agreement and interpretation > of the standard. > > namespace A { > > class A::SomeClass { } ; > > A::SomeClass A::some_func() ; >...

Why are static member variables allowed in c++ and not in C?
Hi All, I have seen this question(mentioned in subject) posted in various forums but some how I am not statisfied with the answer. 1- Is this because of where static variables are placed in c and c++ 2- or There is a constraint from the language(C) (didn't understand this much) and also related to this any links where I can find differences in c and c++ not related to language ie not like c++ has class and c has not but like const has external linkage in c but in c++ it has external linkage. Thanks, Manas -- [ See http://www.gotw.ca/resources/clcm.htm for ...

Question Can I use explicit qualifier <C> after member function name of a template class?
Bjarne Stroustrup's "The C++ Language Programming" says at P330: "Within the scope of String<C>, qualification with <C> is redundant for the name of the template itself, so String<C>::String is the name for the constructor. If you prefer, you can be explicit: template<class T> String<C>: String<C> () { /*...*/ }" But in fact, I find I cannot use this 'explicit' form for any member function of a template class with g++ or Comeau. Is it the problem of the compilers or the book? an0 wrote: > Bjarne Stroustrup's "T...

workaround to C "typedef struct name *name;" C vs C++
Hi All, This is valid code in C because "struct name" and "name" are distinct { the poster refers to this part of the subj line: typedef struct name *name; -mod } types, but not in C++ where this produces a compiler error. I have a third party C library that uses this extensively in header files and I need to use this in C++ code. Is there a way around this? Thanks, Brian -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] Am 25.08.2011 14:30, schrieb Brian L: > Hi All, > > This is valid code in C because "struct name" and "name" are distinct > > { the poster refers to this part of the subj line: > > typedef struct name *name; > > -mod } > > types, but not in C++ where this produces a compiler error. I have a > third party C library that uses this extensively in header files and I > need to use this in C++ code. > > Is there a way around this? What do you mean with a way around? You did not really explain what the actual reason for this construction is. What do you want to realize? The C++ standard is clear that this typedef declaration is invalid in a non-class scope, because the second 'name' does refer to something different than the second one. I can define a construction that works, but I don't know whether this will help ...

qualified name is not allowed
using namespace std; typedef struct { tU16 u16AppID; tU16 u16RegisterID; tU16 u16CmdCounter; tU16 u16FunctionID; tU16 u16SourceSubID; tU32 u32InternalData; } trMessageDataForMethodResult; class ExecuteTest { auto_ptr< trMessageDataForMethodResult > _MessageDataForMethodResultExecuteTest; }; I am using RVCT compiler( ARM ) I forgot to paste the problem, While executing following code( I have removed code that Im not suppossed to post).I am getting the error as qualified name is not allowed at the line whe...

qualified member name lookup
Hello, If I compile the following program with gcc, clang or comeau I get a error about ambiguity. Is this correct behavior? struct a { int foo; }; struct a2 : virtual a {}; struct b : a2 {}; struct c : a2 {}; struct d : b, c { void f() { b::a2::foo; // OK for MSVC, ERROR for others } }; (clang) error: ambiguous conversion from derived class 'd' to base class 'a2': struct d -> struct b -> struct a2 struct d -> struct c -> struct a2 (gcc) error: 'a2' is an ambiguous base of 'd' (...

Named std::pair members
Hi all. I recently stumbled over a discussion that asserted that code using std::pair<string, int> instead of, say, struct city_t { string name; int pcode; }; is hard to read as every time we access the pair we just work with first and second and the user does not immediately see what first and second should be. What do you think of the following solution where std::pair is extended via a preprocessor macro to contain two arbitrarily named member references in addition to first and second ... ? br, Martin [code] #include <map> #include <string> #define NAMED_PAIR_TYPE(...

why does C standard allow this declaration
Hi Why does C allows declaration of variable inside switch block. ex: foll prg does not gives "undeclared "b" error msg. but also does not initialize b to 20 int a=1; switch(a) { int b=20; case 1: printf("b is %d\n",b); break; default:printf("b is %d\n",b); break; } this prints some garbage. ( yeah even though i got warning msg "unreachable code int b = 20" why is it declaring inside switch block but not initializing b) "sunny" <sunny.nls@gmail.com> w...

How to declare a C or C++ function in a Objective C class
Hi, I need to write few functions, which I need to pass to a method in Objective C class using the pointers to those functions. These functions use the instance variable of the class. Hence they must have access to the variables. I want to write functions in C or C++ because they are crucial to the efficiency of my code and I don't want to use selectors way of passing methods for the same reasons. Then where do I include the function declations and implementations in ..h and .mm files of the class. Ankush In article <1150755755.068251.207990@h76g2000cwa.googlegroups.com>, ankushiitk@gmail.com wrote: > Hi, > I need to write few functions, which I need to pass to a method in > Objective C class using the pointers to those functions. These > functions use the instance variable of the class. Hence they must have > access to the variables. > I want to write functions in C or C++ because they are crucial to the > efficiency of my code and I don't want to use selectors way of passing > methods for the same reasons. > Then where do I include the function declations and implementations in > .h and .mm files of the class. > Ankush Consider adding a userData parameter to your fast C++ functions. Define a struct that has a pointer to your Objective C object instance members. Add an initBridge Objective-C method that initializes the struct with pointers to objective-C members. Now, your fast function ...

SLIME C-c C-k causes name-conflicts
Hello, I have this problem: I visit a file defining a package in emacs slime, compile and load it with C-c C-k, then switch to the REPL, and do (use- package ...) and get a condition sb-int:name-conflict. (emacs 22.1.1, slime 3.0-alpha, sbcl 1.0.6). I believe my lisp file complies with lisp standards, so give me a hint! Here is the lisp file I load (defpackage #:seidel-sparse (:use :cl) (:export *eps* #:seidel-sparse)) (in-package #:seidel-sparse) (defvar *eps* 5d-6) (defun seidel-sparse(A b x) (declare ;(type (simple-array double-float (*)) b x) ;(type (array list (*)) A...

Qualifying class declarations with defined symbols in C++
Hi! I am looking into some C++ code written by others. They declare some classes like the following: --- class SLICE_API BoolTok : public GrammarBase {...}; --- I wander what the meaning of the SLICE_API qualifier is in the previous declaration? I have never seen anyone qualify the new class-name like that before. By poking around in the rest of the code, I have found SLICE_API to be declared in an included file, as follows: --- #ifndef SLICE_API # ifdef SLICE_API_EXPORTS # define SLICE_API ICE_DECLSPEC_EXPORT # else # define SLICE_API ICE_DECLSPEC_IMP...

C++11 allows static member initialisation
I have this: $ more static-initialisers.cpp=20 class Simple { static int mCounter =3D 0; }; $ g++-4.6.3 -std=3Dc++0x -c static-initialisers.cpp static-initialisers.cpp:3:24: error: ISO C++ forbids in-class initialization of non-const static member =E2=80=98mCounter=E2=80=99 Which version of G++ allows this? The docs for 4.7.x doesn't say if it is allowed. I know I can simply do: int Simple::mCounter =3D 0 to get around this though.=20 --=20 Tactical Nuclear Kittens On 06/08/2012 00:11, Single Stage to Orbit wrote: > I have this: > > $ more static-i...

Are negative integer literals allowed in std C++?
>From the definition of an integer literal in the 1998 ISO/IEC 14882 standard (in 2.13.1) (or the preprocessing number definition in 2.9), I don't see a way for negative integer literals to be defined. (I'm thinking it must be covered elsewhere, but I haven't come across it, yet.) Although the text in 2.13.1 suggests that it's possible, based on the suffix (or, more specifically, the absence of the 'U' suffix), and although I've done it in practice (so compilers at least allow it), there doesn't seem to be allowance for a leading sign (+/-) character. I und...

Qualified-id and qualified names?
Hello all - i found there are many places where the Standard refers to qualified-id, but actually in that context no qualified-id appears or the obvious intend was to apply to all qualified names. Examples: 3.4.3.1/1: "If the nested-name-specifier of a qualified-id nominates a class, the name specified after the nested-name-specifier is looked up in the scope of the class (10.2), except for the cases listed below: [...] the lookup for a name specified in a using-declaration (7.3.3) also finds class or enumeration names" - no qualified-id appears in a using declaration. 3.4.3.2/1: If the nested-name-specifier of a qualified-id nominates a namespace, the name specified after the nested-name-specifier is looked up in the scope of the namespace ..." - what about declaration "A::f<int> foo;", where the type-specifier does not use qualified-id? 14.7/6: "If the qualified-id in a typename-specifier does not denote a type, the program is ill-formed." - no qualified-id here either! 14.7.2.1/4: "A name is a member of the current instantiation if it is ... — A qualified-id in which the nested-name-specifier refers to the current instantiation." - what about type-specifiers like "T::x y;" ? I've noticed DR 120 ( http://www.open- std.org/jtc1/sc22/wg21/docs/cwg_defects.html#120 ) replaced "qualified-name" by "qualified-id" in some places - could it be that the original ...

C and C++ naming issues?
http://www.gubbe.ch/code/libcfgparse/cfgtypes_8h-source.html That page contains a header that when included does not define any of the typedefs or any of the value references that are in that file. For instance, I included that file and then tried this: switch (file.get_type("valid_operating_systems")) { case CFG_ITEM_NONE: cerr << "NONE" << endl; break; case CFG_ITEM_INTEGER: cerr << "INT" << endl; break; case CFG_ITEM_BOOLEAN: cerr << "BOOL" << endl; break; case CFG_ITEM_FLOATINGPOINT: cerr << &qu...

What, exactly, is the 'qualified name' in a DTD declaration?
The documentation for org.w3c.dom.DOMImplementation.createDocumentType says helpfully: public DocumentType createDocumentType(java.lang.String qualifiedName, java.lang.String publicId, java.lang.String systemId) throws DOMException and goes on to explain: Parameters: qualifiedNameThe - qualified name of the document type to be created. On a 'monkey see, monkey do' basis I've been supplying the string 'html' for XHTML documents, and since I've not...

Static instances of std::map allowed by C++ standard?
I am curious if the C++ Standard (14882:1998(E) ) actually disallows static instances of std::map as in: #include <map> std::map<int, int> foo; int main() { return 0; } When I use the Microsoft Visual Studio .NET 2003 compiler with some code that uses static instances of maps, Rational Purify reports: UMR: Uninitialized memory read in std::_Tree_nod and tracing through the stack it seems associated with the allocator initialization for std::map. Moreover when I replace the static map instances with a Singleton pattern, Purify reports no errors. The problem doesn't seem 100% consistent; for example, the 3-line program above does _not_ seem to trigger the Rational Purify problem. If static map instances are indeed forbidden, this would seem somewhat invasive; for example, it would imply that CppUnit test fixture classes can't contain any std::map data members (since static instances of these classes are declared by the fixture registration macro). Thanks in advance, Jordan Samuels [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] On 23 Dec 2004 17:13:06 -0500, <jordan@madsam.com> wrote: > I am curious if the C++ Standard (14882:1998(E) ) actually disallows > static instances of std::map as in: > > #include <map> > std::map<int, int> foo; > int main() { return 0; } > > When I use the Microsoft Visual Studio .NET 2003 compile...

Why C dont allow the name of a variable start with a digit?
Dear all, Why C and some of other languages dont allow the name of a variable start with a digit? Jason20005 said: > Dear all, > > Why C and some of other languages dont allow the name of a variable > start with a digit? Assume C *did* allow it. What should the output of this program be? #include <stdio.h> int main(void) { int 42 = 6; printf("%d\n", 42); return 0; } What should be printed, and why? -- Richard Heathfield <http://www.cpax.org.uk> Email: -http://www. +rjh@ Google users: <http://www.cpax.org.uk/prg/writings/googly.php> "...

Are fully qualified class names permitted for ctor declarations?
Given the following: class A { class B { A::B( A::B const & ); }; }; Is the above ctor declaration valid C++? ISO C++ 2003, 12.1, paragraph 1 states: "Constructors do not have names. A special declarator syntax using an optional sequence of function-specifiers (7.1.2) followed by the constructor=92s class name followed by a parameter list is used to declare or define the constructor. In such a declaration, optional parentheses around the constructor class name are ignored." However, as best I can tell, the ISO standard does not specify if ...

C++ volatile qualified reference and member functions useful?
Andrei Alexandrescu had an interesting article "volatile - Multithreaded Programmer's Best Friend" about using the type system and volatile to help with thread-safety. I understand that volatile qualifiying data doesn't help with thread-safety. But Andrei's idea of "marking" thread-safe interfaces with volatile still seems like a good idea to me. Does anyone have any experience with that technique? How did it go? terry On 28 B=F8e, 08:20, "Terry G" <tjgol...@netins.net> wrote: > Does anyone have any experience with that technique? How did it go? i've tried to implement and use it with combination of another article: http://hillside.net/plop/2005/proceedings/PLoP2005_pbachmann1_0.pdf it's handy when you need to protect whole vector with some kind of lock and you are tired of writing various forms of locked pimpls etc. i am using it for year or two and still happy with that pattern (many thanks to authors of course!). if i may i'll paste a sample from documentation as it illustrates misc accesses to the container. /**@class synchronized * @brief synchronize mt-unsafe interface * * due to const/volatile qualification and locked_ptr proxy mechanism * several ways to access underlying _ThreadUnsafeInterface exist: * * typedef synchronized<std::list<int>, helpers::rw_mutex> mt_list_t; * * mt_list_t volatile rw_list; ...

Error E2140 deque.c 293: Declaration is not allowed here
typedef struct { short dataType; YYSTYPE datum; } SyntaxNode; struct deque_node { SyntaxNode key; struct deque_node * prev; struct deque_node * next; }; SyntaxNode deque_begin(void) { deque_p = deque_head; SyntaxNode t; if (NULL != deque_p) { t=deque_p->key; } return t; } SyntaxNode deque_end(void) { deque_p = deque_tail; SyntaxNode t; if (deque_p != NULL) { t=deque_p->key; } return t; } Error E2140 deque.c 293: Declaration is not allowed here in function deque_begin Error ...

C++14 std::size() non-member function
The C++14 working paper has voted in the following non-member functions, which are missing from the C++11 standard: std::cbegin()/std::cend(), std::rbegin()/std::rend(), std::crbegin()/std::crend(). Seemingly another missing non-member function is std::size(). Such a function would be useful, especially when dealing with legacy functions that expect a pointer to an array and an array size. Many times the array size calculation of the array size is either hard coded or calculated using sizeof, both of which are error prone. Consider the following possible implementation of the std::size() non-member function. // for raw arrays template<typename Arr, size_t Size> size_t inline size(Arr(&Array)[Size]) { return Size; } // for std containers implemented the size member function template<typename Container> auto inline size(Container& Cont) -> decltype(Cont.size()) { return Cont.size(); } Using std::size() to calculate an array size would be as follows: void some_legacy_func(wchar_t * p, size_t s); wchar_t buf[15]; some_legacy_func(p, std::size(buf)); // the line above easier to get right than (sizeof(buf) / sizeof(buf[0])) Is there any interest in such a function? If so, how could such a feature be proposed? -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] ...

lookup of class members qualified by a derived class name
Hi, can anyone point me to the exact paragraph in the standard which makes the following ill-formed? struct Base { int i; }; struct Derived : Base { }; int main(){ Base b = { 0 }; return b.Derived::i; // ill-formed } Note that "i" looked up in the scope of "Derived" is actually "Base::i" and for example the expression "b.* &Derived::i" is well-formed. Regards, Vladimir Marko -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] Vladimir Marko ha scrit...

Web resources about - Is qualified name allowed in member declaration? - comp.std.c++

United States Declaration of Independence - Wikipedia, the free encyclopedia
"Declaration of Independence" redirects here. For the type of document generally, see Declaration of independence . For the painting, see Trumbull's ...

United States Declaration of Independence - Wikipedia, the free encyclopedia
"Declaration of Independence" redirects here. For the type of document generally, see Declaration of independence . For the painting, see Trumbull's ...

North Korea says South's pulling out of industrial zone 'declaration of war'
[ Brisbane Times - Text-only index ] North Korea says South's pulling out of industrial zone 'declaration of war' Date: February 12 2016 Philip ...

Two confirmed cases of Zika virus in Australia, researchers warn after WHO emergency declaration
The NSW Health department has confirmed two cases from passengers travelling from the Caribbean.

North Korea says South's pulling out of industrial zone 'declaration of war'
... zone on Thursday, calling the South's move to suspend operations, in retaliation for Sunday's rocket launch by the North, a &quot;declaration ...

North Korea says South's pulling out of industrial zone 'declaration of war'
... industrial zone on Thursday, calling the South's move to suspend operations, in retaliation for Sunday's rocket launch by the North, a "declaration ...

Flint water contamination in Michigan prompts emergency declaration by President Barack Obama
Barack Obama declares a state of emergency in Michigan, freeing up federal aid to help an area affected by contaminated water.

Snyder Asks Obama For Emergency Declaration In Flint Water Crisis
... laws were violated. FLINT (AP) – Michigan Gov. Rick Snyder has asked President Barack Obama to issue an emergency and major disaster declaration ...

Vanessa Hudgens’ public declaration of love could cost her
❤️❤️ @austinbutler #sedonadreams A photo posted by Vanessa Hudgens (@vanessahudgens) on Feb 14, 2016 at 1:12pm PST We’ve all been there, right? ...

Hillary Confuses The Constitution With Declaration Of Independence During Anti-Gun Diatribe
Hillary Confuses The Constitution With Declaration Of Independence During Anti-Gun Diatribe

Resources last updated: 3/6/2016 5:30:48 PM