28 #ifndef YB_INC_ystdex_memory_hpp_
29 #define YB_INC_ystdex_memory_hpp_ 1
43 template<
typename _type>
49 template<
typename _type>
55 template<
typename _type>
61 template<
typename _type>
65 return p.lock().get();
75 template<
typename _type>
86 template<
typename _type>
112 template<
typename _type,
typename _pSrc>
116 static_assert(is_pointer<_pSrc>::value,
"Invalid type found.");
118 return std::unique_ptr<_type>(p);
124 template<
typename _type,
typename _pSrc>
128 static_assert(is_pointer<_pSrc>::value,
"Invalid type found.");
130 return std::unique_ptr<_type>(p);
132 template<
typename _type>
136 return std::unique_ptr<_type>(p);
142 template<
typename _type>
146 return std::unique_ptr<_type>();
163 template<
typename _type,
typename _pSrc>
167 static_assert(is_pointer<_pSrc>::value,
"Invalid type found.");
169 return std::shared_ptr<_type>(p);
175 template<
typename _type,
typename _pSrc>
179 static_assert(is_pointer<_pSrc>::value,
"Invalid type found.");
181 return std::shared_ptr<_type>(p);
183 template<
typename _type>
187 return std::shared_ptr<_type>(p);
193 template<
typename _type>
197 return std::shared_ptr<_type>();
211 template<
typename _type,
typename... _tParams>
215 return std::unique_ptr<_type>(
new _type(
yforward(args)...));
217 template<
typename _type,
typename... _tParams>
219 std::unique_ptr<_type>>)
224 template<
typename _type,
typename... _tParams>
237 template<typename _type, typename... _tParams>
241 return std::shared_ptr<_type>(
new _type(
yforward(args)...));
yconstfn const string _tParams && args
std::unique_ptr< _type > unique_raw(const _pSrc &p)
std::shared_ptr< _type > make_shared(_tParams &&...args)
使用 new 和指定参数构造指定类型的 std::shared_ptr 实例。
std::shared_ptr< _type > share_raw(const _pSrc &p)
typename remove_extent< _type >::type remove_extent_t
#define yforward(_expr)
根据参数类型使用 std::forward 传递对应参数。
_type * get_raw(_type *const &p)
#define ynothrow
YSLib 无异常抛出保证:若支持 noexcept 关键字, 指定特定的 noexcept 异常规范。
#define yconstfn
指定编译时常量函数。
bool reset(std::unique_ptr< _type > &p)
enable_if_t<!is_array< _type >::value, std::unique_ptr< _type > > make_unique(_tParams &&...args)
使用 new 和指定参数构造指定类型的 std::unique_ptr 实例。
typename enable_if< _bCond, _type >::type enable_if_t