mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 06:28:13 +00:00
AK: Define conversion from Span<T> to Span<const T> correctly.
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 commit is contained in:
parent
68cf22d580
commit
7036a9b6f7
2 changed files with 13 additions and 5 deletions
|
@ -36,6 +36,14 @@ TEST_CASE(default_constructor_is_empty)
|
|||
EXPECT(span.is_empty());
|
||||
}
|
||||
|
||||
TEST_CASE(implicit_converson_to_const)
|
||||
{
|
||||
Bytes bytes0;
|
||||
ReadonlyBytes bytes1 { bytes0 };
|
||||
[[maybe_unused]] ReadonlyBytes bytes2 = bytes0;
|
||||
[[maybe_unused]] ReadonlyBytes bytes3 = static_cast<ReadonlyBytes>(bytes2);
|
||||
}
|
||||
|
||||
TEST_CASE(span_works_with_constant_types)
|
||||
{
|
||||
const u8 buffer[4] { 1, 2, 3, 4 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue