Using-declaration or using-directive inside unnamed-namespace?

  • Thread starter Niels Dekker - no reply address
  • Start date
N

Niels Dekker - no reply address

We have some using-declarations and using-directives at file scope (in a CPP
file, right after the #include statements). Does it matter much if they are
places in an unnamed namespace instead? I mean, does it make any difference
(file scope versus unnamed-namespace)?

For example:

#include "my_things.h"
#include <memory>

namespace // unnamed
{
using ::std::tr1::shared_ptr;
using namespace my_things;
}

// Using shared_ptr and things from my_things here...


Kind regards,

Niels
 
N

Niels Dekker - no reply address

We have some using-declarations and using-directives at file scope
Victor said:
The using declarations and using-directives only have effect for this
particular translation unit. They don't create additional symbols
that might become visible from another module, if that's what you're
worrying about.

Thanks, Victor. So it doesn't really matter whether they are inside an
unnamed namespace or at file scope.

I thought so already, but I wanted to be sure :)

Kind regards,

Niels
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top