`transform_iterator` does not work with `std::sort` from libc++ 22
还没有人认领这个 Issue。
评估
调研方向
Start with boost/iterator/transform_iterator.hpp and the repro.cpp example, then compare the transform_iterator behavior used by std::sort with the libc++ 22 diagnostic and the linked LLVM issue. Done means the provided C++17 example compiles successfully with libc++ 22 and sorts the wrapped values.
由索引模型根据 Issue 内容生成。
描述
If the comparator has a templated operator(), sorting through a boost::transform_iterator fails to compile with libc++ 22.
#include <algorithm>
#include <string>
#include <vector>
#include <boost/iterator/transform_iterator.hpp>
template <typename T> struct Wrapper { T item; };
struct Identity {
Wrapper<std::string> &operator()(Wrapper<std::string> &w) const { return w; }
};
struct Cmp {
template <typename T>
bool operator()(const Wrapper<T> &a, const Wrapper<T> &b) const { return a.item < b.item; }
};
int main() {
std::vector<Wrapper<std::string>> v{{"b"}, {"a"}};
typedef boost::transform_iterator<Identity, std::vector<Wrapper<std::string>>::iterator> It;
std::sort(It(v.begin()), It(v.end()), Cmp());
}
$ clang++ -std=c++17 -stdlib=libc++ -c repro.cpp
...
/usr/bin/../include/c++/v1/__algorithm/sift_down.h:55:7: error: no matching function for call to object of type
'Cmp'
55 | if (__comp(__first[__child], __first[__start]))
| ^~~~~~
repro.cpp:14:8: note: candidate template ignored: could not match 'Wrapper' against 'operator_brackets_proxy'
14 | bool operator()(const Wrapper<T> &a, const Wrapper<T> &b) const { return a.item < b.item; }
| ^
...
See also https://github.com/llvm/llvm-project/issues/223290.
- 主要语言
- C++
- 星标
- 23
- 派生
- 70
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
boostorg/iterator 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 35/100
-
难度 3/5 1-2 天 新手友好度 45/100
-
难度 2/5 1-3 小时 新手友好度 58/100
-
难度 3/5 1-2 天 新手友好度 35/100
-
难度 2/5 1-3 小时 新手友好度 45/100
查看 boostorg/iterator 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
-
good first issue
难度 2/5 1-3 小时 新手友好度 75/100
ros2/message_filters#338 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
subsurface/subsurface#4984 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
flutter-webrtc/flutter-webrtc#2206 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
google-ai-edge/LiteRT-LM#3739 ·