【发布时间】:2021-07-10 16:28:58
【问题描述】:
我对概念还很陌生,但到目前为止我很喜欢它们,并希望在项目中使用它们。问题是我还希望项目能够使用早期的 C++ 标准进行编译。到目前为止,我提出了以下实用化的解决方案:
#if ISCPP20
template<NumT number = double,Index index = int,CoordinateContainer<number> coords>
#else
template<class number = double,class index = int,class coords>
#endif
其中 NumT、Index 和 CoodinateContainer 是定义的概念。该解决方案有效,但我不喜欢冗长。是否有推荐的方法将概念引入代码库,同时又不破坏向后编译兼容性?
【问题讨论】:
标签: c++ c++20 c++-concepts