小编Ast*_*tar的帖子

如何复制“算法”标头类型函数?

就像 algo header 中的算法一样, std::sort(std::begin(), std::end(), greater) where greateris abool func

我正在尝试做同样的事情来理解它的实际工作原理。所以我试图通过
1 -> 在单独的命名空间中创建一个 lambda func
2 -> 像std::sort在其他命名空间中那样创建一个单独的函数
3 -> 传递一个向量,它应该返回一个指向要查找的元素的指针

我收到错误:

<source>: In function 'int main()':
<source>:41:22: error: no matching function for call to 'chk(std::vector<int>::iterator, std::vector<int>::iterator, lambda::<lambda(auto:16, int)>&, int)'
   41 |     auto l {test::chk(series.begin(), series.end(), lambda::find, 50)};
      |             ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:22:10: note: candidate: 'template<class auto:17, class auto:18, class auto:19> auto test::chk(auto:17, auto:18, std::function<bool(auto:19, int)>&, int)'
   22 |     auto chk(auto start, auto end, std::function<bool (auto, …
Run Code Online (Sandbox Code Playgroud)

c++ c++20

1
推荐指数
1
解决办法
128
查看次数

标签 统计

c++ ×1

c++20 ×1