fennec/include/fennec/memory/ptr_traits.h

49 lines
1.7 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_PTR_TRAITS_H
#define FENNEC_MEMORY_PTR_TRAITS_H
#include <fennec/lang/types.h>
#include <fennec/memory/detail/__ptr_traits.h>
namespace fennec
{
///
/// \brief Class for retrieving the traits of Pointer-like types
/// \tparam ClassT The Pointer class type
template<typename ClassT>
struct ptr_traits
: detail::__ptr_traits_impl<ClassT, detail::__ptr_get_element<ClassT>> {};
// overload for C-Style Pointers
template<typename ElemT>
struct ptr_traits<ElemT*> : detail::__ptr_traits_ptr_to<ElemT*, ElemT>
{
using pointer_t = ElemT*;
using element_t = ElemT;
using diff_t = ptrdiff_t;
template<typename U> using rebind = U*;
};
}
#endif // FENNEC_MEMORY_PTR_TRAITS_H