Age | Commit message (Collapse) | Author |
|
|
|
It's a convenience constructor. But it also seems more consistent
to allow a Span being made from both raw and managed arrays.
|
|
|
|
__builtin_memcpy will fail when the target area and the source area
overlap. Using __builtin_memmove will handle this case as well.
|
|
There is no need to have a user-defined copy constructor that simply
calls the base class's copy constructor. By having the compiler generate
it for us, Span is made trivially copyable, so it can be passed in
registers.
|
|
This should:
- Accept const& on both sides
- Not involve implicit conversions on either side
otherwise the argument order would be deemed significant, and trip this
warning.
|
|
|
|
|
|
|
|
|
|
Useful for checking for contents at the start of a span.
|
|
SPDX License Identifiers are a more compact / standardized
way of representing file license information.
See: https://spdx.dev/resources/use/#identifiers
This was done with the `ambr` search and replace tool.
ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
|
|
This commit makes the user-facing StdLibExtras templates and utilities
arguably more nice-looking by removing the need to reach into the
wrapper structs generated by them to get the value/type needed.
The C++ standard library had to invent `_v` and `_t` variants (likely
because of backwards compat), but we don't need to cater to any codebase
except our own, so might as well have good things for free. :^)
|
|
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)
Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.
We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
|
|
|
|
The array constructor allows arrays to be easily treated
as generic span of data.
|
|
Problem:
- Many constructors are defined as `{}` rather than using the ` =
default` compiler-provided constructor.
- Some types provide an implicit conversion operator from `nullptr_t`
instead of requiring the caller to default construct. This violates
the C++ Core Guidelines suggestion to declare single-argument
constructors explicit
(https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c46-by-default-declare-single-argument-constructors-explicit).
Solution:
- Change default constructors to use the compiler-provided default
constructor.
- Remove implicit conversion operators from `nullptr_t` and change
usage to enforce type consistency without conversion.
|
|
I was confused by the trim() API, thinking it would mutate the span it
was called on. Mark all const functions that return a new span with
[[nodiscard]] so we can catch such mistakes.
|
|
|
|
|
|
Problem:
- `Span` is not `constexpr` aware.
Solution:
- Add `constexpr` support for all parts that do not require
`reinterpret_cast`.
- Modify tests which use the `constexpr` functions.
|
|
|
|
|
|
|
|
|
|
|
|
Two changes were made
1. copy_to() and copy_trimmed_to() now return how many bytes were
copied.
2. The argument was changed to Span<typename RemoveConst<T>::Type>
because the following would not work:
ReadonlyBytes bytes0;
Bytes bytes1;
// Won't work because this calls Span<const u8>::copy_to(Span<u8>)
// but the method was defined as Span<const u8>::copy_to(Span<const u8>)
bytes0.copy_to(bytes1);
|
|
Previously, the following would not work:
Bytes{}.slice(0);
because it was asserted that `start < size()`.
|
|
https://github.com/SerenityOS/serenity/pull/3166#discussion_r471031704
|
|
|
|
|
|
|
|
This assertion was added to prevent accitentally using stuff like
Span<int*> instead of Span<int>. But there can be spans of pointers.
|
|
|
|
|
|
|
|
|
|
|
|
I accidently wrote `Span<RemoveConst<T>>` when I meant
`Span<RemoveConst<T>::Type>`.
Changing that wouldn't be enough though, this constructor can only be
defined if T is not const, otherwise it would redefine the copy
constructor. This can be avoided by overloading the cast operator.
|
|
This makes it possible to pass one object rather than pointer and length
individually.
|