C++ 继承模板化转换运算符

C++ 继承模板化转换运算符,c++,inheritance,template-meta-programming,c++20,conversion-operator,C++,Inheritance,Template Meta Programming,C++20,Conversion Operator,考虑以下代码: template <class R, class... Args> using function_type = R(*)(Args...); struct base { template <class R, class... Args> constexpr operator function_type<R, Args...>() const noexcept { return nullptr; } };

考虑以下代码:

template <class R, class... Args>
using function_type = R(*)(Args...);

struct base {
    template <class R, class... Args>
    constexpr operator function_type<R, Args...>() const noexcept {
        return nullptr;
    }
};

struct derived: private base {
    template <class R, class... Args>
    using base::operator function_type<R, Args...>; // ERROR
};
模板
使用函数_type=R(*)(Args…);
结构基{
模板
constexpr运算符函数_type()const noexcept{
返回空ptr;
}
};
派生结构:私有基{
模板
使用base::operator函数_type;//错误
};
在C++20中是否有一种可行的替代方法来继承和公开模板转换函数?

GCC支持此功能:

模板
使用函数_type=R(*)(Args…);
结构基{
模板
constexpr运算符函数_type()const noexcept{
返回空ptr;
}
};
派生结构:私有基{
使用base::operator函数_type;//没有错误!
};
int main(){
导出d;
静态铸型(d);
}
但我认为这是对语言的一种延伸,可能来自于TS的概念

在C++20中是否有一种可行的替代方法来继承和公开模板转换函数

我不知道通过
使用
直接公开它的方法

但可以将其包装在派生运算符中

struct derived: private base {

    template <typename R, typename... Args>
    constexpr operator function_type<R, Args...>() const noexcept {
       return base::operator function_type<R, Args...>();
    }

};
struct派生:私有基{
模板
constexpr运算符函数_type()const noexcept{
返回基::运算符函数_type();
}
};

Afaics当前的C++2a标准草案仍然包含这样一段话,即阻止使用声明来引用基类的成员模板转换函数的专门化。
派生的
中是否有其他转换函数会在
中隐藏转换函数模板?@davishering它正试图更改访问权限。@T.C.:Right-I错过了私有继承。
struct derived: private base {

    template <typename R, typename... Args>
    constexpr operator function_type<R, Args...>() const noexcept {
       return base::operator function_type<R, Args...>();
    }

};