Search code examples
c++namespaceswrapperprivate

Make a namespace private in C++


Consider this case. I am writing a library and want to wrap my data in a namespace. For example:

//header.h
#pragma once

namespace wrapper
{
    // some interface functions here..
}

And I want to make my namespace private. So that no one can write anything in it. For instance, we can always write something like this.

namespace std
{
    // some data here..
}

So I want to prevent the last case. Is there any technique to do that besides using static functions wrapped in a class?


Solution

  • This is not possible. If all else fails, I can always edit your header file.