Error when pass std::map as template template argument

后端 未结 2 1634
我寻月下人不归
我寻月下人不归 2021-01-07 02:14

I defined a function like this, in which there is a template template class

template cl         


        
2条回答
  •  轮回少年
    2021-01-07 02:50

    You don't really need template template parameter in the first place. You could make it

    template
    struct ForEachOf {
      void operator()(const Map& map,
          std::function func) const {
                for(const auto& pair : map) {
                    func(pair.first, pair.second);
                }
            }
        };
    

    or even

    template 
    void operator() (const Map& map, F func) const { ... }
    

提交回复
热议问题