Michele Caini 6 лет назад
Родитель
Сommit
bac4984496
1 измененных файлов с 19 добавлено и 1 удалено
  1. 19 1
      docs/md/entity.md

+ 19 - 1
docs/md/entity.md

@@ -1500,6 +1500,24 @@ standard library. If it's not clear, this is a great thing.
 As an example, this kind of iterators can be used in combination with
 `std::for_each` and `std::execution::par` to parallelize the visit and therefore
 the update of the components returned by a view or a group, as long as the
-constraints previously discussed are respected.<br/>
+constraints previously discussed are respected:
+
+```cpp
+auto view = registry.view<position, const velocity>();
+
+std::for_each(std::execution::par_unseq, view.begin(), view.end(), [&view](auto entity) {
+    // ...
+});
+```
+
 This can increase the throughput considerably, even without resorting to who
 knows what artifacts that are difficult to maintain over time.
+
+Unfortunately, because of the limitations of the current revision of the
+standard, the parallel `std::for_each` accepts only forward iterators. This
+means that the iterators provided by the library cannot return proxy objects as
+references and **must** return actual reference types instead.<br/>
+This may change in the future and the iterators will almost certainly return
+both the entities and a list of references to their components sooner or later.
+Multi-pass guarantee won't break in any case and the performance should even
+benefit from it further.