1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:37:34 +00:00

Add clang-format file

Also run it across the whole tree to get everything using the One True Style.
We don't yet run this in an automated fashion as it's a little slow, but
there is a snippet to do so in makeall.sh.
This commit is contained in:
Robin Burchell 2019-05-28 11:53:16 +02:00 committed by Andreas Kling
parent c11351ac50
commit 0dc9af5f7e
286 changed files with 3244 additions and 2424 deletions

View file

@ -1,24 +1,34 @@
#pragma once
#include "StdLibExtras.h"
#include "Types.h"
#include "Traits.h"
#include "Types.h"
namespace AK {
template<typename T>
class OwnPtr {
public:
OwnPtr() { }
explicit OwnPtr(T* ptr) : m_ptr(ptr) { }
OwnPtr(OwnPtr&& other) : m_ptr(other.leak_ptr()) { }
template<typename U> OwnPtr(OwnPtr<U>&& other) : m_ptr(static_cast<T*>(other.leak_ptr())) { }
OwnPtr(std::nullptr_t) { };
OwnPtr() {}
explicit OwnPtr(T* ptr)
: m_ptr(ptr)
{
}
OwnPtr(OwnPtr&& other)
: m_ptr(other.leak_ptr())
{
}
template<typename U>
OwnPtr(OwnPtr<U>&& other)
: m_ptr(static_cast<T*>(other.leak_ptr()))
{
}
OwnPtr(std::nullptr_t) {};
~OwnPtr()
{
clear();
#ifdef SANITIZE_PTRS
if constexpr(sizeof(T*) == 8)
if constexpr (sizeof(T*) == 8)
m_ptr = (T*)(0xe1e1e1e1e1e1e1e1);
else
m_ptr = (T*)(0xe1e1e1e1);
@ -91,7 +101,8 @@ private:
T* m_ptr = nullptr;
};
template<class T, class... Args> inline OwnPtr<T>
template<class T, class... Args>
inline OwnPtr<T>
make(Args&&... args)
{
return OwnPtr<T>(new T(AK::forward<Args>(args)...));
@ -105,6 +116,5 @@ struct Traits<OwnPtr<T>> {
}
using AK::OwnPtr;
using AK::make;
using AK::OwnPtr;