【发布时间】:2014-04-15 14:54:07
【问题描述】:
这是我想做的一些伪代码:
void thing (storedClassArg){
virtualClass<x,y> in1 = new storedClassArg<x,y>;
virtualClass<x,z> in2 = new storedClassArg<x,z>;
}
main:
storedClass;
if( inputThingy)
storedClass = type1;
else
storedClass = type2;
thing(storedClass);
【问题讨论】:
-
这在 C++ 中是不可能的。 C++17 正在考虑将反射纳入 C++ 的各种提案。
-
@BrianBi 哇,你真的明白这个问题了吗?
-
实际上现在只考虑 compile-time 反射。他们说他们首先研究编译时反射,因为它可能决定应该存在什么样的运行时反射设施。所以不要指望它直到 C++23...
-
@juanchopanza 我不知道 OP 到底想做什么,但它肯定看起来像反思......
-
这个问题似乎是题外话,因为它是关于一些童话语言,而不是c++ ...