【发布时间】:2018-11-01 16:20:15
【问题描述】:
template
<
template <typename, typename>
class storage_t,
typename T,
typename is_allocated
>
class Buffer : public storage_t<T, is_allocated> { ... };
template
<
template <typename, typename>
class storage_t,
typename T = storage::UnknownType,
typename is_allocated = std::false_type
>
class Example_Buffer
: public Buffer<storage_t, T, is_allocated> {
constexpr Example_Buffer(
typename storage_t<T, is_allocated>::iterator it) {}
};
Example_Buffer<...> 继承自 Buffer<...>。 Buffer<storage_t, T, is_allocated> 继承自 storage_t<T, is_allocated>。 storage_t<...> 包括 typedefs 和静态 constexpr 数据。有没有办法通过继承在Example_Buffer的构造函数中访问这些typedefs和static constexpr data? (通过继承,也就是不使用storage_t<T, is_allocated>?在同一个类中使用这种语法两次感觉有点奇怪。
如果我需要详细说明,请随时询问。
【问题讨论】:
标签: c++11 templates inheritance static policy-based-design