YSTest: placement.hpp 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

placement.hpp
浏览该文件的文档.
1 /*
2 © 2015-2016, 2018-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_placement_hpp_
31 #define YB_INC_ystdex_placement_hpp_ 1
32
33 #include "addressof.hpp" // for "addressof.hpp", cond_t, is_void, _t, vdefer,
34 // std::align, sizeof_t, size_t_, identity, empty_base, YB_ASSUME,
35 // ystdex::addressof, is_lvalue_reference, std::pair, std::allocator,
36 // std::allocator_traits, enable_if_convertible_t, std::unique_ptr,
37 // is_nothrow_destructible;
38 #include "cstdint.hpp" // for is_power_of_2_positive, yconstraint,
39 // YB_VerifyIterator, std::iterator_traits, vseq, ctor_of, when, _a;
40 #include <new> // for placement ::operator new from standard library;
41 // NOTE: The following code is necessary to check for <optional> header to
42 // ensure it have %in_place_t consistently. Other implementation is in
43 // "optional.h".
44 // NOTE: Check of %__cplusplus is needed because SD-6 issues are not resolved in
45 // mainstream implementations yet. See https://groups.google.com/a/isocpp.org/forum/#!topic/std-discussion/1rO2FiqWgtI
46 // and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79433 for details. For
47 // feature-test marcos, see https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations.
48 // See also https://docs.microsoft.com/en-us/cpp/visual-cpp-language-conformance.
49 #if (YB_IMPL_MSCPP >= 1910 && _MSVC_LANG >= 201603) \
50 || (__cplusplus >= 201603L && __has_include(<optional>))
51 # include <optional>
52 // NOTE: See also WG21 P0941R0 with minor fixes of the specification about WG21
53 // P0032R3. Since WG21 P0941R2, the macro value is combined as '201606L' with
54 // WG21 P0504R0 support which is not used here, so the check remains the value
55 // in WG21 P0941R1.
56 # if (YB_IMPL_MSCPP >= 1910 && _MSVC_LANG >= 201603) \
57 || __cpp_lib_optional >= 201603L
58 # define YB_Has_optional 1
59 # endif
60 // NOTE: As per the specification, single <optional> without may indicate WG21
61 // N3672 <optional>, which is WG21 N3793 <experimental/optional> without some
62 // minor bug fixes. This is not fully supported to suppress YStandardEx
63 // replacement (see "optional.hpp").
64 #elif __cplusplus > 201402L && __has_include(<experimental/optional>)
65 # include <experimental/optional>
66 # if __cpp_lib_experimental_optional >= 201411L
67 # define YB_Has_optional 2
68 # endif
69 #endif
70
78 #ifndef __cpp_lib_optional
79 # if (YB_IMPL_MSCPP >= 1910 && _MSVC_LANG >= 201606) || __cplusplus >= 201606L
80 # define __cpp_lib_optional 201606L
81 # endif
82 #endif
83
84
85 namespace ystdex
86 {
87
95 template<typename _type>
96 YB_ATTR_nodiscard YB_PURE inline bool
97 is_aligned_ptr(_type* p, size_t alignment
98 = yalignof(cond_t<is_void<_type>, std::max_align_t, _type>)) ynothrow
99 {
100 yconstraint(p);
101 yconstraint(is_power_of_2_positive(alignment));
102
103 // XXX: This can be bit and of 'reinterpret_cast<std::uintptr_t>(ptr)' and
104 // 'alignment - 1'. However, for portability, %std::align is used instead,
105 // even inefficient in general.
106 void* ptr(p);
107 size_t space(_t<cond_t<is_void<_type>, identity<size_t_<1>>,
108 vdefer<sizeof_t, _type>>>::value);
109
110 return bool(std::align(alignment, space, ptr, space));
111 }
112
113
126 // XXX: Although GCC supports non-constant alignment in its test suite, Clang++
127 // does not and it would complain with "error: argument to
128 // '__builtin_assume_aligned' must be a constant integer". WG21 P0886R0 also
129 // porposes the attribute having constant-expression (or a type-id).
130 #if YB_IMPL_GNUCPP >= 40700
131 # define yaligned(_p, _align) \
132 (yverify(ystdex::is_aligned_ptr(_p, _align)), \
133 __builtin_assume_aligned(_p, _align))
134 #elif false && (__has_builtin(__builtin_assume_aligned) \
135 || YB_IMPL_CLANGPP >= 35100)
136 # define yaligned(_p, _align) \
137 (yverify(ystdex::is_aligned_ptr(_p, _align)), __builtin_constant_p(_align) \
138 ? __builtin_assume_aligned(_p, _align) : _p)
139 #else
140 # define yaligned(_p, _align) \
141 (yassume(ystdex::is_aligned_ptr(_p, _align)), _p)
142 #endif
143
144
150 yconstexpr const struct default_init_t{} default_init{};
151
157 yconstexpr const struct value_init_t{} value_init{};
158
159
166 namespace uniformed_tags
167 {
168
178 struct in_place_tag
180 {
181 in_place_tag() = delete;
182 };
183
185 //{@
187 using in_place_t = in_place_tag(*)(yimpl(empty_base<>));
188
190 template<typename _type>
191 using in_place_type_t = in_place_tag(*)(yimpl(empty_base<_type>));
192
194 template<size_t _vIdx>
195 using in_place_index_t = in_place_tag(*)(yimpl(size_t_<_vIdx>));
197
204 yimpl(YB_NORETURN) inline in_place_tag
205 in_place(yimpl(empty_base<>))
206 {
207 YB_ASSUME(false);
208 }
209 template<typename _type>
210 yimpl(YB_NORETURN) in_place_tag
211 in_place(yimpl(empty_base<_type>))
212 {
213 YB_ASSUME(false);
214 }
215 template<size_t _vIdx>
216 yimpl(YB_NORETURN) in_place_tag
217 in_place(yimpl(size_t_<_vIdx>))
218 {
219 YB_ASSUME(false);
220 }
222
223 } // namespace uniformed_tags;
224
229 inline namespace cpp2017
230 {
231
232 #if YB_Has_optional == 1
233 using std::in_place_t;
234 using std::in_place;
235 using std::in_place_type_t;
236 using std::in_place_type;
237 using std::in_place_index_t;
238 using std::in_place_index;
239 #else
240 # if YB_Has_optional == 2
241 using std::experimental::in_place_t;
242 using std::experimental::in_place;
243 # else
244 using uniformed_tags::in_place_t;
245 // XXX: Using instead of %in_place_type and %in_place_index is not supported
246 // here, even it is supported by %uniformed_tags::in_place;
247 using uniformed_tags::in_place;
248 # endif
249
250 using uniformed_tags::in_place_type_t;
251 using uniformed_tags::in_place_index_t;
252
253 template<typename _type>
254 yimpl(YB_NORETURN) yimpl(uniformed_tags::in_place_tag)
255 in_place_type(yimpl(empty_base<_type>))
256 {
257 YB_ASSUME(false);
258 }
259
260 template<size_t _vIdx>
261 yimpl(YB_NORETURN) yimpl(uniformed_tags::in_place_tag)
262 in_place_index(yimpl(size_t_<_vIdx>))
263 {
264 YB_ASSUME(false);
265 }
266 #endif
267
268 } // inline namespace cpp2017;
269
271
272 template<typename _type>
274 struct in_place_index_ctor
275 {
276 using type = in_place_index_t<_type::value>;
277 };
278
279
280 namespace vseq
281 {
282
284
285 template<typename _type>
286 struct ctor_of<in_place_type_t<_type>, when<true>>
287 {
288 using type = _a<in_place_type_t>;
289 };
290
291 template<size_t _vIdx>
292 struct ctor_of<in_place_index_t<_vIdx>, when<true>>
293 {
294 using type = _a<in_place_index_ctor>;
295 };
297
298 } // namespace vseq;
300
301
308 template<typename _type, typename _tObj>
310 yconstfn _type*
311 construct_default_within(_tObj& obj)
312 {
313 return ::new(
314 static_cast<void*>(static_cast<_tObj*>(ystdex::addressof(obj)))) _type;
315 }
316
322 template<typename _type, typename _tObj, typename... _tParams>
323 YB_ATTR(always_inline) yconstfn _type*
324 construct_within(_tObj& obj, _tParams&&... args)
325 {
326 return ::new(static_cast<void*>(
327 static_cast<_tObj*>(ystdex::addressof(obj)))) _type(yforward(args)...);
328 }
330
337 template<typename _type>
338 yconstfn_relaxed void
339 construct_default_in(_type& obj)
340 {
341 ystdex::construct_default_within<_type>(obj);
342 }
343
350 template<typename _type, typename... _tParams>
351 yconstfn_relaxed void
352 construct_in(_type& obj, _tParams&&... args)
353 {
354 ystdex::construct_within<_type>(obj, yforward(args)...);
355 }
356
358
359
361
374 template<typename _tIter, typename... _tParams>
375 void
376 construct(_tIter i, _tParams&&... args)
377 {
378 using value_type = typename std::iterator_traits<_tIter>::value_type;
379
380 YB_VerifyIterator(i);
381 ystdex::construct_within<value_type>(*i, yforward(args)...);
382 }
383
389 template<typename _tIter>
390 void
391 construct_default(_tIter i)
392 {
393 using value_type = typename std::iterator_traits<_tIter>::value_type;
394
395 YB_VerifyIterator(i);
396 ystdex::construct_default_within<value_type>(*i);
397 }
398
403 template<typename _tIter, typename... _tParams>
404 void
405 construct_range(_tIter first, _tIter last, _tParams&&... args)
406 {
407 for(; first != last; ++first)
408 ystdex::construct(first, yforward(args)...);
409 }
411
412
414 inline namespace cpp2017
415 {
416
429 #if (YB_IMPL_MSCPP >= 1911 && _MSVC_LANG >= 201606) \
430 || (((YB_IMPL_GNUCPP >= 80000 && __GLIBCXX__ > 20160914) \
431 || _LIBCPP_VERSION > 4000) && __cplusplus >= 201606L) \
432 || __cpp_lib_raw_memory_algorithms >= 201606L
433
435 using std::destroy_at;
436 using std::destroy;
437 using std::destroy_n;
439 #else
440 template<typename _type>
441 yconstfn_relaxed void
442 destroy_at(_type* location)
443 {
444 yconstraint(location);
445 location->~_type();
446 }
447
449 template<typename _tFwd>
450 yconstfn_relaxed void
451 destroy(_tFwd first, _tFwd last)
452 {
453 for(; first != last; ++first)
454 ystdex::destroy_at(ystdex::addressof(*first));
455 }
456
457 template<typename _tFwd, typename _tSize>
458 yconstfn_relaxed _tFwd
459 destroy_n(_tFwd first, _tSize n)
460 {
461 // XXX: To reduce dependency on resolution of LWG 2598.
462 static_assert(is_lvalue_reference<decltype(*first)>(),
463 "Invalid iterator reference type found.");
464
465 // NOTE: There can be improved diagnostics as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80553,
466 // which is not required for conforming. Note WG21 P0411R0 is not adopted.
467 // XXX: Excessive order refinment by ','?
468 for(; n > 0; ++first, static_cast<void>(--n))
469 ystdex::destroy_at(ystdex::addressof(*first));
470 return first;
471 }
472 #endif
473
474
475
476 } // inline namespace cpp2017;
477
478
486 template<typename _type>
487 YB_ATTR(always_inline) yconstfn_relaxed void
488 destruct_in(_type& obj)
489 {
490 // XXX: See https://developercommunity.visualstudio.com/content/problem/431598/vc-fails-to-compile-the-noexcept-expression-inside.html.
491 #if YB_IMPL_MSCPP < 1921
492 // XXX: This should allow privete memberwise %operator delete.
493 ::delete static_cast<_type*>(nullptr);
494 #endif
495 obj.~_type();
496 }
497
504 template<typename _tIter>
505 void
506 destruct(_tIter i)
507 {
508 using value_type = typename std::iterator_traits<_tIter>::value_type;
509
510 YB_VerifyIterator(i);
511 ystdex::destruct_in<value_type>(*i);
512 }
513
519 template<typename _tIter>
520 yconstfn_relaxed void
521 destruct_range(_tIter first, _tIter last)
522 {
523 for(; first != last; ++first)
524 ystdex::destruct(first);
525 }
527
528
530 inline namespace cpp2017
531 {
532
533 #define YB_Impl_UninitGuard_Begin \
534 auto i = first; \
535 \
536 try \
537 {
538
539 // NOTE: The order of destruction is unspecified.
540 #define YB_Impl_UninitGuard_End \
541 } \
542 catch(...) \
543 { \
544 ystdex::destruct_range(first, i); \
545 throw; \
546 }
547
556 #if (YB_IMPL_MSCPP >= 1911 && _MSVC_LANG >= 201606) \
557 || (((YB_IMPL_GNUCPP >= 80000 && __GLIBCXX__ > 20160920) \
558 || _LIBCPP_VERSION > 4000) && __cplusplus >= 201606L) \
559 || __cpp_lib_raw_memory_algorithms >= 201606L
560
562 using std::uninitialized_default_construct;
563 using std::uninitialized_default_construct_n;
564 using std::uninitialized_value_construct;
565 using std::uninitialized_value_construct_n;
566 using std::uninitialized_move;
567 using std::uninitialized_move_n;
569
571
573
575 #else
576 template<typename _tFwd>
577 inline void
578 uninitialized_default_construct(_tFwd first, _tFwd last)
579 {
580 YB_Impl_UninitGuard_Begin
581 for(; first != last; ++first)
582 ystdex::construct_default(first);
583 YB_Impl_UninitGuard_End
584 }
585
586 template<typename _tFwd, typename _tSize>
587 _tFwd
588 uninitialized_default_construct_n(_tFwd first, _tSize n)
589 {
590 YB_Impl_UninitGuard_Begin
591 // XXX: Excessive order refinment by ','?
592 for(; n > 0; ++first, static_cast<void>(--n))
593 ystdex::construct_default(first);
594 YB_Impl_UninitGuard_End
595 }
597
599 template<typename _tFwd>
600 inline void
601 uninitialized_value_construct(_tFwd first, _tFwd last)
602 {
603 YB_Impl_UninitGuard_Begin
604 ystdex::construct_range(first, last);
605 YB_Impl_UninitGuard_End
606 }
607
608 template<typename _tFwd, typename _tSize>
609 _tFwd
610 uninitialized_value_construct_n(_tFwd first, _tSize n)
611 {
612 YB_Impl_UninitGuard_Begin
613 // XXX: Excessive order refinment by ','?
614 for(; n > 0; ++first, static_cast<void>(--n))
615 ystdex::construct(first);
616 YB_Impl_UninitGuard_End
617 return first;
618 }
620
621
628 template<typename _tIn, class _tFwd>
629 _tFwd
630 uninitialized_move(_tIn first, _tIn last, _tFwd result)
631 {
632 YB_Impl_UninitGuard_Begin
633 for(; first != last; ++result, static_cast<void>(++first))
634 ystdex::construct(result, std::move(*first));
635 YB_Impl_UninitGuard_End
636 return result;
637 }
638
639 template<typename _tIn, typename _tSize, class _tFwd>
640 std::pair<_tIn, _tFwd>
641 uninitialized_move_n(_tIn first, _tSize n, _tFwd result)
642 {
643 YB_Impl_UninitGuard_Begin
644 // XXX: Excessive order refinment by ','?
645 for(; n > 0; ++result, ++first, static_cast<void>(--n))
646 ystdex::construct(result, std::move(*first));
647 YB_Impl_UninitGuard_End
648 return {first, result};
649 }
651 #endif
652
653
654 } // inline namespace cpp2017;
655
656
672 template<typename _tFwd, typename... _tParams>
673 void
674 uninitialized_construct(_tFwd first, _tFwd last, _tParams&&... args)
675 {
676 YB_Impl_UninitGuard_Begin
677 for(; i != last; ++i)
678 ystdex::construct(i, yforward(args)...);
679 YB_Impl_UninitGuard_End
680 }
681
688 template<typename _tFwd, typename _tSize, typename... _tParams>
689 void
690 uninitialized_construct_n(_tFwd first, _tSize n, _tParams&&... args)
691 {
692 YB_Impl_UninitGuard_Begin
693 // NOTE: This form is by specification (WG21 N4431) of
694 // 'std::unitialized_fill' literally.
695 for(; n--; ++i)
696 ystdex::construct(i, yforward(args)...);
697 YB_Impl_UninitGuard_End
698 }
700
701
702 #undef YB_Impl_UninitGuard_End
703 #undef YB_Impl_UninitGuard_Begin
704
705
707
708 template<typename _type, class _tAlloc = std::allocator<_type>>
710 class default_init_allocator : public _tAlloc
711 {
712 public:
713 using allocator_type = _tAlloc;
714 using traits_type = std::allocator_traits<allocator_type>;
715 template<typename _tOther>
716 struct rebind
717 {
718 using other = default_init_allocator<_tOther,
719 typename traits_type::template rebind_alloc<_tOther>>;
720 };
721
727 using allocator_type::allocator_type;
728
730 template<typename _tOther>
731 void
732 construct(_tOther* p) ynoexcept(_tOther())
733 {
734 ::new(static_cast<void*>(p)) _tOther;
735 }
736 template<typename _tOther, typename... _tParams>
737 void
738 construct(_type* p, _tParams&&... args)
739 {
740 traits_type::construct(static_cast< allocator_type&>(*this), p,
741 yforward(args)...);
742 }
743 };
744
745
751 template<typename _type, typename _tPointer = _type*>
752 struct placement_delete
753 {
754 using pointer = _tPointer;
755
756 yconstfn placement_delete() ynothrow = default;
757 template<typename _type2,
758 yimpl(typename = enable_if_convertible_t<_type2*, _type*>)>
759 placement_delete(const placement_delete<_type2>&) ynothrow
760 {}
761
762 void
763 operator()(pointer p) const ynothrowv
764 {
765 ystdex::destroy_at(p);
766 }
767 };
768
769
771 template<typename _type, typename _tPointer = _type*>
772 using placement_ptr
773 = std::unique_ptr<_type, placement_delete<_type, _tPointer>>;
775
776
782 template<typename _tToken, typename _type>
783 struct tagged_value
784 {
785 using token_type = _tToken;
786 using value_type = _type;
787
788 token_type token;
789 union
790 {
791 empty_base<> empty;
792 mutable _type value;
793 };
794
796 yconstfn
797 #if !YB_IMPL_GNUCPP || YB_IMPL_GNUCPP < 70000 || YB_IMPL_GNUCPP > 70300
798 tagged_value() ynoexcept_spec(token_type())
799 // XXX: Blocked. See $2019-08 @ %Documentation::Workflow.
800 #else
801 tagged_value() ynoexcept(is_nothrow_default_constructible<token_type>())
802 #endif
803 : token(), empty()
804 {}
805 explicit
806 tagged_value(default_init_t)
807 {}
808 tagged_value(token_type t)
809 : token(t), empty()
810 {}
811 template<typename... _tParams>
812 explicit yconstfn
813 tagged_value(token_type t, in_place_t, _tParams&&... args)
814 : token(t), value(yforward(args)...)
815 {}
816 tagged_value(const tagged_value& v)
817 : token(v.token)
818 {}
823 ~tagged_value()
824 {}
825
826 template<typename... _tParams>
827 yconstfn_relaxed void
828 construct(_tParams&&... args)
829 {
830 ystdex::construct_in(value, yforward(args)...);
831 }
832
833 yconstfn_relaxed void
834 destroy() ynoexcept(is_nothrow_destructible<value_type>())
835 {
836 ystdex::destruct_in(value);
837 }
838
839 yconstfn_relaxed void
840 destroy_nothrow() ynothrow
841 {
842 ynoexcept_assert("Invalid type found.", value.~value_type());
843
844 destroy();
845 }
846 };
847
848 } // namespace ystdex;
849
850 #endif
851
ystdex::cpp2017::uninitialized_move_n
std::pair< _tIn, _tFwd > uninitialized_move_n(_tIn first, _tSize n, _tFwd result)
Definition: placement.hpp:641
ystdex::tagged_value::token
token_type token
Definition: placement.hpp:788
ystdex::tagged_value::tagged_value
tagged_value(const tagged_value &v)
Definition: placement.hpp:816
YB_ATTR_nodiscard
#define YB_ATTR_nodiscard
标记返回值不被忽略的属性。
Definition: ydef.h:715
ystdex::placement_delete::operator()
void operator()(pointer p) const
Definition: placement.hpp:763
ystdex::empty_base
空基类模板。
Definition: ydef.h:1424
ystdex::vseq::_a
构造具有 apply 成员的一阶元函数。
Definition: variadic.hpp:247
ystdex::construct_default
void construct_default(_tIter i)
使用指定参数在迭代器指定的位置以默认初始化构造对象。
Definition: placement.hpp:391
ystdex::cpp2017::uninitialized_default_construct
void uninitialized_default_construct(_tFwd first, _tFwd last)
Definition: placement.hpp:578
ystdex::tagged_value::value
_type value
Definition: placement.hpp:792
ystdex::tagged_value::~tagged_value
~tagged_value()
析构：空实现。
Definition: placement.hpp:823
YB_ASSUME
#define YB_ASSUME(_expr)
假定表达式的求值总是为真。
Definition: ydef.h:811
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:1072
ystdex::destruct_in
void destruct_in(_type &obj)
原地析构。
Definition: placement.hpp:488
YB_PURE
#define YB_PURE
指示函数或函数模板实例为纯函数。
Definition: ydef.h:919
ystdex::construct_within
_type * construct_within(_tObj &obj, _tParams &&... args)
以值初始化在对象中构造。
Definition: placement.hpp:324
ystdex::placement_delete::placement_delete
placement_delete()=default
ynoexcept_assert
#define ynoexcept_assert(_msg,...)
表达式 noexcept 静态断言。
Definition: ydef.h:1152
yalignof
#define yalignof(_type)
指定特定类型的对齐。
Definition: ydef.h:1053
ystdex::default_init_allocator::rebind
Definition: placement.hpp:717
ystdex::function_base
函数包装类模板。
Definition: function.hpp:578
ystdex::tagged_value< function< void(bool, _type &)>, _type >::value_type
_type value_type
Definition: placement.hpp:786
ystdex::placement_delete::pointer
_tPointer pointer
Definition: placement.hpp:754
ystdex::default_init_allocator::construct
void construct(_type *p, _tParams &&... args)
Definition: placement.hpp:738
ystdex::destruct_range
void destruct_range(_tIter first, _tIter last)
析构d迭代器范围内的对象序列。
Definition: placement.hpp:521
ystdex::destruct
void destruct(_tIter i)
析构迭代器指向的对象。
Definition: placement.hpp:506
ystdex::placement_ptr
std::unique_ptr< _type, placement_delete< _type, _tPointer > > placement_ptr
独占放置存储的对象所有权的指针。
Definition: placement.hpp:773
ynoexcept_spec
#define ynoexcept_spec(...)
表达式 noexcept 异常规范。
Definition: ydef.h:1181
ystdex::in_place_index_ctor
Definition: placement.hpp:275
ystdex::default_init_allocator::allocator_type
_tAlloc allocator_type
Definition: placement.hpp:713
ystdex::cpp2017::uninitialized_value_construct
void uninitialized_value_construct(_tFwd first, _tFwd last)
Definition: placement.hpp:601
ystdex::tagged_value::destroy_nothrow
void destroy_nothrow()
Definition: placement.hpp:840
yconstfn_relaxed
#define yconstfn_relaxed
指定编译时没有 C++11 限制和隐式成员 const 的常量函数。
Definition: ydef.h:1097
ystdex::default_init_allocator::traits_type
std::allocator_traits< allocator_type > traits_type
Definition: placement.hpp:714
ystdex::in_place_index_ctor::type
in_place_index_t< _type::value > type
Definition: placement.hpp:276
ystdex::default_init_t
默认初始化标记。
Definition: placement.hpp:150
ystdex::uniformed_tags::in_place_t
in_place_tag(*)(empty_base<>) in_place_t
原地空标记类型。
Definition: placement.hpp:187
ystdex::default_init
const struct ystdex::default_init_t default_init
ystdex::uniformed_tags::in_place
in_place_tag in_place(empty_base<>)
原地标记函数。
Definition: placement.hpp:205
CHRLib::args
YB_ATTR_nodiscard _tParams && args
Definition: CharacterProcessing.h:649
ystdex::vseq::ctor_of
取类型构造器：具有 apply 成员，结果的嵌套 type 类型为构造类型的元函数。
Definition: variadic.hpp:284
ystdex::details::_type2
_type2
Definition: operators.hpp:241
ystdex::vseq::vdefer
可变参数类型列表延迟求值。
Definition: variadic.hpp:198
ystdex::construct_default_in
void construct_default_in(_type &obj)
以默认初始化原地构造。
Definition: placement.hpp:339
ystdex::uninitialized_construct
void uninitialized_construct(_tFwd first, _tFwd last, _tParams &&... args)
在迭代器指定的未初始化的范围上构造对象。
Definition: placement.hpp:674
ystdex::tagged_value::tagged_value
tagged_value()
Definition: placement.hpp:798
ystdex::uniformed_tags::in_place_tag
原地标记类型。
Definition: placement.hpp:180
YB_NORETURN
#define YB_NORETURN
指定无返回值函数。
Definition: ydef.h:877
ystdex::identity
恒等元函数。
Definition: meta.hpp:815
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 转发对应参数。
Definition: ydef.h:1508
ystdex::tagged_value
带记号标记的可选值。
Definition: placement.hpp:784
ystdex::tagged_value::empty
empty_base empty
Definition: placement.hpp:791
ystdex::construct_range
void construct_range(_tIter first, _tIter last, _tParams &&... args)
使用指定的参数重复构造迭代器范围内的对象序列。
Definition: placement.hpp:405
YB_VerifyIterator
#define YB_VerifyIterator(_expr)
验证表达式求值的迭代器的有效性。
Definition: deref_op.hpp:67
YB_Impl_UninitGuard_Begin
#define YB_Impl_UninitGuard_Begin
Definition: placement.hpp:533
ystdex::size_t_
integral_constant< size_t, _vInt > size_t_
Definition: integral_constant.hpp:103
YB_ATTR
#define YB_ATTR(...)
GNU 风格属性。
Definition: ydef.h:567
ystdex::default_init_allocator
默认初始化构造分配器。
Definition: placement.hpp:711
YSLib::i
return i
Definition: YCoreUtilities.h:177
ystdex::when
类似 void_t 的元函数，具有较低匹配优先级，避免偏特化歧义；但使用条件表达式。
Definition: meta.hpp:305
ystdex::is_aligned_ptr
bool is_aligned_ptr(_type *p, size_t alignment=std::alignment_of< cond_t< is_void< _type > >::value std::max_align_t, _type >))
返回参数指定的指针值对齐到指定的对齐值。
Definition: placement.hpp:97
ystdex::uniformed_tags::in_place
in_place_tag in_place(size_t_< _vIdx >)
Definition: placement.hpp:217
ystdex::value_init
const struct ystdex::value_init_t value_init
ystdex::tagged_value::tagged_value
tagged_value(default_init_t)
Definition: placement.hpp:806
yconstraint
#define yconstraint(_expr)
约束：接口语义。
Definition: cassert.h:125
ystdex::uniformed_tags::in_place_index_t
in_place_tag(*)(size_t_< _vIdx >) in_place_index_t
原地索引标记模板。
Definition: placement.hpp:195
ystdex::cpp2017::destroy_n
_tFwd destroy_n(_tFwd first, _tSize n)
Definition: placement.hpp:459
ystdex::tagged_value::destroy
void destroy()
Definition: placement.hpp:834
ystdex::cond_t
_t< cond< _tCond, _tThen, _tElse > > cond_t
Definition: meta.hpp:794
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::uniformed_tags::in_place_type_t
in_place_tag(*)(empty_base< _type >) in_place_type_t
原地类型标记模板。
Definition: placement.hpp:191
YSLib::_tParams
YB_ATTR_nodiscard YB_PURE typename _tParams
Definition: ValueNode.h:1294
ystdex::cpp2017::in_place_index
uniformed_tags::in_place_tag in_place_index(size_t_< _vIdx >)
Definition: placement.hpp:262
alignment
size_t alignment
Definition: memory_resource.cpp:296
ystdex::cpp2017::in_place_type
uniformed_tags::in_place_tag in_place_type(empty_base< _type >)
Definition: placement.hpp:255
ystdex::construct
void construct(_tIter i, _tParams &&... args)
使用指定参数在迭代器指定的位置以指定参数初始化构造对象。
Definition: placement.hpp:376
ystdex::tagged_value::tagged_value
tagged_value(token_type t, in_place_t, _tParams &&... args)
Definition: placement.hpp:813
ystdex::addressof
enable_if_t< has_no_overloaded_addressof< _type >::value, _type * > addressof(_type &r)
尝试对非重载 operator& 提供 constexpr 的 std::addressof 替代。
Definition: addressof.hpp:131
ystdex::_t
typename _type::type _t
嵌套类型别名。
Definition: meta.hpp:45
ystdex::uninitialized_construct_n
void uninitialized_construct_n(_tFwd first, _tSize n, _tParams &&... args)
Definition: placement.hpp:690
ystdex::construct_in
void construct_in(_type &obj, _tParams &&... args)
以值初始化原地构造。
Definition: placement.hpp:352
ystdex::value_init_t
值初始化标记。
Definition: placement.hpp:157
YB_Impl_UninitGuard_End
#define YB_Impl_UninitGuard_End
Definition: placement.hpp:540
platform::p
return p p
Definition: YCLib/FileSystem.h:209
const
const Decapsulate const Decapsulate &y ynothrow ContextNode &ctx const
Definition: NPLA1Forms.cpp:1629
addressof.hpp
一元操作符 & 和取指针的相关接口。
yimpl
#define yimpl(...)
实现标签。
Definition: ydef.h:413
platform::bool
YB_ATTR_nodiscard std::FILE *fp bool
Definition: FileIO.h:1271
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:1199
ystdex::is_power_of_2_positive
bool is_power_of_2_positive(std::uintmax_t n)
判断无符号整数是否为 2 的整数次幂的正整数。
Definition: cstdint.hpp:280
ystdex::cpp2017::destroy_at
void destroy_at(_type *location)
原地销毁。
Definition: placement.hpp:442
ystdex::cpp2017::uninitialized_move
_tFwd uninitialized_move(_tIn first, _tIn last, _tFwd result)
转移初始化范围。
Definition: placement.hpp:630
ystdex::cpp2017::uninitialized_default_construct_n
_tFwd uninitialized_default_construct_n(_tFwd first, _tSize n)
Definition: placement.hpp:588
ystdex::cpp2017::uninitialized_value_construct_n
_tFwd uninitialized_value_construct_n(_tFwd first, _tSize n)
Definition: placement.hpp:610
ynoexcept
#define ynoexcept(...)
YSLib 无异常抛出保证：指定特定的异常规范。
Definition: ydef.h:1151
ystdex::tagged_value::tagged_value
tagged_value(token_type t)
Definition: placement.hpp:808
ystdex::cpp2017::destroy
void destroy(_tFwd first, _tFwd last)
Definition: placement.hpp:451
ystdex::placement_delete
放置存储的对象删除器：释放时调用伪析构函数。
Definition: placement.hpp:753
ystdex::construct_default_within
_type * construct_default_within(_tObj &obj)
以默认初始化在对象中构造。
Definition: placement.hpp:311
ystdex::tagged_value::construct
void construct(_tParams &&... args)
Definition: placement.hpp:828
ystdex::uniformed_tags::in_place_tag::in_place_tag
in_place_tag()=delete
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:1073
cstdint.hpp
ISO C 标准整数类型和相关扩展操作。
ystdex::default_init_allocator::construct
void construct(_tOther *p)
Definition: placement.hpp:732