EnTT 4.0.0
Loading...
Searching...
No Matches
memory.hpp
1#ifndef ENTT_STL_MEMORY_HPP
2#define ENTT_STL_MEMORY_HPP
3
5#if __has_include(<entt/ext/stl/memory.hpp>)
6# include <entt/ext/stl/memory.hpp>
7#else
8# include <memory>
9# include <version>
10# include "../config/config.h"
11
12namespace entt::stl {
13
14using std::addressof;
15using std::allocate_shared;
16using std::allocator;
17using std::allocator_arg;
18using std::allocator_arg_t;
19using std::allocator_traits;
20using std::default_delete;
21using std::destroy;
22using std::enable_shared_from_this;
23using std::make_shared;
24using std::make_unique;
25using std::pointer_traits;
26using std::shared_ptr;
27using std::static_pointer_cast;
28using std::uninitialized_fill;
29using std::unique_ptr;
30using std::uses_allocator_v;
31
32} // namespace entt::stl
33
34# ifndef ENTT_FORCE_STL
35# if defined(__cpp_lib_to_address)
36# define ENTT_HAS_TO_ADDRESS
37
38namespace entt::stl {
39
40using std::to_address;
41
42} // namespace entt::stl
43
44# endif
45# endif
46
47# ifndef ENTT_HAS_TO_ADDRESS
48# include <type_traits>
49
50namespace entt::stl {
51
52template<typename Type>
53constexpr Type *to_address(Type *ptr) noexcept {
54 static_assert(!std::is_function_v<Type>, "Invalid type");
55 return ptr;
56}
57
58template<typename Type>
59constexpr auto to_address(const Type &ptr) noexcept {
60 if constexpr(requires { std::pointer_traits<Type>::to_address(ptr); }) {
61 return std::pointer_traits<Type>::to_address(ptr);
62 } else {
63 return to_address(ptr.operator->());
64 }
65}
66
67} // namespace entt::stl
68# endif
69#endif
71
72#undef ENTT_HAS_TO_ADDRESS
73
74#endif
Custom EnTT namespace for the standard template library.
Definition entt.hpp:5