如果我想可视化 C++20迭代器概念的层次结构,我想用一行简短地解释每个概念的含义。没有什么精确的,只是一个粗略的意思(精确性在源代码中......;-))
我很难想出一个好的“一行摘要”
- 输入迭代器
- 输出迭代器
- 前向迭代器
这是我的可视化:
digraph iter_concepts {
rankdir = BT;
node[shape=record];
indirectly_readable [label="{indirectly_readable|... = *it}"];
indirectly_writable [label="{indirectly_writable|*it = ...}"];
weakly_incrementable [label="{weakly_incrementable|++it, one pass}"];
incrementable [label="{incrementable|++it, multi pass}"];
input_or_output_iterator [label="{input_or_output_iterator|*it}"];
sentinel_for [label="{sentinel_for|for(x : ...)}"];
sized_sentinel_for [label="{sized_sentinel_for|for(... i<sz ...)}"];
input_iterator [label="{input_iterator|}"];
output_iterator [label="{output_iterator|}"];
forward_iterator [label="{forward_iterator|}"];
bidirectional_iterator [label="{bidirectional_iterator| --it}"];
random_access_iterator [label="{random_access_iterator| it+=n, it-=n, it[n]}"];
contiguous_iterator [label="{contiguous_iterator| it ≍ pointer}"];
incrementable -> weakly_incrementable;
input_or_output_iterator -> weakly_incrementable;
sentinel_for -> input_or_output_iterator;
sized_sentinel_for -> sentinel_for;
input_iterator -> input_or_output_iterator;
input_iterator -> indirectly_readable;
output_iterator -> input_or_output_iterator;
output_iterator -> indirectly_writable;
forward_iterator -> input_iterator;
forward_iterator -> sentinel_for;
forward_iterator -> incrementable;
bidirectional_iterator -> forward_iterator;
random_access_iterator -> bidirectional_iterator;
contiguous_iterator -> random_access_iterator;
}
结果图像是我非常满意的,除了缺少的框:
更新:forward_iterator -> incrementable
我纠正了图表中的缺失(尚未在图像中)。