YSTest: memory.hpp 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

memory.hpp
浏览该文件的文档.
1 /*
2 © 2011-2020 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
30 #ifndef YB_INC_ystdex_memory_hpp_
31 #define YB_INC_ystdex_memory_hpp_ 1
32
33 #include "allocator.hpp" // for <memory>, "pointer.hpp", "allocator.hpp",
34 // internal "placement.hpp", std::free, enable_if_convertible_t, bool_, false_,
35 // true_, std::pair, cond_or, remove_reference_t, detected_or_t,
36 // remove_pointer_t, is_void, indirect_element_t, not_, yconstraint,
37 // is_pointer, enable_if_t, is_array, extent, remove_extent_t, is_polymorphic;
38 #include <limits> // for std::numeric_limits;
39 #include "ref.hpp" // for is_reference_wrapper;
40
47 #ifndef __cpp_lib_make_unique
48 # if YB_IMPL_MSCPP >= 1800 || __cplusplus >= 201304L
49 # define __cpp_lib_make_unique 201304L
50 # endif
51 #endif
52
53
54 namespace ystdex
55 {
56
58 namespace details
59 {
60
61 template<typename _type, typename... _tParams>
62 YB_NORETURN inline _type
63 create_or_throw_impl(void*, _tParams&&...)
64 {
65 throw_invalid_construction();
66 }
68 template<typename _type, typename... _tParams>
69 YB_ATTR_nodiscard inline auto
70 create_or_throw_impl(nullptr_t, _tParams&&... args)
71 -> decltype(_type(yforward(args)...))
72 {
73 return _type(yforward(args)...);
74 }
75
76 template<typename _type, class _tAlloc, typename... _tParams>
77 YB_NORETURN _type*
78 create_or_throw_with_allocator_impl(void*, _tAlloc&, _tParams&&...)
79 {
80 throw_invalid_construction();
81 }
82 template<typename _type, class _tAlloc, typename... _tParams>
83 YB_ATTR_nodiscard inline auto
84 create_or_throw_with_allocator_impl(nullptr_t, _tAlloc& a, _tParams&&... args)
85 -> decltype(ystdex::create_with_allocator<_type>(a, yforward(args)...))
86 {
87 return ystdex::create_with_allocator<_type>(a, yforward(args)...);
88 }
89
90 template<typename _type, typename... _tParams>
91 YB_NORETURN inline _type*
92 new_or_throw_impl(void*, _tParams&&...)
93 {
94 throw_invalid_construction();
95 }
96 template<typename _type, typename... _tParams>
97 YB_ATTR_nodiscard inline auto
98 new_or_throw_impl(nullptr_t, _tParams&&... args)
99 -> decltype(new _type(yforward(args)...))
100 {
101 return new _type(yforward(args)...);
102 }
103
104 } // namespace details;
105
106
118 template<typename _type, typename... _tParams>
119 YB_ATTR_nodiscard inline _type
120 create_or_throw(_tParams&&... args)
121 {
122 return details::create_or_throw_impl<_type>(nullptr, yforward(args)...);
123 }
124
126 template<typename _type, class _tAlloc, typename... _tParams>
127 YB_ATTR_nodiscard _type*
128 create_or_throw_with_allocator(_tAlloc&& a, _tParams&&... args)
129 {
130 return details::create_or_throw_with_allocator_impl<_type>(nullptr, a,
131 yforward(args)...);
132 }
133
135 template<typename _type, typename... _tParams>
136 YB_ATTR_nodiscard _type*
137 new_or_throw(_tParams&&... args)
138 {
139 return details::new_or_throw_impl<_type>(nullptr, yforward(args)...);
140 }
142
143
152 template<typename _type>
153 struct is_sharing : false_
154 {};
155
156 template<typename _type>
157 struct is_sharing<std::shared_ptr<_type>> : true_
158 {};
159
160 template<typename _type>
161 struct is_sharing<std::weak_ptr<_type>> : true_
162 {};
164
165
176 template<typename _type>
177 struct free_delete
178 {
179 yconstfn free_delete() ynothrow = default;
180 template<typename _type2,
181 yimpl(typename = enable_if_convertible_t<_type2*, _type*>)>
182 free_delete(const free_delete<_type2>&) ynothrow
183 {}
184
186 void
187 operator()(_type* p) const ynothrowv
188 {
189 p->~_type();
190 std::free(p);
191 }
192 };
193
194 template<typename _type>
195 struct free_delete<_type[]>
196 {
198
199 static_assert(is_trivially_destructible<_type>(), "Invalid type found");
200
201 yconstfn free_delete() ynothrow = default;
202 template<typename _type2,
203 yimpl(typename = enable_if_convertible_t<_type2(*)[], _type(*)[]>)>
204 free_delete(const free_delete<_type2[]>&) ynothrow
205 {}
206
207 template<typename _type2,
208 yimpl(typename = enable_if_convertible_t<_type2(*)[], _type(*)[]>)>
209 void
210 operator()(_type2* p) const ynothrowv
211 {
212 std::free(p);
213 }
215 };
217
218
225 namespace details
226 {
227
228 #if __cpp_aligned_new >= 201606L
229 # define YB_Impl_aligned_new true
230 #endif
231 template<typename _type>
232 using over_aligned_t
233 #if YB_Impl_aligned_new
234 = bool_<(yalignof(_type) > __STDCPP_DEFAULT_NEW_ALIGNMENT__)>;
235 #else
236 = false_;
237 #endif
238
239 YB_ALLOCATOR inline void*
240 new_aligned(size_t size, size_t, false_) ynothrow
241 {
242 return ::operator new(size, std::nothrow);
243 }
244 #if YB_Impl_aligned_new
245 YB_ALLOCATOR inline void*
246 new_aligned(size_t size, size_t alignment, true_) ynothrow
247 {
248 return ::operator new(size, std::align_val_t(alignment), std::nothrow);
249 }
250 #endif
251
252 inline void
253 delete_aligned(void* ptr, size_t, false_) ynothrow
254 {
255 // NOTE: No %std::nothrow is needed here. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86954.
256 ::operator delete(ptr);
257 }
258 #if YB_Impl_aligned_new
259 inline void
260 delete_aligned(void* ptr, size_t alignment, true_) ynothrow
261 {
262 ::operator delete(ptr, std::align_val_t(alignment));
263 }
264 #endif
265 #undef YB_Impl_aligned_new
266
267 } // namespace details;
268
269
270 #if (YB_IMPL_MSCPP >= 1912 && _MSVC_LANG >= 201606) || (__GLIBCXX__ \
271 && (__GLIBCXX__ <= 20150815 || YB_IMPL_GNUCPP < 90000)) \
272 || __cplusplus >= 201611L
273 template<typename _type>
274 YB_ATTR_nodiscard inline std::pair<_type*, ptrdiff_t>
275 get_temporary_buffer(ptrdiff_t n) ynothrow
276 {
277 const ptrdiff_t m(std::numeric_limits<ptrdiff_t>::max() / sizeof(_type));
278
279 // NOTE: Like libstdc++ and libc++ but not Microsoft VC++ 2017, this does
280 // not fail fast.
281 if(n > m)
282 n = m;
283 while(n > 0)
284 {
285 if(const auto p = details::new_aligned(static_cast<size_t>(n)
286 * sizeof(_type), yalignof(_type), details::over_aligned_t<_type>()))
287 return {static_cast<_type*>(p), n};
288 n /= 2;
289 }
290 return {nullptr, 0};
291 }
292
293 template<typename _type>
294 inline void
295 return_temporary_buffer(_type* p) ynothrow
296 {
297 details::delete_aligned(p, yalignof(_type),
298 details::over_aligned_t<_type>());
299 }
300 #else
301 using std::get_temporary_buffer;
302 using std::return_temporary_buffer;
303 #endif
304
305
306
314 template<typename>
315 struct temporary_buffer_delete;
316
317 template<typename _type>
318 struct temporary_buffer_delete<_type[]>
319 {
320 yconstfn temporary_buffer_delete() ynothrow = default;
321
322 void
323 operator()(_type* p) const ynothrowv
324 {
325 ystdex::return_temporary_buffer(p);
326 }
327 };
329
330
337 template<typename _type>
338 class temporary_buffer
339 {
340 public:
341 using array_type = _type[];
342 using element_type = _type;
343 using deleter = temporary_buffer_delete<array_type>;
344 using pointer = std::unique_ptr<_type, deleter>;
345
346 private:
347 std::pair<pointer, size_t> buf;
348
349 public:
351 temporary_buffer(size_t n)
352 : buf([n]{
353 // NOTE: See LWG 2072.
354 const auto pr(ystdex::get_temporary_buffer<_type>(ptrdiff_t(n)));
355
356 if(pr.first)
357 return std::pair<pointer, size_t>(pointer(pr.first),
358 size_t(pr.second));
359 throw std::bad_cast();
360 }())
361 {}
362 temporary_buffer(temporary_buffer&&) = default;
363 temporary_buffer&
364 operator=(temporary_buffer&&) = default;
365
367 YB_ATTR_nodiscard yconstfn const pointer&
368 get() const ynothrow
369 {
370 return buf.first;
371 }
372
373 YB_ATTR_nodiscard YB_PURE pointer&
374 get_pointer_ref() ynothrow
375 {
376 return buf.first;
377 }
378
379 YB_ATTR_nodiscard YB_PURE size_t
380 size() const ynothrow
381 {
382 return buf.second;
383 }
384 };
386
387
393 template<class _tDeleter>
395 using deleter_member_pointer_t
396 = typename remove_reference_t<_tDeleter>::pointer;
397
399 template<typename _type, class _tDeleter>
400 using unique_ptr_pointer
401 = detected_or_t<_type*, deleter_member_pointer_t, _tDeleter>;
402
408 template<typename _tPointer, typename _tDefault = void>
409 using defer_element = cond_or<not_<is_void<remove_pointer_t<_tPointer>>>,
410 _tDefault, indirect_element_t, _tPointer>;
412
413
420 template<typename _type, typename _fDeleter>
421 inline bool
422 is_undereferenceable(const std::unique_ptr<_type, _fDeleter>& p) ynothrow
423 {
424 return !p;
425 }
426 template<typename _type>
427 inline bool
428 is_undereferenceable(const std::shared_ptr<_type>& p) ynothrow
429 {
430 return !p;
431 }
432 template<typename _type>
433 inline bool
434 is_undereferenceable(const std::weak_ptr<_type>& p) ynothrow
435 {
436 // XXX: Although conforming, this is actually not sufficient. There can be
437 // some false negative results when the pointer is null.
438 return !p.expired();
439 }
441
447 template<typename _type>
448 YB_ATTR_nodiscard YB_STATELESS yconstfn _type*
449 get_raw(_type* const& p) ynothrow
450 {
451 return p;
452 }
454 template<typename _type, typename _fDeleter>
455 YB_ATTR_nodiscard YB_PURE yconstfn auto
456 get_raw(const std::unique_ptr<_type, _fDeleter>& p) ynothrow
457 -> decltype(p.get())
458 {
459 return p.get();
460 }
461 template<typename _type>
462 YB_ATTR_nodiscard YB_PURE yconstfn _type*
463 get_raw(const std::shared_ptr<_type>& p) ynothrow
464 {
465 return p.get();
466 }
467 template<typename _type>
468 YB_ATTR_nodiscard YB_PURE yconstfn _type*
469 get_raw(const std::weak_ptr<_type>& p) ynothrow
470 {
471 return p.lock().get();
472 }
474
480 template<typename _type>
481 YB_ATTR_nodiscard YB_STATELESS yconstfn bool
482 owns_any(_type* const&) ynothrow
483 {
484 return {};
485 }
487 template<typename _type, typename _fDeleter>
488 YB_ATTR_nodiscard YB_PURE yconstfn bool
489 owns_any(const std::unique_ptr<_type, _fDeleter>& p) ynothrow
490 {
491 return bool(p);
492 }
493 template<typename _type>
494 YB_ATTR_nodiscard YB_PURE yconstfn bool
495 owns_any(const std::shared_ptr<_type>& p) ynothrow
496 {
497 return p.use_count() > 0;
498 }
499 template<typename _type>
500 YB_ATTR_nodiscard YB_PURE yconstfn bool
501 owns_any(const std::weak_ptr<_type>& p) ynothrow
502 {
503 return !p.expired();
504 }
506
512 template<typename _type>
513 YB_ATTR_nodiscard YB_STATELESS yconstfn bool
514 owns_nonnull(_type* const&) ynothrow
515 {
516 return {};
517 }
519 template<typename _type, typename _fDeleter>
520 YB_ATTR_nodiscard YB_PURE yconstfn bool
521 owns_nonnull(const std::unique_ptr<_type, _fDeleter>& p) ynothrow
522 {
523 return bool(p);
524 }
525 template<typename _type>
526 YB_ATTR_nodiscard YB_PURE yconstfn bool
527 owns_nonnull(const std::shared_ptr<_type>& p) ynothrow
528 {
529 return bool(p);
530 }
531 template<typename _type>
532 YB_ATTR_nodiscard YB_PURE yconstfn bool
533 owns_nonnull(const std::weak_ptr<_type>& p) ynothrow
534 {
535 return bool(p.lock());
536 }
538
544 template<typename _type>
545 YB_ATTR_nodiscard YB_STATELESS yconstfn bool
546 owns_unique(const _type&) ynothrow
547 {
548 return !is_reference_wrapper<_type>();
549 }
550 template<typename _type, class _tDeleter>
551 YB_ATTR_nodiscard inline bool
552 owns_unique(const std::unique_ptr<_type, _tDeleter>& p) ynothrow
553 {
554 return bool(p);
555 }
557 template<typename _type>
558 YB_ATTR_nodiscard YB_PURE inline bool
559 owns_unique(const std::shared_ptr<_type>& p) ynothrow
560 {
561 return p.unique();
562 }
564 template<typename _type>
565 YB_ATTR_nodiscard YB_PURE inline bool
566 owns_unique(const std::weak_ptr<_type>& p) ynothrow
567 {
568 return p.use_count() == 1;
569 }
570
571 template<typename _type>
572 YB_ATTR_nodiscard YB_STATELESS yconstfn bool
573 owns_unique_nonnull(const _type&) ynothrow
574 {
575 return !is_reference_wrapper<_type>();
576 }
578
579 template<typename _type, class _tDeleter>
580 YB_ATTR_nodiscard YB_PURE inline bool
581 owns_unique_nonnull(const std::unique_ptr<_type, _tDeleter>& p) ynothrow
582 {
583 yconstraint(p);
584 return true;
585 }
586 template<typename _type>
587 YB_ATTR_nodiscard YB_PURE inline bool
588 owns_unique_nonnull(const std::shared_ptr<_type>& p) ynothrow
589 {
590 yconstraint(p);
591 return p.unique();
592 }
594 template<typename _type>
595 YB_ATTR_nodiscard YB_PURE inline bool
596 owns_unique_nonnull(const std::weak_ptr<_type>& p) ynothrow
597 {
598 yconstraint(!p.expired());
599 return p.use_count() == 1;
600 }
602
603
610 template<typename _type, class _tDeleter>
612 inline bool
613 reset(std::unique_ptr<_type, _tDeleter>& p) ynothrow
614 {
615 if(p.get())
616 {
617 p.reset();
618 return true;
619 }
620 return {};
621 }
622 template<typename _type>
623 inline bool
624 reset(std::shared_ptr<_type>& p) ynothrow
625 {
626 if(p.get())
627 {
628 p.reset();
629 return true;
630 }
631 return {};
632 }
634
643 template<typename _type, typename _pSrc>
644 YB_ATTR_nodiscard yconstfn std::unique_ptr<_type>
645 unique_raw(_pSrc* p) ynothrow
646 {
647 return std::unique_ptr<_type>(p);
648 }
649 template<typename _type>
650 YB_ATTR_nodiscard yconstfn std::unique_ptr<_type>
651 unique_raw(_type* p) ynothrow
652 {
653 return std::unique_ptr<_type>(p);
654 }
655 template<typename _type, typename _tDeleter, typename _pSrc>
656 YB_ATTR_nodiscard yconstfn std::unique_ptr<_type, _tDeleter>
657 unique_raw(_pSrc* p, _tDeleter&& d) ynothrow
658 {
659 return std::unique_ptr<_type, _tDeleter>(p, yforward(d));
660 }
661 template<typename _type, typename _tDeleter>
662 YB_ATTR_nodiscard yconstfn std::unique_ptr<_type, _tDeleter>
663 unique_raw(_type* p, _tDeleter&& d) ynothrow
664 {
665 return std::unique_ptr<_type, _tDeleter>(p, yforward(d));
666 }
671 template<typename _type>
672 YB_ATTR_nodiscard yconstfn std::unique_ptr<_type>
673 unique_raw(nullptr_t) ynothrow
674 {
675 return std::unique_ptr<_type>();
676 }
678
679
688
690 template<typename _type, typename... _tParams>
691 YB_ATTR_nodiscard yconstfn std::shared_ptr<_type>
692 share_raw(_type* p, _tParams&&... args)
693 {
694 return std::shared_ptr<_type>(p, yforward(args)...);
695 }
700 template<typename _type, typename _pSrc, typename... _tParams>
701 YB_ATTR_nodiscard yconstfn std::shared_ptr<_type>
702 share_raw(_pSrc&& p, _tParams&&... args)
703 {
704 static_assert(is_pointer<remove_reference_t<_pSrc>>(),
705 "Invalid type found.");
706
707 return std::shared_ptr<_type>(p, yforward(args)...);
708 }
710
714 template<typename _type>
715 YB_ATTR_nodiscard yconstfn std::shared_ptr<_type>
716 share_raw(nullptr_t) ynothrow
717 {
718 return std::shared_ptr<_type>();
719 }
725 template<typename _type, class... _tParams>
726 YB_ATTR_nodiscard yconstfn
727 yimpl(enable_if_t)<sizeof...(_tParams) != 0, std::shared_ptr<_type>>
728 share_raw(nullptr_t, _tParams&&... args) ynothrow
729 {
730 return std::shared_ptr<_type>(nullptr, yforward(args)...);
731 }
733
734
736
737
742 inline namespace cpp2014
743 {
744
745 #if __cpp_lib_make_unique >= 201304L
746 using std::make_unique;
748 #else
749
757 template<typename _type, typename... _tParams>
758 YB_ATTR_nodiscard yconstfn
759 yimpl(enable_if_t<!is_array<_type>::value, std::unique_ptr<_type>>)
760 make_unique(_tParams&&... args)
761 {
762 return std::unique_ptr<_type>(new _type(yforward(args)...));
763 }
764 template<typename _type, typename... _tParams>
765 YB_ATTR_nodiscard yconstfn yimpl(enable_if_t<is_array<_type>::value
766 && extent<_type>::value == 0, std::unique_ptr<_type>>)
767 make_unique(size_t size)
768 {
769 return std::unique_ptr<_type>(new remove_extent_t<_type>[size]());
770 }
771 template<typename _type, typename... _tParams>
772 yimpl(enable_if_t<extent<_type>::value != 0>)
773 make_unique(_tParams&&...) = delete;
775 #endif
776
777 } // inline namespace cpp2014;
778
785 template<typename _type, typename... _tParams>
786 YB_ATTR_nodiscard yconstfn
787 yimpl(enable_if_t<!is_array<_type>::value, std::unique_ptr<_type>>)
788 make_unique_default_init()
789 {
790 return std::unique_ptr<_type>(new _type);
791 }
792 template<typename _type, typename... _tParams>
793 YB_ATTR_nodiscard yconstfn yimpl(enable_if_t<is_array<_type>::value
794 && extent<_type>::value == 0, std::unique_ptr<_type>>)
795 make_unique_default_init(size_t size)
796 {
797 return std::unique_ptr<_type>(new remove_extent_t<_type>[size]);
798 }
799 template<typename _type, typename... _tParams>
800 yimpl(enable_if_t<extent<_type>::value != 0>)
801 make_unique_default_init(_tParams&&...) = delete;
803
808 template<typename _type, typename _tElem>
809 YB_ATTR_nodiscard yconstfn std::unique_ptr<_type>
810 make_unique(std::initializer_list<_tElem> il)
811 {
812 return ystdex::cpp2014::make_unique<_type>(il);
813 }
814
820 template<typename _type, typename _tDeleter, typename... _tParams>
822 YB_ATTR_nodiscard yconstfn yimpl(enable_if_t<!is_array<_type>::value,
823 std::unique_ptr<_type, _tDeleter>>)
824 make_unique_with(_tDeleter&& d, _tParams&&... args)
825 {
826 return std::unique_ptr<_type, _tDeleter>(new _type(yforward(args)...),
827 yforward(d));
828 }
829 template<typename _type, typename _tDeleter, typename... _tParams>
830 YB_ATTR_nodiscard yconstfn yimpl(enable_if_t<is_array<_type>()
831 && extent<_type>() == 0, std::unique_ptr<_type>>)
832 make_unique_with(_tDeleter&& d, size_t size)
833 {
834 return std::unique_ptr<_type, _tDeleter>(new remove_extent_t<_type>[size],
835 yforward(d));
836 }
837 template<typename _type, typename _tDeleter, typename... _tParams>
838 yimpl(enable_if_t<is_array<_type>() && extent<_type>() != 0>)
839 make_unique_with(_tDeleter&&, _tParams&&...) = delete;
841
842
844
845 using std::make_shared;
853 template<typename _type, typename _tValue>
854 YB_ATTR_nodiscard yconstfn std::shared_ptr<_type>
855 make_shared(std::initializer_list<_tValue> il)
856 {
857 return std::make_shared<_type>(il);
858 }
859
864 template<typename _type>
865 YB_ATTR_nodiscard inline std::weak_ptr<_type>
866 make_weak(const std::shared_ptr<_type>& p) ynothrow
867 {
868 return p;
869 }
871
872
874
875 template<typename _tValue, typename _type = _tValue>
877 YB_ATTR_nodiscard yconstfn std::shared_ptr<decay_t<_type>>
878 share_copy(const _tValue& v)
879 {
880 return ystdex::make_shared<decay_t<_type>>(v);
881 }
883
884 template<typename _tValue, typename _type = _tValue>
886 YB_ATTR_nodiscard yconstfn std::shared_ptr<decay_t<_type>>
887 share_copy(std::initializer_list<_tValue> il)
888 {
889 return ystdex::make_shared<decay_t<_type>>(il);
890 }
892 template<typename _tValue, class _tAlloc, typename _type = _tValue>
893 YB_ATTR_nodiscard yconstfn std::shared_ptr<decay_t<_type>>
894 share_copy(const _tAlloc& a, const _tValue& v)
895 {
896 return ystdex::allocate_shared<decay_t<_type>>(a, v);
897 }
899 template<typename _tValue, class _tAlloc, typename _type = _tValue>
900 YB_ATTR_nodiscard yconstfn std::shared_ptr<decay_t<_type>>
901 share_copy(const _tAlloc& a, std::initializer_list<_tValue> il)
902 {
903 return ystdex::allocate_shared<decay_t<_type>>(a, il);
904 }
906
908 template<typename _tValue, typename _type = _tValue>
909 YB_ATTR_nodiscard yconstfn std::shared_ptr<decay_t<_type>>
910 share_forward(_tValue&& v)
911 {
912 return ystdex::make_shared<decay_t<_type>>(yforward(v));
913 }
915
916 template<typename _tValue, typename _type = _tValue>
918 YB_ATTR_nodiscard yconstfn std::shared_ptr<decay_t<_type>>
919 share_forward(std::initializer_list<_tValue> il)
920 {
921 return ystdex::make_shared<decay_t<_type>>(il);
922 }
924 template<typename _tValue, class _tAlloc, typename _type = _tValue>
925 YB_ATTR_nodiscard yconstfn std::shared_ptr<decay_t<_type>>
926 share_forward(const _tAlloc& a, _tValue&& v)
927 {
928 return ystdex::allocate_shared<decay_t<_type>>(a, yforward(v));
929 }
931 template<typename _tValue, class _tAlloc, typename _type = _tValue>
932 YB_ATTR_nodiscard yconstfn std::shared_ptr<decay_t<_type>>
933 share_forward(const _tAlloc& a, std::initializer_list<_tValue> il)
934 {
935 return ystdex::allocate_shared<decay_t<_type>>(a, il);
936 }
938
940 template<typename _tValue, typename _type = _tValue>
941 YB_ATTR_nodiscard yconstfn std::shared_ptr<decay_t<_type>>
942 share_move(_tValue&& v)
943 {
944 return ystdex::make_shared<decay_t<_type>>(std::move(v));
945 }
947
948 template<typename _tValue, typename _type = _tValue>
950 YB_ATTR_nodiscard yconstfn std::shared_ptr<decay_t<_type>>
951 share_move(std::initializer_list<_tValue> il)
952 {
953 return ystdex::make_shared<decay_t<_type>>(il);
954 }
956 template<typename _tValue, class _tAlloc, typename _type = _tValue>
957 YB_ATTR_nodiscard yconstfn std::shared_ptr<decay_t<_type>>
958 share_move(const _tAlloc& a, _tValue&& v)
959 {
960 return ystdex::allocate_shared<decay_t<_type>>(a, std::move(v));
961 }
963 template<typename _tValue, class _tAlloc, typename _type = _tValue>
964 YB_ATTR_nodiscard yconstfn std::shared_ptr<decay_t<_type>>
965 share_move(const _tAlloc& a, std::initializer_list<_tValue> il)
966 {
967 return ystdex::allocate_shared<decay_t<_type>>(a, il);
968 }
970
971
976 template<typename _tValue, typename _type = _tValue>
977 YB_ATTR_nodiscard yconstfn std::unique_ptr<decay_t<_type>>
978 unique_copy(const _tValue& v)
979 {
980 return ystdex::make_unique<decay_t<_type>>(v);
981 }
983
984 template<typename _tValue, typename _type = _tValue>
985 YB_ATTR_nodiscard yconstfn std::unique_ptr<decay_t<_type>>
986 unique_copy(std::initializer_list<_tValue> il)
987 {
988 return ystdex::make_unique<decay_t<_type>>(il);
989 }
990 template<typename _tValue, class _tAlloc, typename _type = _tValue>
991 YB_ATTR_nodiscard yconstfn std::unique_ptr<decay_t<_type>>
992 unique_copy(const _tAlloc& a, const _tValue& v)
993 {
994 return ystdex::allocate_unique<decay_t<_type>>(a, v);
995 }
996 template<typename _tValue, class _tAlloc, typename _type = _tValue>
997 YB_ATTR_nodiscard yconstfn std::unique_ptr<decay_t<_type>>
998 unique_copy(const _tAlloc& a, std::initializer_list<_tValue> il)
999 {
1000 return ystdex::allocate_unique<decay_t<_type>>(a, il);
1001 }
1003
1008 template<typename _tValue, typename _type = _tValue>
1009 YB_ATTR_nodiscard yconstfn std::unique_ptr<decay_t<_type>>
1010 unique_forward(_tValue&& v)
1011 {
1012 return ystdex::make_unique<decay_t<_type>>(yforward(v));
1013 }
1015
1016 template<typename _tValue, typename _type = _tValue>
1017 YB_ATTR_nodiscard yconstfn std::unique_ptr<decay_t<_type>>
1018 unique_forward(std::initializer_list<_tValue> il)
1019 {
1020 return ystdex::make_unique<decay_t<_type>>(il);
1021 }
1022 template<typename _tValue, class _tAlloc, typename _type = _tValue>
1023 YB_ATTR_nodiscard yconstfn std::unique_ptr<decay_t<_type>>
1024 unique_forward(const _tAlloc& a, _tValue&& v)
1025 {
1026 return ystdex::allocate_unique<decay_t<_type>>(a, yforward(v));
1027 }
1028 template<typename _tValue, class _tAlloc, typename _type = _tValue>
1029 YB_ATTR_nodiscard yconstfn std::unique_ptr<decay_t<_type>>
1030 unique_forward(const _tAlloc& a, std::initializer_list<_tValue> il)
1031 {
1032 return ystdex::allocate_unique<decay_t<_type>>(a, il);
1033 }
1035
1040 template<typename _tValue, typename _type = _tValue>
1041 YB_ATTR_nodiscard yconstfn std::unique_ptr<decay_t<_type>>
1042 unique_move(_tValue&& v)
1043 {
1044 return ystdex::make_unique<decay_t<_type>>(std::move(v));
1045 }
1047
1048 template<typename _tValue, typename _type = _tValue>
1049 YB_ATTR_nodiscard yconstfn std::unique_ptr<decay_t<_type>>
1050 unique_move(std::initializer_list<_tValue> il)
1051 {
1052 return ystdex::make_unique<decay_t<_type>>(il);
1053 }
1054 template<typename _tValue, class _tAlloc, typename _type = _tValue>
1055 YB_ATTR_nodiscard yconstfn std::unique_ptr<decay_t<_type>>
1056 unique_move(const _tAlloc& a, _tValue&& v)
1057 {
1058 return ystdex::allocate_unique<decay_t<_type>>(a, std::move(v));
1059 }
1060 template<typename _tValue, class _tAlloc, typename _type = _tValue>
1061 YB_ATTR_nodiscard yconstfn std::unique_ptr<decay_t<_type>>
1062 unique_move(const _tAlloc& a, std::initializer_list<_tValue> il)
1063 {
1064 return ystdex::allocate_unique<decay_t<_type>>(a, il);
1065 }
1067
1068
1069
1075 template<typename _tDst, typename _type>
1076 YB_ATTR_nodiscard YB_PURE inline std::unique_ptr<_tDst>
1077 static_pointer_cast(std::unique_ptr<_type> p) ynothrow
1078 {
1079 return std::unique_ptr<_tDst>(static_cast<_tDst*>(p.release()));
1080 }
1081 template<typename _tDst, typename _type, typename _tDeleter>
1082 YB_ATTR_nodiscard YB_PURE inline std::unique_ptr<_tDst, _tDeleter>
1083 static_pointer_cast(std::unique_ptr<_type, _tDeleter> p) ynothrow
1084 {
1085 return std::unique_ptr<_tDst, _tDeleter>(static_cast<_tDst*>(p.release()),
1086 std::move(p.get_deleter()));
1087 }
1088
1089 template<typename _tDst, typename _type>
1090 YB_ATTR_nodiscard YB_PURE std::unique_ptr<_tDst>
1091 dynamic_pointer_cast(std::unique_ptr<_type>& p) ynothrow
1092 {
1093 if(auto p_res = dynamic_cast<_tDst*>(p.get()))
1094 {
1095 p.release();
1096 return std::unique_ptr<_tDst>(p_res);
1097 }
1098 return std::unique_ptr<_tDst>();
1099 }
1100 template<typename _tDst, typename _type>
1101 YB_ATTR_nodiscard YB_PURE inline std::unique_ptr<_tDst>
1102 dynamic_pointer_cast(std::unique_ptr<_type>&& p) ynothrow
1103 {
1104 return ystdex::dynamic_pointer_cast<_tDst, _type>(p);
1105 }
1106 template<typename _tDst, typename _type, typename _tDeleter>
1107 YB_ATTR_nodiscard YB_PURE std::unique_ptr<_tDst, _tDeleter>
1108 dynamic_pointer_cast(std::unique_ptr<_type, _tDeleter>& p) ynothrow
1109 {
1110 if(auto p_res = dynamic_cast<_tDst*>(p.get()))
1111 {
1112 p.release();
1113 return std::unique_ptr<_tDst, _tDeleter>(p_res);
1114 }
1115 return std::unique_ptr<_tDst, _tDeleter>(nullptr);
1116 }
1117 template<typename _tDst, typename _type, typename _tDeleter>
1118 YB_ATTR_nodiscard YB_PURE inline std::unique_ptr<_tDst, _tDeleter>
1119 dynamic_pointer_cast(std::unique_ptr<_type, _tDeleter>&& p) ynothrow
1120 {
1121 return ystdex::dynamic_pointer_cast<_tDst, _type, _tDeleter>(p);
1122 }
1123
1124 template<typename _tDst, typename _type>
1125 YB_ATTR_nodiscard std::unique_ptr<_tDst>
1126 const_pointer_cast(std::unique_ptr<_type> p) ynothrow
1127 {
1128 return std::unique_ptr<_tDst>(const_cast<_tDst*>(p.release()));
1129 }
1130 template<typename _tDst, typename _type, typename _tDeleter>
1131 YB_ATTR_nodiscard std::unique_ptr<_tDst, _tDeleter>
1132 const_pointer_cast(std::unique_ptr<_type, _tDeleter> p) ynothrow
1133 {
1134 return std::unique_ptr<_tDst, _tDeleter>(const_cast<_tDst*>(p.release()),
1135 std::move(p.get_deleter()));
1136 }
1138
1139
1141
1142 template<typename _type>
1144 YB_ATTR_nodiscard inline _type*
1145 clone_monomorphic(const _type& v)
1146 {
1147 return new _type(v);
1148 }
1150 template<typename _type, class _tAlloc>
1151 YB_ATTR_nodiscard inline auto
1152 clone_monomorphic(const _type& v, _tAlloc&& a)
1153 -> decltype(ystdex::create_with_allocator<_type>(yforward(a), v))
1154 {
1155 return ystdex::create_with_allocator<_type>(yforward(a), v);
1156 }
1157
1159 template<typename _tPointer>
1160 YB_ATTR_nodiscard inline auto
1161 clone_monomorphic_ptr(const _tPointer& p)
1162 -> decltype(ystdex::clone_monomorphic(*p))
1163 {
1164 using ptr_t = decltype(ystdex::clone_monomorphic(*p));
1165
1166 return p ? ystdex::clone_monomorphic(*p) : ptr_t();
1167 }
1169 template<typename _tPointer, class _tAlloc>
1170 YB_ATTR_nodiscard inline auto
1171 clone_monomorphic_ptr(const _tPointer& p, _tAlloc&& a)
1172 -> decltype(ystdex::clone_monomorphic(*p, yforward(a)))
1173 {
1174 using ptr_t = decltype(ystdex::clone_monomorphic(*p, yforward(a)));
1175
1176 return p ? ystdex::clone_monomorphic(*p, yforward(a)) : ptr_t();
1177 }
1178
1183 template<class _type>
1184 YB_ATTR_nodiscard inline auto
1185 clone_polymorphic(const _type& v) -> decltype(v.clone())
1186 {
1187 static_assert(is_polymorphic<_type>(), "Non-polymorphic class type found.");
1188
1189 return v.clone();
1190 }
1191
1193 template<class _tPointer>
1194 YB_ATTR_nodiscard inline auto
1195 clone_polymorphic_ptr(const _tPointer& p) -> decltype(clone_polymorphic(*p))
1196 {
1197 return
1198 p ? ystdex::clone_polymorphic(*p) : decltype(clone_polymorphic(*p))();
1199 }
1201
1202
1204 namespace details
1205 {
1206
1207 template<typename _type>
1208 struct pack_obj_impl
1209 {
1210 template<typename... _tParams>
1211 YB_ATTR_nodiscard static _type
1212 pack(_tParams&&... args)
1213 {
1214 return _type(yforward(args)...);
1215 }
1216 };
1217
1218 template<typename _type, class _tDeleter>
1219 struct pack_obj_impl<std::unique_ptr<_type, _tDeleter>>
1220 {
1221 template<typename... _tParams>
1222 YB_ATTR_nodiscard static std::unique_ptr<_type>
1223 pack(_tParams&&... args)
1224 {
1225 return std::unique_ptr<_type>(yforward(args)...);
1226 }
1227 };
1228
1229 template<typename _type>
1230 struct pack_obj_impl<std::shared_ptr<_type>>
1231 {
1232 template<typename... _tParams>
1233 YB_ATTR_nodiscard static std::shared_ptr<_type>
1234 pack(_tParams&&... args)
1235 {
1236 return std::shared_ptr<_type>(yforward(args)...);
1237 }
1238 };
1239
1240 } // namespace details;
1241
1243
1244
1251 template<typename _type, typename... _tParams>
1252 YB_ATTR_nodiscard auto
1253 pack_object(_tParams&&... args)
1254 -> decltype(yimpl(details::pack_obj_impl<_type>::pack(yforward(args)...)))
1255 {
1256 return details::pack_obj_impl<_type>::pack(yforward(args)...);
1257 }
1258
1259
1261 template<typename _type, typename _tPack = std::unique_ptr<_type>>
1262 struct object_pack
1263 {
1264 public:
1265 using value_type = _type;
1266 using pack_type = _tPack;
1267
1268 private:
1269 pack_type pack;
1270
1271 public:
1273 template<typename... _tParams>
1274 object_pack(_tParams&&... args)
1275 : pack(pack_object<_tPack>(yforward(args)...))
1276 {}
1277
1278 YB_ATTR_nodiscard YB_PURE
1279 operator pack_type&() ynothrow
1280 {
1281 return pack;
1282 }
1283 YB_ATTR_nodiscard YB_PURE
1284 operator const pack_type&() const ynothrow
1285 {
1286 return pack;
1287 }
1288 };
1290
1291 } // namespace ystdex;
1292
1293 #endif
1294
ystdex::make_weak
std::weak_ptr< _type > make_weak(const std::shared_ptr< _type > &p)
使用指定的 std::shared_ptr 实例的对象创建对应的 std::weak_ptr 实例的对象。
Definition: memory.hpp:866
ystdex::make_unique_default_init
enable_if_t<!is_array< _type >::value, std::unique_ptr< _type > > make_unique_default_init()
Definition: memory.hpp:788
ystdex::make_unique_with
enable_if_t<!is_array< _type >::value, std::unique_ptr< _type, _tDeleter > > make_unique_with(_tDeleter &&d, _tParams &&... args)
Definition: memory.hpp:824
ystdex::details::pack_obj_impl::pack
static _type pack(_tParams &&... args)
Definition: memory.hpp:1212
YB_ATTR_nodiscard
#define YB_ATTR_nodiscard
标记返回值不被忽略的属性。
Definition: ydef.h:715
ystdex::unique_forward
std::unique_ptr< decay_t< _type > > unique_forward(_tValue &&v)
传递值创建对应的 std::unique_ptr 实例的对象。
Definition: memory.hpp:1010
ystdex::object_pack::value_type
_type value_type
Definition: memory.hpp:1265
ystdex::free_delete< _type[]>::operator()
void operator()(_type2 *p) const
Definition: memory.hpp:210
ystdex::cpp2014::remove_extent_t
typename remove_extent< _type >::type remove_extent_t
Definition: meta.hpp:172
ystdex::temporary_buffer::buf
std::pair< pointer, size_t > buf
Definition: memory.hpp:347
ystdex::temporary_buffer_delete
使用显式 ystdex::return_temporary_buffer 调用释放存储的删除器。
Definition: memory.hpp:315
YB_PURE
#define YB_PURE
指示函数或函数模板实例为纯函数。
Definition: ydef.h:919
ystdex::static_pointer_cast
std::unique_ptr< _tDst > static_pointer_cast(std::unique_ptr< _type > p)
智能指针转换。
Definition: memory.hpp:1077
ystdex::detected_or_t
_t< detected_or< _tDefault, _gOp, _tParams... > > detected_or_t
Definition: meta.hpp:407
ystdex::clone_polymorphic
auto clone_polymorphic(const _type &v) -> decltype(v.clone())
使用 clone 成员函数复制多态类类型对象。
Definition: memory.hpp:1185
yalignof
#define yalignof(_type)
指定特定类型的对齐。
Definition: ydef.h:1053
ystdex::pack_object
auto pack_object(_tParams &&... args) -> decltype(details::pack_obj_impl< _type >::pack(std::forward< decltype(args)>(args)...))
打包对象：通过指定参数构造对象。
Definition: memory.hpp:1253
ref.hpp
引用包装。
ystdex::share_raw
std::shared_ptr< _type > share_raw(_type *p, _tParams &&... args)
Definition: memory.hpp:692
ystdex::deleter_member_pointer_t
typename remove_reference_t< _tDeleter >::pointer deleter_member_pointer_t
取删除器的 pointer 成员类型。
Definition: memory.hpp:396
ystdex::unique_ptr_pointer
detected_or_t< _type *, deleter_member_pointer_t, _tDeleter > unique_ptr_pointer
取 unique_ptr 包装的指针类型。
Definition: memory.hpp:401
ystdex::cpp2014::enable_if_t
typename enable_if< _bCond, _type >::type enable_if_t
Definition: meta.hpp:199
ystdex::make_shared
std::shared_ptr< _type > make_shared(std::initializer_list< _tValue > il)
使用指定类型的初始化列表构造指定类型的 std::shared_ptr 对象。
Definition: memory.hpp:855
CHRLib::d
_tDst * d
Definition: CharacterProcessing.h:142
ystdex::share_move
std::shared_ptr< decay_t< _type > > share_move(_tValue &&v)
转移值创建对应的 std::shared_ptr 实例的对象。
Definition: memory.hpp:942
ystdex::nullptr_t
空指针类。
Definition: ydef.h:1321
ystdex::temporary_buffer::temporary_buffer
temporary_buffer(temporary_buffer &&)=default
ystdex::cpp2014::max
const _type & max(const _type &a, const _type &b, _fComp comp=less< _type >())
取较大的元素。
Definition: algorithm.hpp:635
ystdex::temporary_buffer::operator=
temporary_buffer & operator=(temporary_buffer &&)=default
ystdex::clone_polymorphic_ptr
auto clone_polymorphic_ptr(const _tPointer &p) -> decltype(clone_polymorphic(*p))
若指针非空，使用 clone 成员函数复制指针指向的多态类类型对象。
Definition: memory.hpp:1195
ystdex::details::over_aligned_t
false_ over_aligned_t
Definition: memory.hpp:236
ystdex::object_pack::pack
pack_type pack
Definition: memory.hpp:1269
ystdex::owns_unique_nonnull
bool owns_unique_nonnull(const _type &)
Definition: memory.hpp:573
ystdex::details::create_or_throw_impl
_type create_or_throw_impl(void *, _tParams &&...)
Definition: memory.hpp:63
ystdex::clone_monomorphic_ptr
auto clone_monomorphic_ptr(const _tPointer &p) -> decltype(ystdex::clone_monomorphic(*p))
若指针非空，使用 new 复制指针指向的对象。
Definition: memory.hpp:1161
allocator.hpp
分配器接口。
ystdex::get_raw
_type * get_raw(_type *const &p)
Definition: memory.hpp:449
ystdex::make_unique
std::unique_ptr< _type > make_unique(std::initializer_list< _tElem > il)
使用指定类型的初始化列表构造指定类型的 std::unique_ptr 对象。
Definition: memory.hpp:810
CHRLib::args
YB_ATTR_nodiscard _tParams && args
Definition: CharacterProcessing.h:649
ystdex::bool_
integral_constant< bool, _vInt > bool_
Definition: integral_constant.hpp:93
ystdex::temporary_buffer::get
const pointer & get() const
Definition: memory.hpp:368
ystdex::details::_type2
_type2
Definition: operators.hpp:241
ystdex::temporary_buffer::temporary_buffer
temporary_buffer(size_t n)
Definition: memory.hpp:351
ystdex::cond_or
cond_t< _tCond, vdefer< _gOp, _tParams... >, identity< _tDefault > > cond_or
条件判断，若失败使用默认类型。
Definition: type_op.hpp:261
ystdex::free_delete< _type[]>::free_delete
free_delete()=default
YB_ALLOCATOR
#define YB_ALLOCATOR
指示返回指针的函数或函数模板若为非空值则对应的存储不和其它对象指针共享别名。
Definition: ydef.h:785
ystdex::unique_raw
std::unique_ptr< _type > unique_raw(_pSrc *p)
Definition: memory.hpp:645
ystdex::temporary_buffer
临时缓冲区。
Definition: memory.hpp:339
YB_NORETURN
#define YB_NORETURN
指定无返回值函数。
Definition: ydef.h:877
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 转发对应参数。
Definition: ydef.h:1508
ystdex::cpp2017::size
auto size(const _tRange &c) -> decltype(c.size())
Definition: range.hpp:540
ystdex::details::pack_obj_impl< std::shared_ptr< _type > >::pack
static std::shared_ptr< _type > pack(_tParams &&... args)
Definition: memory.hpp:1234
ystdex::throw_invalid_construction
void throw_invalid_construction()
Definition: ystdex/exception.cpp:49
YB_STATELESS
#define YB_STATELESS
指示函数或函数模板实例为无状态函数。
Definition: ydef.h:941
ystdex::unique_move
std::unique_ptr< decay_t< _type > > unique_move(_tValue &&v)
转移值创建对应的 std::unique_ptr 实例的对象。
Definition: memory.hpp:1042
ystdex::create_or_throw
_type create_or_throw(_tParams &&... args)
调用构造函数创建对象或抛出异常。
Definition: memory.hpp:120
ystdex::indirect_element_t
remove_reference_t< indirect_t< _type > > indirect_element_t
Definition: type_traits.hpp:74
ystdex::unique_copy
std::unique_ptr< decay_t< _type > > unique_copy(const _tValue &v)
复制值创建对应的 std::unique_ptr 实例的对象。
Definition: memory.hpp:978
std
Definition: optional.h:982
ystdex::reset
bool reset(std::unique_ptr< _type, _tDeleter > &p)
Definition: memory.hpp:613
ystdex::dynamic_pointer_cast
std::unique_ptr< _tDst > dynamic_pointer_cast(std::unique_ptr< _type > &p)
Definition: memory.hpp:1091
ystdex::owns_nonnull
bool owns_nonnull(_type *const &)
Definition: memory.hpp:514
ystdex::temporary_buffer::pointer
std::unique_ptr< _type, deleter > pointer
Definition: memory.hpp:344
ystdex::temporary_buffer::size
size_t size() const
Definition: memory.hpp:380
ystdex::clone_monomorphic
_type * clone_monomorphic(const _type &v)
使用 new 复制对象。
Definition: memory.hpp:1145
ystdex::is_reference_wrapper
判断模板参数指定的类型是否为引用包装的实例。
Definition: ref.hpp:150
ystdex::share_copy
std::shared_ptr< decay_t< _type > > share_copy(const _tValue &v)
复制值创建对应的 std::shared_ptr 实例的对象。
Definition: memory.hpp:878
yconstraint
#define yconstraint(_expr)
约束：接口语义。
Definition: cassert.h:125
ystdex::details::delete_aligned
void delete_aligned(void *ptr, size_t, false_)
Definition: memory.hpp:253
ystdex::new_or_throw
_type * new_or_throw(_tParams &&... args)
调用 new 表达式创建对象或抛出异常。
Definition: memory.hpp:137
ystdex::object_pack
打包的对象：使用 pack_object 得到的对象包装。
Definition: memory.hpp:1263
ystdex::true_
bool_< true > true_
Definition: integral_constant.hpp:109
ystdex::temporary_buffer::get_pointer_ref
pointer & get_pointer_ref()
Definition: memory.hpp:374
ystdex::const_pointer_cast
std::unique_ptr< _tDst > const_pointer_cast(std::unique_ptr< _type > p)
Definition: memory.hpp:1126
ystdex::is_undereferenceable
bool is_undereferenceable(const _tIter &)
Definition: deref_op.hpp:46
ystdex::details::create_or_throw_with_allocator_impl
_type * create_or_throw_with_allocator_impl(void *, _tAlloc &, _tParams &&...)
Definition: memory.hpp:78
ystdex::enable_if_convertible_t
enable_if_t< is_convertible< _tFrom, _tTo >::value, _type > enable_if_convertible_t
Definition: meta.hpp:837
v
byte v
Definition: CharRenderer.cpp:76
ynothrowv
#define ynothrowv
YSLib 无异常抛出保证验证：有条件地使用无异常抛出规范。
Definition: ydef.h:1219
ystdex
<memory> 特性测试宏。
Definition: ydef.h:1262
ystdex::details::new_or_throw_impl
_type * new_or_throw_impl(void *, _tParams &&...)
Definition: memory.hpp:92
ystdex::details::new_aligned
void * new_aligned(size_t size, size_t, false_)
Definition: memory.hpp:240
YSLib::_tParams
YB_ATTR_nodiscard YB_PURE typename _tParams
Definition: ValueNode.h:1294
ystdex::object_pack::pack_type
_tPack pack_type
Definition: memory.hpp:1266
ystdex::temporary_buffer_delete< _type[]>::temporary_buffer_delete
temporary_buffer_delete()=default
ystdex::owns_unique
bool owns_unique(const _type &)
Definition: memory.hpp:546
alignment
size_t alignment
Definition: memory_resource.cpp:296
ystdex::share_forward
std::shared_ptr< decay_t< _type > > share_forward(_tValue &&v)
传递值创建对应的 std::shared_ptr 实例的对象。
Definition: memory.hpp:910
ystdex::object_pack::object_pack
object_pack(_tParams &&... args)
Definition: memory.hpp:1274
ystdex::free_delete::free_delete
free_delete()=default
ystdex::cpp2014::remove_reference_t
typename remove_reference< _type >::type remove_reference_t
Definition: meta.hpp:155
ystdex::free_delete::operator()
void operator()(_type *p) const
Definition: memory.hpp:187
ystdex::cpp2014::make_unique
enable_if_t<!is_array< _type >::value, std::unique_ptr< _type > > make_unique(_tParams &&... args)
Definition: memory.hpp:760
ystdex::temporary_buffer::element_type
_type element_type
Definition: memory.hpp:342
platform::p
return p p
Definition: YCLib/FileSystem.h:209
ystdex::owns_any
bool owns_any(_type *const &)
Definition: memory.hpp:482
ystdex::temporary_buffer::array_type
_type[] array_type
Definition: memory.hpp:341
ystdex::defer_element
cond_or< not_< is_void< remove_pointer_t< _tPointer > >>, _tDefault, indirect_element_t, _tPointer > defer_element
取指针对应的元素类型。
Definition: memory.hpp:410
const
const Decapsulate const Decapsulate &y ynothrow ContextNode &ctx const
Definition: NPLA1Forms.cpp:1629
yimpl
#define yimpl(...)
实现标签。
Definition: ydef.h:413
platform::bool
YB_ATTR_nodiscard std::FILE *fp bool
Definition: FileIO.h:1271
ystdex::false_
bool_< false > false_
Definition: integral_constant.hpp:110
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:1199
ystdex::create_or_throw_with_allocator
_type * create_or_throw_with_allocator(_tAlloc &&a, _tParams &&... args)
调用 ystdex::create_with_allocator 表达式创建对象或抛出异常。
Definition: memory.hpp:128
ystdex::is_sharing
判断指定类型是否为已知的持有共享所有权的对象类型。
Definition: memory.hpp:154
ystdex::details::pack_obj_impl< std::unique_ptr< _type, _tDeleter > >::pack
static std::unique_ptr< _type > pack(_tParams &&... args)
Definition: memory.hpp:1223
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:1073
YSLib::a
YB_PURE const _type * a
Definition: YCoreUtilities.h:168
ystdex::free_delete
使用显式析构函数调用和 std::free 的删除器。
Definition: memory.hpp:178
ystdex::details::pack_obj_impl
Definition: memory.hpp:1209