C++ 使用访问修饰符继承构造函数模板

C++ 使用访问修饰符继承构造函数模板,c++,c++11,gcc,mingw,C++,C++11,Gcc,Mingw,继承构造函数模板时,GCC(6.2.0通过MinGW-w64,6.3通过)似乎忽略了访问修饰符 #include <iostream> class Base { protected: template<typename ...Args> Base(Args ...args) { std::cout << "variadic ctor" << std::endl; } template<

继承构造函数模板时,GCC(6.2.0通过MinGW-w64,6.3通过)似乎忽略了访问修饰符

#include <iostream>

class Base
{
protected:
    template<typename ...Args>
    Base(Args ...args)
    {
        std::cout << "variadic ctor" << std::endl;
    }

    template<typename T>
    Base(T t)
    {
        std::cout << "template ctor" << std::endl;
    }

    Base(char const *s)
    {
        std::cout << s << std::endl;
    }
};

class Derived : public Base
{
protected:
    using Base::Base;
};

int main(int, char**) noexcept
{
    //Base bv{ 0, 1 }; // error: 'Base::Base(Args ...) [with Args = {int, int}]' is protected within this context
    //Base bt{ 0 }; // error: 'Base::Base(T) [with T = int]' is protected within this context
    //Base bs{ "base" }; // error: 'Base::Base(const char*)' is protected within this context
    Derived dv{ 0, 1 };
    Derived dt{ 0 };
    //Derived ds{ "derived" }; // error: 'Derived::Derived(const char*)' is protected within this context
    return 0;
}
#包括
阶级基础
{
受保护的:
模板
基本(Args…Args)
{

std::难道我看不出这是正确的行为吗?我发现标准中没有任何东西可以解释这一点,这里有一些东西支持通常的可访问性规则适用的概念。谢谢,@SamVarshavchik。我添加了一个指向另一个答案的链接,这个答案说得差不多,虽然它没有明确提到模板的情况,但它们不应该(显然)作为一个例外。这是我看到的事情之一。这似乎表明无论
是否在private/protected/public部分中出现使用
,继承的构造函数也会继承可访问性——这是我没有预料到的,但这仍然不能解释这一点……在[namespace.udecl]中有一个类似的例子/N4618的第18条,但该标准不够明确,我不知道构造函数是否可以访问。文本是“如果其他构造函数在用于构造相应基类的对象时可以访问,那么它们是可以访问的,并且使用声明的可访问性被忽略”但是,它没有说明在什么上下文中执行访问检查。在
B
上下文中,
A
构造函数确实可以访问以构造
A
。clang++3.8不接受此代码,icc也不接受。