core:
* added memory.hpp * added public unfancy function
This commit is contained in:
33
src/entt/core/memory.hpp
Normal file
33
src/entt/core/memory.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef ENTT_CORE_MEMORY_HPP
|
||||
#define ENTT_CORE_MEMORY_HPP
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include "../config/config.h"
|
||||
|
||||
|
||||
namespace entt {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Unwraps fancy pointers, does nothing otherwise.
|
||||
* @tparam Type Pointer type.
|
||||
* @param ptr A pointer to evaluate.
|
||||
* @return A plain pointer.
|
||||
*/
|
||||
template<typename Type>
|
||||
[[nodiscard]] constexpr auto * unfancy(Type ptr) ENTT_NOEXCEPT {
|
||||
if constexpr(std::is_pointer_v<Type>) {
|
||||
return ptr;
|
||||
} else {
|
||||
return std::addressof(*ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "../config/config.h"
|
||||
#include "../core/algorithm.hpp"
|
||||
#include "../core/compressed_pair.hpp"
|
||||
#include "../core/fwd.hpp"
|
||||
#include "../core/memory.hpp"
|
||||
#include "../core/type_traits.hpp"
|
||||
#include "../signal/sigh.hpp"
|
||||
#include "component.hpp"
|
||||
@@ -248,14 +248,6 @@ class basic_storage: public basic_sparse_set<Entity, typename std::allocator_tra
|
||||
}
|
||||
}
|
||||
|
||||
Type * unfancy(alloc_pointer ptr) const {
|
||||
if constexpr(std::is_pointer_v<alloc_pointer>) {
|
||||
return ptr;
|
||||
} else {
|
||||
return std::addressof(*ptr);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void construct(alloc_pointer ptr, Args &&... args) {
|
||||
if constexpr(std::is_aggregate_v<value_type>) {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "core/family.hpp"
|
||||
#include "core/hashed_string.hpp"
|
||||
#include "core/ident.hpp"
|
||||
#include "core/memory.hpp"
|
||||
#include "core/monostate.hpp"
|
||||
#include "core/type_info.hpp"
|
||||
#include "core/type_traits.hpp"
|
||||
|
||||
Reference in New Issue
Block a user