Typedef模板的成员类型

Typedef a member type of a template

本文关键字:成员类 类型 成员 Typedef      更新时间:2023-10-16

我有一个这样的公式:

template <typename A, typename B>
struct SomeLibraryClass
{
     using Foo = A;
     using Bar = B;
};

现在我想使用它,但重命名它,因为概念上的用法是不同的。

template <typename A, typename B>
using quaz = SomeLibraryClass<A, B>;

然而,如果我想要得到bar,它仍然是quaz::bar。但是我想把quaz::bar换成quaz::foobar。这可能吗?为什么或者为什么不呢?

我不能使用继承。

不能添加或删除成员,也不能更改已经定义的类的成员名。你所能做的就是定义一个新的类。