// tmp_policy // Created by lucas on 22-7-26. // Re-implementation of a typical policy architecture in C++ Template Meta-Programming. #include #include "accumulator.h" #include #include int main() { // Normal demo std::vector intVec; intVec.reserve(10); for (int i = 1; i <= 10; ++i) intVec.push_back(i); std::cout << Accumulator>::eval(intVec) << std::endl; std::cout << Accumulator>::eval(intVec) << std::endl; std::cout << Accumulator>::eval(intVec) << std::endl; std::cout << Accumulator<>::eval(intVec) << std::endl; std::cout << Accumulator::eval(intVec) << std::endl; std::cout << Accumulator::eval(intVec) << std::endl; // Punchline (gusha) std::vector strVec; for (int i = 1; i <= 10; ++i) strVec.emplace_back("Today is KFC crazy Thursday V me ¥50\n"); std::cout << Accumulator>::eval(strVec) << std::endl; return 0; }