|
23 | 23 | #include "subspace/containers/__private/vec_iter.h"
|
24 | 24 | #include "subspace/containers/__private/vec_marker.h"
|
25 | 25 | #include "subspace/containers/slice.h"
|
| 26 | +#include "subspace/fn/fn_concepts.h" |
| 27 | +#include "subspace/fn/run_fn.h" |
26 | 28 | #include "subspace/iter/from_iterator.h"
|
27 | 29 | #include "subspace/iter/into_iterator.h"
|
28 | 30 | #include "subspace/macros/compiler.h"
|
@@ -94,8 +96,10 @@ class Vec {
|
94 | 96 | /// This is highly unsafe, due to the number of invariants that aren’t
|
95 | 97 | /// checked:
|
96 | 98 | ///
|
97 |
| - /// * `ptr` must be heap allocated through malloc() (TODO: Want our own global |
98 |
| - /// allocator API). |
| 99 | + /// * `ptr` must be heap allocated with the same method as Vec uses |
| 100 | + /// internally, which is not currently stable. (TODO: Want our own global |
| 101 | + /// allocator API.) The only safe way to get this pointer is from |
| 102 | + /// `from_raw_parts()`. |
99 | 103 | /// * `T` needs to have an alignment no more than what `ptr` was allocated
|
100 | 104 | /// with.
|
101 | 105 | /// * The size of `T` times the `capacity` (ie. the allocated size in bytes)
|
@@ -442,21 +446,21 @@ class Vec {
|
442 | 446 | void sort() { as_mut_slice().sort(); }
|
443 | 447 |
|
444 | 448 | /// #[doc.inherit=[n]sus::[n]containers::[r]Slice::[f]sort_by]
|
445 |
| - template <class F, int&..., |
446 |
| - class R = std::invoke_result_t<F, const T&, const T&>> |
| 449 | + template <::sus::fn::FnOnce<::sus::fn::NonVoid(const T&, const T&)> F, |
| 450 | + int&..., class R = std::invoke_result_t<F, const T&, const T&>> |
447 | 451 | requires(::sus::ops::Ordering<R>)
|
448 |
| - void sort_by(F compare) { |
| 452 | + void sort_by(F&& compare) { |
449 | 453 | as_mut_slice().sort_by(sus::move(compare));
|
450 | 454 | }
|
451 | 455 |
|
452 | 456 | /// #[doc.inherit=[n]sus::[n]containers::[r]Slice::[f]sort_unstable]
|
453 | 457 | void sort_unstable() { as_mut_slice().sort(); }
|
454 | 458 |
|
455 | 459 | /// #[doc.inherit=[n]sus::[n]containers::[r]Slice::[f]sort_unstable_by]
|
456 |
| - template <class F, int&..., |
457 |
| - class R = std::invoke_result_t<F, const T&, const T&>> |
| 460 | + template <::sus::fn::FnOnce<::sus::fn::NonVoid(const T&, const T&)> F, |
| 461 | + int&..., class R = std::invoke_result_t<F, const T&, const T&>> |
458 | 462 | requires(::sus::ops::Ordering<R>)
|
459 |
| - void sort_unstable_by(F compare) { |
| 463 | + void sort_unstable_by(F&& compare) { |
460 | 464 | as_mut_slice().sort_by(sus::move(compare));
|
461 | 465 | }
|
462 | 466 |
|
|
0 commit comments