Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Problem w/ C++ using declaration in namespaces

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
o2a Posted - Jan 25 2006 : 09:49:25 AM
While we are at C++ namespaces now - here is another problem I noticed when using the boost::tuples lib.

From it's docu:
"All definitions are in namespace ::boost::tuples, but the most common names are lifted to namespace ::boost with using declarations."

So e.g. ::boost::tuples::make_tuple(...) is aliased as ::boost::make_tuple(...). But when using these full-qualified forms, only the former is recognized by VAX, not the latter aliased form.

It turns out, that VAX doesn't seem to recognize identifiers which are using-declared in a namespace when you access them with the full qualified form. On the other hand, if you do without full qualification by putting in a using directive for that namespace, VAX works correctly.

(Please note: not a using directive for the original namespace of the identifier, but for the other namespace containing the using declaration. Of course both will work, but the interesting fact is, that VAX doesn't have a problem with the inner using declaration itself but with the qualification of the containing namespace.)

Example:

namespace test1
{
	void testfunc1(){}
}

namespace test2
{
	using ::test1::testfunc1;
}

void testfunc3()
{
	::test1::testfunc1();	// correctly recognized by VAX
	::test2::testfunc1();	// not recognized by VAX
}

void testfunc4()
{
	using namespace test2;
	testfunc1();			// now correctly recognized by VAX
}
2   L A T E S T    R E P L I E S    (Newest First)
support Posted - Jan 17 2007 : 3:44:06 PM
Fixed in 1544.
feline Posted - Jan 25 2006 : 5:46:08 PM
i had to re-read this one a few times to get it straight in my own head, probably because i never normally use namespaces in my code. thank you for the clear example, i am not sure where i would have started with this.

case=972

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000