Public alias for non-public type

Joh*_*mph 12 c++ alias access-modifiers

I wonder if it is valid C++ :

class Test {
    struct PrivateInner {
        PrivateInner(std::string const &str) {
            std::cout << str << "\n";
        }
    };

public:
    using PublicInner = PrivateInner;
};

//Test::PrivateInner priv("Hello world");        // Ok, private so we can't use that
Test::PublicInner publ("Hello World");           // ?, by using public alias we can access private type, is it ok ?
Run Code Online (Sandbox Code Playgroud)

Bri*_*ian 14

Types are neither public nor private. Access control only ever applies to names. Since PublicInner is a public name that refers to the PrivateInner class, it can be used outside the Test class.