考虑以下代码:
template<typename T> class Base
{
Base();
Base(const Base<T>& rhs);
template<typename T0> explicit Base(const Base<T0>& rhs);
template<typename T0, class = typename std::enable_if<std::is_fundamental<T0>::value>::type> Base(const T0& rhs);
explicit Base(const std::string& rhs);
};
template<typename T> class Derived : Base<T>
{
Derived();
Derived(const Derived<T>& rhs);
template<class T0> Derived(const T0& rhs) : Base(rhs);
// Is there a way to "inherit" the explicit property ?
// Derived(double) will call an implicit constructor of Base
// Derived(std::string) will call an explicit constructor of Base
};
有没有办法重新设计这段代码,Derived
使所有的构造函数都Base
具有相同的显式/隐式属性?