c++ - 模板参数的类型无效
问题描述
我的模板有什么问题以及如何修复它?鉴于谓词功能,这应该从 Qt-ish 容器中删除所有项目。编译器产生错误'std::function': 'T::value_type' is not a valid template type argument for parameter '_Fty'
template <typename T>
void eraseIf( T &container, std::function<bool(T::value_type)> predicate)
{
auto it = container.begin();
while( it != container.end() )
{
if( predicate( *it ) )
{
it = container.erase( it );
}
else
{
++it;
}
}
}
解决方案
推荐阅读
- sql - Laravel 查询生成器:这个命令是否可以免除 SQL 注入?
- c - 使用 C11 GCC 使数据读/写原子化
? - sql - 如果语句包含没有 INTO 子句的 OUTPUT 子句,则 DML 语句不能有任何启用的触发器
- java - 使用 EasyMock 在 junit 测试用例中跳过方法调用?
- authentication - DNN 9 Persona Bar 登录后不可见
- html - iPhone上的页脚超出屏幕
- bash - Bash:回显文件内容以计数器开头
- javascript - 我们如何访问未定义的对象?
- ruby-on-rails - 如何在rails中使用脚手架创建复选框?
- amazon-web-services - 我可以强制 CloudFormation 解析来自 Secrets Manager 的值吗?