You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- *Description*: A transform view that dereferences pointer-like elements in a range. Useful for turning a range of pointers or smart pointers into a range of references.
36
+
- *Usage*: `range | gl::util::deref_view`
37
+
- *Works with*: `T*`, `std::unique_ptr<T>`, `std::shared_ptr<T>`, and generally pointer-like objects supporting unary `*`.
38
+
- *Return type*: A lazy transformed view whose reference type is `decltype(*p)` of the underlying elements.
39
+
- *Example*:
40
+
```cpp
41
+
std::vector<std::unique_ptr<int>> v; /* ... */
42
+
for (int& x : v | gl::util::deref_view) {
43
+
// use x as an int&
44
+
}
45
+
```
46
+
47
+
### Functions
48
+
49
+
-**`range_size(r)`**
50
+
- *Template parameters*:
51
+
- `R: std::ranges::range`
52
+
- *Description*: Returns the size of a range. If `R` models `std::ranges::sized_range`, it forwards to `std::ranges::size(r)` in O(1). Otherwise, it computes `std::ranges::distance(std::begin(r), std::end(r))` in O(n).
53
+
- *Parameters*:
54
+
- `r: R&&` – the input range.
55
+
- *Return type*: Same type as produced by `std::ranges::size(r)` for sized ranges or `std::ranges::distance(...)` otherwise.
56
+
- *Complexity*: O(1) for sized ranges; O(n) otherwise.
57
+
- *Exceptions*: No specific exceptions; propagates iterator operations if they throw.
58
+
59
+
> [!CAUTION]
60
+
> For non-sized, single-pass/input ranges `range_size` will consume the range when computing distance.
-`edge: types::const_ref_wrap<EdgeType>` - a constant reference wrapper for the edge.
74
-
-`source_id: types::id_type` - the ID of the source vertex of the held edge.
75
-
76
65
-`predicate_result`
77
66
-*Description*: Represents the result of a predicate evaluation.
78
67
-*Type definitions*:
@@ -383,7 +372,7 @@ This section covers the specific types and type traits used for the algorithm im
383
372
> -*Constructors*:
384
373
> -`mst_descriptor(types::size_type n_vertices)` - Initializes an empty `edges` list with the capacity of $\text{n-vertices} - 1$ and the total weight is set to $0$.
385
374
> -*Member variables*:
386
-
> -`edges: std::vector<types::const_ref_wrap<edge_type>>` - A list of constant edge references representing the edges of the spanning tree.
375
+
> -`edges: std::vector<edge_type>` - A list of edges of the spanning tree.
387
376
> -`weight: weight_type` - The total weight of all edges of the spanning tree.
0 commit comments