Commit 397e5ed
committed
span: remove default copy ctor and assignment oper
These have the effect of disabling the default move constructor and move
operator. This is generally meaningless for spans due to their simplicity,
but consider the (simplified here) internal implementation of .first():
Span<C> first(std::size_t count) const noexcept {
return Span<C>(m_data, count);
}
Technically this creates a new Span object and moves/copies it when it returns,
but RVO takes care of optimizing that out.
Because trivial moves have been implicitly deleted, it falls into the more
complicated conversion rvalue constructor to handle the return.
The next commit will add an attribute to the conversion constructor to help
detect dangling stack references, so we want to make sure that we're not
sending trivial copies through it.
NOTE: This copy/move is could also be avoided by constructing the return value
in-place:
Span<C> first(std::size_t count) const noexcept {
return {m_data, count};
}1 parent f32f7e9 commit 397e5ed
1 file changed
+0
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | 64 | | |
71 | 65 | | |
72 | 66 | | |
| |||
0 commit comments