Namespace and regions

Is it possible to declare a region of class interface 'using namespace' without making the whole file using that namespace?

EX:
Class interface contains functions with parameters to a subscoped namespace, there are several of these functions. Is there a simple way to declare the use of namespace for this region of code, or do I need to scope each parameter?

Also, lets say within the source these functions are defined, and by their nature require the same subscopes. Other than declaring "using namespace <scope>;" for each defining region of each function, is there a way to declare a region within the source (outside the functions but not encompassing the whole file) that it is using a namespace. Like if there is a keyword that 'unuses' a namespace once using namespace has been declared.
Last edited on
Are you looking for a private namespace?

You can always do something like:
1
2
3
4
5
6
7
8
9
10
11
namespace exportable
  {

  int you_can_see_me( int );

  namespace
    {
    void i_am_hidden();
    }

  }
More like this:

1
2
3
4
5
6
class A
{
public:
	void func( b::Obj B, b::Obj A );
	// ... and several more functions with param type b::Obj (namespace b)
};


Trying to do something like
1
2
3
4
5
6
7
8
9
class A
{
public:
	{ 
	using namespace b;
		
	void func( Obj B, Obj A );
	}
};


The reason I can't just use 'using namespace b;' at the top of file is because there is another namespace that contains some types of same name.
Ah. Yes, I see how that can seem obnoxious, but header files should never using anything.
Your source (implementation) files, of course, can using anything they like.

If you persist, however, you can just name the specific object:
1
2
3
using b::Obj;

void func( Obj B, Obj A );

Good luck!
Thanks for your time!
Topic archived. No new replies allowed.