Search code examples
c++c++11privateusing

Is there a private using name = type;


I want to write:

namespace A{
    using name = type;
}

But if I try to use it from another space it would be available. Can I make it private inside its namespace?


Solution

  • There's no language feature to allow that, but many projects have the convention that all contents of namespaces named detail are reserved and should not be used.

    namespace A {
        namespace detail {
            using name = type;
        }
    
        //something using detail::name
    }
    
    //A::detail::name technically accessible, but disallowed by convention