我的问题的背景是我试图创建一个惰性网格结构,其中网格区域仅在需要时实例化,否则它们在查询时返回默认值。稍微归结一下这个问题,考虑一下我的情况的以下模型:structContainer{std::vectordata;floatget(intindexOuter,intindexInner){returndata[indexOuter].get(indexInner);}}我想stubBase::get在某些情况下函数总是返回相同的值,而在其他情况下我想返回某个数组中的值。我想象两种可能的解决方案。第一个解决方案是在Base上使用标志,即structBase{std::vectordat