- Switched from Allman (BSD) to 1TBS (K&R)
Namespaces, Types, and Requires/Concepts still use Allman
This commit is contained in:
@@ -43,8 +43,7 @@ struct default_delete
|
||||
///
|
||||
/// \brief Function Call Operator, calls `delete` on `ptr`
|
||||
/// \param ptr Memory resource to delete
|
||||
constexpr void operator()(TypeT* ptr) const noexcept
|
||||
{
|
||||
constexpr void operator()(TypeT* ptr) const noexcept {
|
||||
static_assert(not is_void_v<TypeT>, "cannot delete a pointer to an incomplete type");
|
||||
static_assert(not sizeof(TypeT) > 0, "cannot delete a pointer to an incomplete type");
|
||||
delete ptr;
|
||||
@@ -69,8 +68,7 @@ struct default_delete<TypeT[]>
|
||||
/// \brief Function Call Operator, calls `delete` on `ptr`
|
||||
/// \param ptr Memory resource to delete
|
||||
template<class ArrT> requires requires { is_convertible_v<ArrT(*)[], TypeT(*)[]> == true; }
|
||||
constexpr void operator()(TypeT* ptr) const noexcept
|
||||
{
|
||||
constexpr void operator()(TypeT* ptr) const noexcept {
|
||||
static_assert(not is_void_v<TypeT>, "cannot delete a pointer to an incomplete type");
|
||||
static_assert(not sizeof(TypeT) > 0, "cannot delete a pointer to an incomplete type");
|
||||
delete[] ptr;
|
||||
@@ -108,38 +106,45 @@ public:
|
||||
/// \brief Pointer Constructor, creates a unique_ptr that owns `ptr` with deleter `del`
|
||||
/// \param ptr The resource to own
|
||||
/// \param del The deleter
|
||||
explicit constexpr unique_ptr(pointer_t ptr, const delete_t& del) : _delete(del), _handle(ptr) {}
|
||||
explicit constexpr unique_ptr(pointer_t ptr, const delete_t& del)
|
||||
: _delete(del), _handle(ptr) {
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Pointer Constructor, creates a unique_ptr that owns `ptr` with deleter `del`
|
||||
/// \param ptr The resource to own
|
||||
/// \param del The deleter
|
||||
explicit constexpr unique_ptr(pointer_t ptr, delete_t&& del) : _delete(del), _handle(ptr) {}
|
||||
explicit constexpr unique_ptr(pointer_t ptr, delete_t&& del)
|
||||
: _delete(del), _handle(ptr) {
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Move Constructor, transfers ownership from `other`
|
||||
/// \param other The unique_ptr to take ownership from
|
||||
constexpr unique_ptr(unique_ptr&& other) : _handle(other._handle) { other._handle = nullptr; }
|
||||
constexpr unique_ptr(unique_ptr&& other)
|
||||
: _handle(other._handle) {
|
||||
other._handle = nullptr;
|
||||
}
|
||||
|
||||
// Delete copy constructor
|
||||
constexpr unique_ptr(const unique_ptr&) = delete;
|
||||
|
||||
///
|
||||
/// \brief Default Constructor, if it owns a resource, it deletes it using `delete_t`
|
||||
constexpr ~unique_ptr() { if(_handle) _delete(_handle); }
|
||||
constexpr ~unique_ptr() {
|
||||
if(_handle) _delete(_handle);
|
||||
}
|
||||
|
||||
constexpr unique_ptr& operator=(const unique_ptr&) = delete;
|
||||
|
||||
constexpr unique_ptr& operator=(unique_ptr&& r) noexcept
|
||||
{
|
||||
constexpr unique_ptr& operator=(unique_ptr&& r) noexcept {
|
||||
_delete = r._delete;
|
||||
_handle = r._handle;
|
||||
r._handle = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
pointer_t release()
|
||||
{
|
||||
pointer_t release() {
|
||||
pointer_t retval = _handle;
|
||||
_handle = nullptr;
|
||||
return retval;
|
||||
|
||||
Reference in New Issue
Block a user