我希望有一个与 boost::any
行为相似但类型集更有限的类型。像这样:
limited_any<int,long,string> x; // x is like boost::any but is guaranteed to contain only an int, a long, or a string
您建议如何实现? (我自己或使用现有解决方案)
最佳答案
您正在寻找boost::variant .
关于c++ - boost::any 类型支持有限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28413265/