Clean Conversion from Run-time Values to Compile-time Constants in C++
本篇源于群友的某个提问,需求略显特别,却是一个非常不错的产生式元编程例子,遂记录一下。 原始问题 优化后的原始问题,代码如下: struct base { virtual void foo() = 0; }; template<int I, int J, int K, int L> struct derived : public base { void foo() override final { std::cout << "derived<" << I << ',' << J << ',' << K << ',' << L << ">::foo()\n";… Continue Reading Clean Conversion from Run-time Values to Compile-time Constants in C++