我正在尝试使用remove_if
STL函数,并且正在传入映射,unordered_map或向量。所有这些都带有返回迭代器的函数.begin()
和.end()
。编译器不允许我在模板化变量上调用函数
我尝试使用.begin()
和.end()
以及begin()
和end()
template<typename FUNCTOR, typename datastructure>
void deleteFromHelper(FUNCTOR func, datastructure table)
{
std::remove_if(table.begin(), table.end(), func);
}
其中 table 是unorded_map、映射或向量。 和 func 是一个自定义函子
编译器说: Error C2228 left of '.begin' must have class/struct/union
看起来像一个 MSVC 错误,gcc 对此非常满意,请参阅:
https://wandbox.org/permlink/KuzZrEriPQerBoou
但是,如果像我的示例那样使用模板推导,您是否指定了/std:c++17?(我认为这在 MSVC 中可能仍然不完整(。