【发布时间】:2021-10-04 11:51:49
【问题描述】:
是否可以从局部变量的类中提取静态成员类型?也就是
class A {
public:
typedef int constituent_type;
constituent_type a;
A(constituent_type _a) :a(_a) {};
}
int main() {
auto a = A(42);
// ... lots ... of other code; where I have long since forgottten, what the type of a really was
std::max<a::constituent_type>(a, a); //<<<
}
【问题讨论】:
-
std::max将推断其参数的类型并使用operator<进行比较 - 所以我不清楚你想要实现什么? -
请发布一个您实际需要的情况示例。
标签: c++ static-members