mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:07:35 +00:00
AK: Made Strings reversible
`AK::String` can now be reversed via AK::String::reverse(). This makes life a lot easier for functions like `itoa()`, where the output ends up being backwards. Very much not like the normal STL (which requires an `std::reverse` object) way of doing things. A call to reverse returns a new `AK::String` so as to not upset any of the possible references to the same `StringImpl` shared between Strings.
This commit is contained in:
parent
093961d2d9
commit
26e81ad574
4 changed files with 28 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/kmalloc.h>
|
||||
|
||||
|
@ -44,6 +44,8 @@ public:
|
|||
return m_hash;
|
||||
}
|
||||
|
||||
NonnullRefPtr<StringImpl> reversed() const;
|
||||
|
||||
private:
|
||||
enum ConstructTheEmptyStringImplTag {
|
||||
ConstructTheEmptyStringImpl
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue