summaryrefslogtreecommitdiff
path: root/AK/Span.h
AgeCommit message (Collapse)Author
2022-04-02AK: Add last() utility function to SpanBen Maxwell
2022-02-26AK: Add constructor to create Span from ArrayArne Elster
It's a convenience constructor. But it also seems more consistent to allow a Span being made from both raw and managed arrays.
2022-02-23AK: Add Traits<Span<T>>::hash()Linus Groh
2021-12-16AK: Use __builtin_memmove for ByteBuffer and Span's overwritesin-ack
__builtin_memcpy will fail when the target area and the source area overlap. Using __builtin_memmove will handle this case as well.
2021-10-17AK: Make Span trivially copy-constructibleDaniel Bertalan
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.
2021-09-13AK: Make Span::operator==() comply with the ISO C++ idea of operator==Ali Mohammad Pur
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.
2021-09-13AK: Switch Span.h to east-const styleAli Mohammad Pur
2021-07-01AK: Annotate more AK::Span methods as nodiscardBrian Gianforcaro
2021-05-27AK: Add a way to slice from the end of a spanAli Mohammad Pur
2021-05-10AK: Add missing 'const' in SpanMatthew Olsson
2021-05-07AK: Implement Span::starts_with()Valtteri Koskivuori
Useful for checking for contents at the start of a span.
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
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 *
2021-04-10AK+Everywhere: Make StdLibExtras templates less wrapper-yAnotherTest
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. :^)
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...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.
2021-02-21AK: Do bounds checking (assertions) in Span::operator[]Andreas Kling
2021-02-21AK: Add Span<T> constructor for arraysBrian Gianforcaro
The array constructor allows arrays to be easily treated as generic span of data.
2021-01-12AK: Simplify constructors and conversions from nullptr_tLenny Maiorani
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.
2020-12-19AK: Mark some Span functions with [[nodiscard]]Andreas Kling
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.
2020-12-19LibTLS+LibCrypto: More ByteBuffer -> Span conversionAndreas Kling
2020-12-19LibTLS+LibCrypto: Replace a whole bunch of ByteBuffers with SpansAndreas Kling
2020-10-16Span: constexpr supportLenny Maiorani
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.
2020-09-21AK: Add missing const in Span::operator==.asynts
2020-09-15AK: Add OutputMemoryStream::fill_to_end.asynts
2020-09-09AK: Use TypedTransfer in Span::copy_to.asynts
2020-09-08Refactor: Replace usages of FixedArray with Vector.asynts
2020-09-08AK: Add generic SimpleIterator class to replace VectorIterator.asynts
2020-08-20AK: Span: Fix signature of copy_to() and copy_trimmed_to().asynts
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);
2020-08-20AK: Span: Allow slicing with zero length.asynts
Previously, the following would not work: Bytes{}.slice(0); because it was asserted that `start < size()`.
2020-08-17AK: Always call memmove in Span instead of memcpy.asynts
https://github.com/SerenityOS/serenity/pull/3166#discussion_r471031704
2020-08-15AK: Add slice() overload to Span.asynts
2020-08-15AK: Add fill() method to Span.asynts
2020-08-15AK: Add copy_to() and move_to() methods to AK::Span.asynts
2020-08-15AK: Remove incorrect static assert in Span.h.asynts
This assertion was added to prevent accitentally using stuff like Span<int*> instead of Span<int>. But there can be spans of pointers.
2020-08-11AK: Span<T>::operator=(const T&) => Span<T>::operator=(const Span<T>&)AnotherTest
2020-07-27AK: Rename Span::subspan() to Span::slice().asynts
2020-07-27AK: Add offset() method to Span.asynts
2020-07-27AK: Add implicit conversion from nullptr to Span.asynts
2020-07-27AK: Add constructors to Bytes and ReadonlyBytes that take void pointers.asynts
2020-07-27AK: Define conversion from Span<T> to Span<const T> correctly.asynts
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.
2020-07-26AK: Implement Span which represents a contiguous sequence of objects.asynts
This makes it possible to pass one object rather than pointer and length individually.