summaryrefslogtreecommitdiff
path: root/AK/DefaultDelete.h
blob: be13a1018c67f3b29d5120da3d4ac85efa4291c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
 * Copyright (c) 2022, the SerenityOS developers.
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

namespace AK {

template<class T>
struct DefaultDelete {
    constexpr DefaultDelete() = default;

    constexpr void operator()(T* t)
    {
        delete t;
    }
};

template<class T>
struct DefaultDelete<T[]> {
    constexpr DefaultDelete() = default;

    constexpr void operator()(T* t)
    {
        delete[] t;
    }
};

}

#ifdef USING_AK_GLOBALLY
using AK::DefaultDelete;
#endif