Files
fennec/include/fennec/memory/new.h

57 lines
1.8 KiB
C++

// =====================================================================================================================
// fennec, a free and open source game engine
// Copyright (C) 2025 Medusa Slockbower
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//2
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef FENNEC_MEMORY_NEW_H
#define FENNEC_MEMORY_NEW_H
#include <new>
#include <fennec/lang/types.h>
#include <fennec/lang/utility.h>
namespace fennec
{
///
/// \brief Alignment class to handle conflicting definitions
enum class align_t : size_t;
///
/// \brief Type to handle explicit nothrow definitions
struct nothrow_t { explicit nothrow_t() noexcept { } };
template<typename TypeT> void construct(TypeT* ptr)
{ ptr->TypeT(); }
template<typename TypeT> void construct(TypeT* ptr, const TypeT& val)
{ ptr->TypeT(val); }
template<typename TypeT> void construct(TypeT* ptr, TypeT&& val)
{ ptr->TypeT(fennec::forward<TypeT>(val)); }
template<typename TypeT, typename...ArgsT> void construct(TypeT* ptr, ArgsT...args)
{ ptr->TypeT(fennec::forward<TypeT>(args)...); }
template<typename TypeT> void destruct(TypeT* ptr)
{ ptr->~TypeT(); }
}
#endif // FENNEC_MEMORY_NEW_H