namespace for a class

T

toton

Hi,
Is it possible to have a class level namespace opening instead of
file level .

Something like this,
I have a long namespace like
namespace com { namespace my_company{ namespace my_project{ namespace
parser{
class my_parser{
};
}}}}

Now when I want to use this , I usually make a shortcut and use it,
with the assumption that I am working at my_project level, thus no
name resolution at that level is needed.

thus in the file,
namespace parser = com::my_company::my_project::parser;

Thus it is in the file scope.
Then use it as parser::my_parser in the header;
The same thing also can be done at function scope.

However, how this can be done in the class scope ?
like,

class my_parser_usage{
namespace parser = com::my_company::my_project::parser;
public:
parser::my_parser get_pasrer()const;
}
class my_second_parser_usage{
namespace parser = com::my_company::my_project::parser2;
public:
parser::my_parser get_pasrer()const;
}

Thanks
abir
 
D

Dave Rahardja

Hi,
Is it possible to have a class level namespace opening instead of
file level .

Something like this,
I have a long namespace like
namespace com { namespace my_company{ namespace my_project{ namespace
parser{
class my_parser{
};
}}}}

Now when I want to use this , I usually make a shortcut and use it,
with the assumption that I am working at my_project level, thus no
name resolution at that level is needed.

thus in the file,
namespace parser = com::my_company::my_project::parser;

Thus it is in the file scope.
Then use it as parser::my_parser in the header;
The same thing also can be done at function scope.

However, how this can be done in the class scope ?
like,

class my_parser_usage{
namespace parser = com::my_company::my_project::parser;
public:
parser::my_parser get_pasrer()const;
}
class my_second_parser_usage{
namespace parser = com::my_company::my_project::parser2;
public:
parser::my_parser get_pasrer()const;
}

Thanks
abir

Not exactly, but you can pull in symbols from another namespace:

class my_parser_usage {
typedef com::my_company::my_project::parser parser;
public:
parser get_parser() const;
};

-dr
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,120
Latest member
ShelaWalli
Top