代码之家  ›  专栏  ›  技术社区  ›  Anycorn

参数包的lambda扩展

  •  2
  • Anycorn  · 技术社区  · 7 年前

    switch )

      template<size_t ... N>
      int f(std::index_sequence<N...>, int k)
      {
        static auto f_table = { []() { return N; }... };
        auto f = f_table.begin() + k;
        assert((*f)() == k);
        return (*f)();
      }
    

    这与 error: parameter packs not expanded with ‘...’:

    0 回复  |  直到 7 年前