YSTest: YObject.h 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

YObject.h
浏览该文件的文档.
1 /*
2 © 2009-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
28 #ifndef YSL_INC_Core_YObject_h_
29 #define YSL_INC_Core_YObject_h_ 1
30
31 #include "YModules.h"
32 #include YFM_YSLib_Core_YCoreUtilities // for std::is_base_of,
33 // ystdex::exclude_tagged_params_t, ystdex::enable_if_t,
34 // ystdex::throw_invalid_construction, std::allocator_arg_t,
35 // std::allocator_arg, ystdex::false_, ystdex::true_,
36 // ystdex::boxed_value, ystdex::exclude_self_t, std::is_constructible,
37 // ystdex::default_init, ystdex::type_id, ystdex::is_allocatable,
38 // ystdex::is_byte_allocator, ystdex::exclude_self_params_t, ystdex::as_const,
39 // YSLib::forward_as_tuple, ystdex::has_get_allocator, ystdex::is_sharing,
40 // ystdex::ref, ystdex::cond_t, ystdex::decay_t, ystdex::rebind_alloc_t,
41 // in_place_type_t, YSLib::make_observer, ystdex::copy_or_move,
42 // ystdex::pseudo_output;
43 #include <ystdex/any.h> // for ystdex::any, ystdex::any_ops,
44 // ystdex::in_place_type, ystdex::in_place_type_t, ystdex::any_cast,
45 // ystdex::unchecked_any_cast, ystdex::unsafe_any_cast;
46 #include <ystdex/typeindex.h> // for ystdex::type_info, ystdex::type_index;
47 #include <ystdex/examiner.hpp> // for ystdex::examiners::equal_examiner;
48 #include <ystdex/operators.hpp> // for ystdex::equality_comparable;
49
50 namespace YSLib
51 {
52
54 using ystdex::any;
55
61 namespace any_ops = ystdex::any_ops;
62
63 using ystdex::bad_any_cast;
64 using ystdex::in_place_type;
65 using ystdex::in_place_type_t;
66
68
69 using ystdex::any_cast;
70 using ystdex::unchecked_any_cast;
71 using ystdex::unsafe_any_cast;
73
74
75
77 using ystdex::type_info;
79 using ystdex::type_index;
80
81
83
84
89 template<typename = void>
90 struct OwnershipTag
91 {};
92
93
98 struct MoveTag
99 {};
100
101
106 struct PointerTag
107 {};
109
110
116 template<class _tOwner, typename _type>
117 struct HasOwnershipOf : std::is_base_of<OwnershipTag<_type>, _tOwner>
118 {};
119
120
126 DeclDerivedI(YF_API, IValueHolder, any_ops::holder)
132 enum Creation
133 {
140 Indirect,
149 Copy,
157 Move
158 };
159
174 YB_ATTR_nodiscard DeclIEntry(any Create(Creation, const any&) const)
184 YB_ATTR_nodiscard YB_PURE DeclIEntry(bool Equals(const void*) const)
189 YB_ATTR_nodiscard YB_PURE DeclIEntry(size_t OwnsCount() const ynothrow)
196 YB_ATTR_nodiscard YB_PURE DeclIEntry(any Query(uintmax_t) const)
197
198
203 template<typename _type>
204 YB_ATTR_nodiscard static any
205 CreateHolder(Creation, _type&);
206 EndDecl
207
208
210
211
216 template<typename _type1, typename _type2>
217 struct HeldEqual : private ystdex::examiners::equal_examiner
218 {
219 using ystdex::examiners::equal_examiner::are_equal;
220 };
221
222 template<typename _type1, typename _type2>
223 struct HeldEqual<weak_ptr<_type1>, weak_ptr<_type2>>
224 {
225 YB_ATTR_nodiscard YB_PURE static bool
226 are_equal(const weak_ptr<_type1>& x, const weak_ptr<_type2>& y)
227 {
228 return x == y;
229 }
230 };
231
232 template<typename _type1, typename _type2, typename _type3, typename _type4>
233 struct HeldEqual<pair<_type1, _type2>, pair<_type3, _type4>>
234 {
235 YB_ATTR_nodiscard YB_PURE static yconstfn bool
236 are_equal(const pair<_type1, _type2>& x, const pair<_type3, _type4>& y)
237 {
238 return x.first == y.first && x.second == y.second;
239 }
240 };
242
243
250 template<typename _type1, typename _type2>
251 YB_ATTR_nodiscard YB_PURE yconstfn bool
252 AreEqualHeld(const _type1& x, const _type2& y)
253 {
254 return HeldEqual<_type1, _type2>::are_equal(x, y);
255 }
257
258
263 template<class _tHolder>
264 struct HolderOperations
265 {
266 static_assert(any_ops::check_holder_t<_tHolder>(),
267 "Invalid holder type found.");
268
270 using Creation = IValueHolder::Creation;
271
272 template<typename... _tParams,
273 yimpl(typename = ystdex::exclude_tagged_params_t<_tParams...>)>
274 YB_ATTR_nodiscard static any
275 CreateInPlace(_tParams&&... args)
276 {
277 return CreateInPlaceImpl(nullptr, yforward(args)...);
278 }
279 template<class _tAlloc, typename... _tParams>
280 YB_ATTR_nodiscard static any
281 CreateInPlace(std::allocator_arg_t, const _tAlloc& a,
282 _tParams&&... args)
283 {
284 return CreateInPlaceWithAllocatorImpl(nullptr, a, yforward(args)...);
285 }
286
287 private:
288 template<typename... _tParams>
289 YB_ATTR_nodiscard static auto
290 CreateInPlaceImpl(nullptr_t, _tParams&&... args)
291 -> decltype(any(any_ops::use_holder, in_place_type<_tHolder>,
292 yforward(args)...))
293 {
294 return any(any_ops::use_holder, in_place_type<_tHolder>,
295 yforward(args)...);
296 }
298 template<typename... _tParams>
299 YB_ATTR_nodiscard YB_NORETURN static any
300 CreateInPlaceImpl(void*, _tParams&&...)
301 {
302 ystdex::throw_invalid_construction();
303 }
304
305 template<class _tAlloc, typename... _tParams>
306 YB_ATTR_nodiscard static auto
307 CreateInPlaceWithAllocatorImpl(nullptr_t, const _tAlloc& a,
308 _tParams&&... args)
309 -> decltype(any(std::allocator_arg, a, any_ops::use_holder,
310 in_place_type<_tHolder>, yforward(args)...))
311 {
312 return any(std::allocator_arg, a, any_ops::use_holder,
313 in_place_type<_tHolder>, yforward(args)...);
314 }
316 template<typename... _tParams>
317 YB_ATTR_nodiscard YB_NORETURN static any
318 CreateInPlaceWithAllocatorImpl(void*, _tParams&&...)
319 {
320 ystdex::throw_invalid_construction();
321 }
322
323 public:
325
326
328 template<typename... _tParams>
329 YB_ATTR_nodiscard YB_NORETURN static any
330 CreateInPlaceConditionally(ystdex::false_, _tParams&&...)
331 {
332 ystdex::throw_invalid_construction();
333 }
335 template<class _tAlloc, typename... _tParams>
336 YB_ATTR_nodiscard YB_NORETURN static any
337 CreateInPlaceConditionally(std::allocator_arg_t, const _tAlloc&,
338 ystdex::false_, _tParams&&...)
339 {
340 ystdex::throw_invalid_construction();
341 }
343 template<typename... _tParams>
344 YB_ATTR_nodiscard static any
345 CreateInPlaceConditionally(ystdex::true_, _tParams&&... args)
346 {
347 return any(any_ops::use_holder, in_place_type<_tHolder>,
348 yforward(args)...);
349 }
350 template<class _tAlloc, typename... _tParams>
351 YB_ATTR_nodiscard static any
352 CreateInPlaceConditionally(std::allocator_arg_t, const _tAlloc& a,
353 ystdex::true_, _tParams&&... args)
354 {
355 return any(std::allocator_arg, a, any_ops::use_holder,
356 in_place_type<_tHolder>, yforward(args)...);
357 }
359
360 private:
362 struct CreateInPlaceFunctor final
363 {
364 template<typename... _tParams>
365 auto
366 operator()(_tParams&&... args)
367 -> decltype(CreateInPlace(yforward(args)...))
368 {
369 return CreateInPlace(yforward(args)...);
370 }
371 };
372
373 public:
375 template<typename _tValue, class _tCopyParams, class _tMoveParams>
376 YB_ATTR_nodiscard YB_PURE static any
377 CreateHolder(Creation c, _tValue& val, _tCopyParams&& args_copy,
378 _tMoveParams&& args_move)
379 {
380 if(c == Creation::Copy)
381 return ystdex::apply(CreateInPlaceFunctor{}, yforward(args_copy));
382 if(c == Creation::Move)
383 return ystdex::apply(CreateInPlaceFunctor{}, yforward(args_move));
384 // NOTE: It is more efficient to construct in place for %Indirect case.
385 return IValueHolder::CreateHolder(c, val);
386 }
387 };
388
389
394 template<class _tHolder, class _tByteAlloc>
395 struct AllocatedHolderOperations
396 {
397 static_assert(ystdex::is_byte_allocator<_tByteAlloc>(),
398 "Invalid byte allocator found.");
399
400 private:
402 struct CreateInPlaceFunctor final
403 {
404 const _tByteAlloc& Allocator;
405
406 template<typename... _tParams>
407 auto
408 operator()(_tParams&&... args)
409 -> decltype(HolderOperations<_tHolder>::CreateInPlace(
410 std::allocator_arg, Allocator, yforward(args)...))
411 {
412 return HolderOperations<_tHolder>::CreateInPlace(std::allocator_arg,
413 Allocator, yforward(args)...);
414 }
415 };
416
417 public:
418 using Creation = IValueHolder::Creation;
419
420 template<typename _tValue, typename... _tParams>
421 YB_ATTR_nodiscard static inline any
422 Create(Creation c, const any& x, _tValue& val, _tParams&&... args)
423 {
424 return CreateDispatched(c, x, any_ops::is_in_place_storable<_tValue>(),
425 val, yforward(args)...);
426 }
427
428 template<typename _tValue, typename... _tParams>
429 YB_ATTR_nodiscard YB_PURE static inline any
430 CreateDispatched(Creation c, const any& x, ystdex::false_, _tValue& val,
431 _tParams&&... args)
432 {
433 return CreateHolder(c, x, val, yforward(args)...);
434 }
435 template<typename _tValue, typename... _tParams>
436 YB_ATTR_nodiscard YB_PURE static inline any
437 CreateDispatched(Creation c, const any&, ystdex::true_, _tValue& val,
438 _tParams&&...)
439 {
440 return IValueHolder::CreateHolder(c, val);
441 }
442
448 template<typename _tValue, class _tCopyParams, class _tMoveParams>
449 YB_ATTR_nodiscard YB_PURE static any
450 CreateHolder(Creation c, const any& x, _tValue& val,
451 _tCopyParams&& args_copy, _tMoveParams&& args_move)
452 {
453 if(c == Creation::Copy || c == Creation::Move)
454 {
455 const auto& ra(GetByteAllocatorOf(x));
456
457 if(c == Creation::Copy)
458 return ystdex::apply(CreateInPlaceFunctor{ra},
459 yforward(args_copy));
460 return ystdex::apply(CreateInPlaceFunctor{ra}, yforward(args_move));
461 }
462 // NOTE: It is more efficient to construct in place for %Indirect case.
463 return IValueHolder::CreateHolder(c, val);
464 }
465
466 private:
468 YB_ATTR_nodiscard YB_PURE static const _tByteAlloc&
469 GetByteAllocatorOf(const any& x) ynothrowv
470 {
471 using ystdex::default_init;
472
473 YAssert(x.has_value(), "Invalid state found.");
474 YAssert(*x.unchecked_access<const type_info*>(
475 default_init, any_ops::get_allocator_type)
476 == ystdex::type_id<_tByteAlloc>(), "Invalid allocator found.");
477
478 return Deref(static_cast<const _tByteAlloc*>(
479 x.unchecked_access<void*>(default_init,
480 any_ops::get_allocator_ptr)));
481 }
482 };
483
484
490 template<typename _type>
492 YB_ATTR_nodiscard YB_PURE yconstfn bool
493 IsNullPointer(const _type& p) ynothrow
494 {
495 return !bool(get_raw(p));
496 }
497 template<typename _type>
498 YB_ATTR_nodiscard YB_PURE inline bool
499 IsNullPointer(const weak_ptr<_type>& p) ynothrow
500 {
501 TryRet(!shared_ptr<_type>(p).get())
502 CatchIgnore(bad_weak_ptr&)
503 CatchExpr(..., yassume(false))
504 return {};
505 }
507
514 template<typename _type>
516 YB_ATTR_nodiscard YB_PURE yconstfn auto
517 GetRawPtrOf(const _type& p) ynothrow -> decltype(get_raw(p))
518 {
519 return get_raw(p);
520 }
522 template<typename _type>
523 YB_ATTR_nodiscard YB_PURE yconstfn _type*
524 GetRawPtrOf(const weak_ptr<_type>& p)
525 {
526 return shared_ptr<_type>(p).get();
527 }
529
530
548 template<typename _type>
549 class ValueHolder
550 : protected ystdex::boxed_value<_type>, implements IValueHolder
551 {
552 static_assert(std::is_object<_type>(), "Non-object type found.");
553 static_assert(!ystdex::is_cv<_type>(), "Cv-qualified type found.");
554
555 public:
557 using value_type = _type;
558
560 DefDeCtor(ValueHolder)
562 template<typename _tParam, yimpl(typename = ystdex::exclude_self_t<
563 ValueHolder, _tParam>, typename = ystdex::enable_if_t<
564 std::is_constructible<_type, _tParam>::value>)>
565 inline
566 ValueHolder(_tParam&& arg)
567 ynoexcept(std::is_nothrow_constructible<_type, _tParam>())
568 : ystdex::boxed_value<_type>(yforward(arg))
569 {}
571 using ystdex::boxed_value<_type>::boxed_value;
573 DefDeCopyMoveCtorAssignment(ValueHolder)
574
575
576 YB_ATTR_nodiscard PDefH(any, Create, Creation c, const any&) const
577 ImplI(IValueHolder)
578 ImplRet(CreateHolder(c, this->value))
579
581 YB_ATTR_nodiscard YB_PURE PDefH(bool, Equals, const void* p) const
582 ImplI(IValueHolder)
583 ImplRet(bool(p) && AreEqualHeld(this->value,
584 Deref(static_cast<const value_type*>(p))))
585
587 YB_ATTR_nodiscard YB_PURE PDefH(size_t, OwnsCount, ) const ynothrow
588 ImplI(IValueHolder)
589 ImplRet(1)
590
592 YB_ATTR_nodiscard YB_PURE PDefH(any, Query, uintmax_t) const ynothrow
593 ImplI(IValueHolder)
594 ImplRet({})
595
597 YB_ATTR_nodiscard YB_ATTR_returns_nonnull YB_PURE PDefH(void*, get, ) const
598 ynothrow ImplI(IValueHolder)
599 ImplRet(std::addressof(this->value))
600
601
602 YB_ATTR_nodiscard YB_PURE PDefH(const type_info&, type, ) const ynothrow
603 ImplI(IValueHolder)
604 ImplRet(ystdex::type_id<_type>())
605 };
606
607
612 template<class _type, class _tTarget>
613 class PolymorphicValueHolder : public ValueHolder<_tTarget>
614 {
615 public:
616 using Creation = IValueHolder::Creation;
617 using value_type = _type;
618
619 private:
620 using base = ValueHolder<_tTarget>;
621
622 public:
623 using base::value;
624
625 template<typename... _tParams, yimpl(typename
626 = ystdex::exclude_self_params_t<PolymorphicValueHolder, _tParams...>,
627 typename = ystdex::enable_if_t<
628 std::is_constructible<base, _tParams&&...>::value>)>
629 inline
630 PolymorphicValueHolder(_tParams&&... args)
631 : base(yforward(args)...)
632 {}
633 DefDeCopyMoveCtorAssignment(PolymorphicValueHolder)
634
635 YB_ATTR_nodiscard PDefH(any, Create, Creation c, const any&) const
636 ImplI(IValueHolder)
637 ImplRet(HolderOperations<PolymorphicValueHolder>::CreateHolder(c,
638 value, YSLib::forward_as_tuple(ystdex::as_const(value)),
639 YSLib::forward_as_tuple(std::move(value))))
640
641 YB_ATTR_nodiscard YB_PURE PDefH(bool, Equals, const void* p) const
642 ImplI(IValueHolder)
643 ImplRet(bool(p) && base::type() == ystdex::type_id<value_type>()
644 && AreEqualHeld(this->value,
645 Deref(static_cast<const value_type*>(p))))
646
648 YB_ATTR_nodiscard YB_ATTR_returns_nonnull YB_PURE PDefH(void*, get, ) const
649 ynothrow ImplI(IValueHolder)
650 ImplRet(std::addressof(static_cast<_type&>(this->value)))
651
652 YB_ATTR_nodiscard YB_PURE PDefH(const type_info&, type, ) const ynothrow
653 override
654 ImplRet(ystdex::type_id<_type>())
655 };
657
658
670 template<typename _type, class _tByteAlloc>
671 class AllocatorHolder : public ValueHolder<_type>
672 {
674 static_assert(ystdex::is_allocatable<_type>(), "Invalid type found.");
676 static_assert(ystdex::is_byte_allocator<_tByteAlloc>(),
677 "Invalid byte allocator found.");
678
679 public:
681
682 using Creation = IValueHolder::Creation;
684 using value_type = _type;
685
686 private:
687 using base = ValueHolder<value_type>;
688
689 public:
691 using base::value;
692
693 template<typename... _tParams,
694 yimpl(typename = ystdex::exclude_self_params_t<AllocatorHolder,
695 _tParams...>, typename = ystdex::enable_if_t<
696 std::is_constructible<_type, _tParams...>::value>)>
697 inline
698 AllocatorHolder(_tParams&&... args)
699 : base(yforward(args)...)
700 {}
702 DefDeCopyMoveCtorAssignment(AllocatorHolder)
704
705
706 YB_ATTR_nodiscard any
707 Create(Creation c, const any& x) const ImplI(IValueHolder)
708 {
709 return AllocatedHolderOperations<AllocatorHolder, _tByteAlloc>::Create(
710 c, x, value, YSLib::forward_as_tuple(ystdex::as_const(value)),
711 YSLib::forward_as_tuple(std::move(value)));
712 }
713
715 template<class _tObj = _type, typename = ystdex::enable_if_t<
716 ystdex::has_get_allocator<_tObj>::value>>
717 YB_ATTR_nodiscard YB_PURE auto
718 get_allocator() const ynothrow
719 -> decltype(std::declval<const _tObj&>().get_allocator())
720 {
721 return value.get_allocator();
722 }
723 };
724
725
731 template<class _type, class _tTarget, class _tByteAlloc>
732 class PolymorphicAllocatorHolder : public AllocatorHolder<_tTarget, _tByteAlloc>
733 {
734 public:
735 using Creation = IValueHolder::Creation;
736 using value_type = _type;
737
738 private:
739 using base = AllocatorHolder<_tTarget, _tByteAlloc>;
740
741 public:
742 using base::value;
743
744 template<typename... _tParams, yimpl(typename
745 = ystdex::exclude_self_params_t<PolymorphicAllocatorHolder, _tParams...>,
746 typename = ystdex::enable_if_t<
747 std::is_constructible<base, _tParams&&...>::value>)>
748 inline
749 PolymorphicAllocatorHolder(_tParams&&... args)
750 : base(yforward(args)...)
751 {}
752 DefDeCopyMoveCtorAssignment(PolymorphicAllocatorHolder)
753
754 YB_ATTR_nodiscard PDefH(any, Create, Creation c, const any& x) const
755 ImplI(IValueHolder)
756 ImplRet(AllocatedHolderOperations<PolymorphicAllocatorHolder,
757 _tByteAlloc>::CreateHolder(c, x, value, YSLib::forward_as_tuple(
758 ystdex::as_const(value)),
759 YSLib::forward_as_tuple(std::move(value))))
760
761 YB_ATTR_nodiscard YB_PURE PDefH(bool, Equals, const void* p) const
762 ImplI(IValueHolder)
763 ImplRet(bool(p) && base::type() == ystdex::type_id<value_type>()
764 && AreEqualHeld(this->value,
765 Deref(static_cast<const value_type*>(p))))
766
768 YB_ATTR_nodiscard YB_ATTR_returns_nonnull YB_PURE PDefH(void*, get, ) const
769 ynothrow ImplI(IValueHolder)
770 ImplRet(std::addressof(static_cast<_type&>(this->value)))
771
772 using base::get_allocator;
773
774 YB_ATTR_nodiscard YB_PURE PDefH(const type_info&, type, ) const ynothrow
775 override
776 ImplRet(ystdex::type_id<_type>())
777 };
779
780
786 template<typename _tPointer>
787 struct PointerHolderTraits : std::pointer_traits<_tPointer>
788 {
789 public:
790 using holder_pointer = _tPointer;
791 using shared = ystdex::is_sharing<holder_pointer>;
792
794
795 YB_ATTR_nodiscard YB_PURE static PDefH(size_t, count_owner,
796 const holder_pointer& p_held) ynothrow
797 ImplRet(count_owner(shared(), p_held))
798
799 private:
800 YB_ATTR_nodiscard YB_PURE static PDefH(size_t, count_owner, ystdex::false_,
801 const holder_pointer& p_held) ynothrow
802 ImplRet(is_owner(p_held) ? 1 : 0)
803 YB_ATTR_nodiscard YB_PURE static PDefH(size_t, count_owner, ystdex::true_,
804 const holder_pointer& p_held) ynothrow
805 ImplRet(size_t(p_held.use_count()))
807
808 public:
809 YB_ATTR_nodiscard YB_PURE static PDefH(auto, get, const holder_pointer&
810 p_held) ynoexcept_spec(YSLib::GetRawPtrOf(p_held))
811 -> decltype(YSLib::GetRawPtrOf(p_held))
812 ImplRet(YSLib::GetRawPtrOf(p_held))
813
815 YB_ATTR_nodiscard YB_PURE static PDefH(bool, is_unique_owner,
816 const holder_pointer& p_held) ynothrow
817 ImplRet(owns_unique(p_held))
818
820 YB_ATTR_nodiscard YB_PURE static PDefH(bool, is_owner,
821 const holder_pointer& p_held) ynothrow
822 ImplRet(is_owner(std::is_pointer<holder_pointer>(), p_held))
823
824 private:
825 YB_ATTR_nodiscard YB_PURE static PDefH(bool, is_owner, ystdex::false_,
826 const holder_pointer& p_held) ynothrow
827 ImplRet(owns_nonnull(p_held))
828 YB_ATTR_nodiscard YB_PURE static PDefH(bool, is_owner, ystdex::true_,
829 const holder_pointer& p_held) ynothrow
830 ImplRet(bool(p_held))
831 };
832
833
844 template<typename _type,
845 class _tTraits = PointerHolderTraits<unique_ptr<_type>>>
846 class PointerHolder : implements IValueHolder
847 {
849 static_assert(ystdex::is_decayed<_type>(), "Invalid type found.");
850
851 public:
853 using value_type = _type;
855 using traits_type = _tTraits;
856 using holder_pointer = typename traits_type::holder_pointer;
857 using pointer
858 = decltype(traits_type::get(std::declval<const holder_pointer&>()));
860 using shared = typename traits_type::shared;
861
862 protected:
863 holder_pointer p_held;
864
865 public:
867 explicit
868 PointerHolder(pointer value)
869 : p_held(value)
870 {}
872
873 PointerHolder(const holder_pointer& p)
874 : p_held(p)
875 {}
876 PointerHolder(holder_pointer&& p)
877 : p_held(std::move(p))
878 {}
879
881 PointerHolder(const PointerHolder& h)
882 : PointerHolder(h, shared())
883 {}
884
885 private:
886 PointerHolder(const PointerHolder& h, ystdex::false_)
887 : PointerHolder(ystdex::clone_monomorphic_ptr(h.p_held))
888 {}
889 PointerHolder(const PointerHolder& h, ystdex::true_)
890 : p_held(h.p_held)
891 {}
893
894 public:
896 DefDeMoveCtor(PointerHolder)
897
898
899 DefDeCopyAssignment(PointerHolder)
900 DefDeMoveAssignment(PointerHolder)
901
902
903 DefGetter(ynothrow, const holder_pointer&, Held, p_held)
904
906 YB_ATTR_nodiscard any
907 Create(Creation c, const any&) const ImplI(IValueHolder)
908 {
909 // TODO: Blocked. Use C++17 'if constexpr' to simplify.
910 if(shared() && c == IValueHolder::Copy)
911 return HolderOperations<PointerHolder>::CreateInPlaceConditionally(
912 shared(), p_held);
913 if(const auto& p = traits_type::get(p_held))
914 return CreateHolder(c, *p);
915 ystdex::throw_invalid_construction();
916 }
917
919 YB_ATTR_nodiscard YB_PURE PDefH(bool, Equals, const void* p) const
920 ImplI(IValueHolder)
921 ImplRet(traits_type::is_owner(p_held) && p
922 ? AreEqualHeld(Deref(traits_type::get(p_held)),
923 Deref(static_cast<const value_type*>(p))) : false)
924
925
926 YB_ATTR_nodiscard YB_PURE PDefH(size_t, OwnsCount, ) const ynothrow
927 ImplI(IValueHolder)
928 ImplRet(traits_type::count_owner(p_held))
929
931 YB_ATTR_nodiscard YB_PURE PDefH(any, Query, uintmax_t) const ynothrow
932 ImplI(IValueHolder)
933 ImplRet({})
934
939 YB_ATTR_nodiscard YB_ATTR_returns_nonnull YB_PURE PDefH(void*, get, ) const
940 ImplI(IValueHolder)
941 ImplRet(Nonnull(traits_type::get(p_held)))
942
944 YB_ATTR_nodiscard YB_PURE PDefH(const type_info&, type, ) const ynothrow
945 ImplI(IValueHolder)
946 ImplRet(!YSLib::IsNullPointer(p_held) ? ystdex::type_id<_type>()
947 : ystdex::type_id<void>())
948 };
949
950
959 template<typename _type>
960 class RefHolder : implements IValueHolder
961 {
962 static_assert(std::is_object<_type>(), "Invalid type found.");
963
964 public:
965 using value_type
966 = ystdex::remove_reference_t<ystdex::unwrap_reference_t<_type>>;
967
968 private:
970 lref<value_type> ref;
971
972 public:
977 RefHolder(_type& r) ynothrow
978 : ref(r)
979 {}
980 DefDeCopyMoveCtorAssignment(RefHolder)
981
982
983 YB_ATTR_nodiscard PDefH(any, Create, Creation c, const any&) const
984 ImplI(IValueHolder)
985 ImplRet(CreateHolder(c, ref.get()))
986
988 YB_ATTR_nodiscard PDefH(bool, Equals, const void* p) const
989 ImplI(IValueHolder)
990 ImplRet(bool(p) && AreEqualHeld(Deref(static_cast<const value_type*>(
991 get())), Deref(static_cast<const value_type*>(p))))
992
994 YB_ATTR_nodiscard YB_PURE PDefH(size_t, OwnsCount, ) const ynothrow
995 ImplI(IValueHolder)
996 ImplRet(0)
997
999 YB_ATTR_nodiscard YB_PURE PDefH(any, Query, uintmax_t) const ynothrow
1000 ImplI(IValueHolder)
1001 ImplRet({})
1002
1003 YB_ATTR_nodiscard YB_PURE PDefH(void*, get, ) const ImplI(IValueHolder)
1004 ImplRet(ystdex::pvoid(std::addressof(ref.get())))
1005
1006 YB_ATTR_nodiscard YB_PURE PDefH(const type_info&, type, ) const ynothrow
1007 ImplI(IValueHolder)
1008 ImplRet(ystdex::type_id<value_type>())
1009 };
1011
1012
1018 template<typename _tPointer>
1019 using HolderFromPointer = PointerHolder<typename PointerHolderTraits<
1020 _tPointer>::element_type, PointerHolderTraits<_tPointer>>;
1021
1022
1023 template<typename _type>
1024 any
1025 IValueHolder::CreateHolder(Creation c, _type& obj)
1026 {
1027 switch(c)
1028 {
1029 case Indirect:
1030 return
1031 HolderOperations<RefHolder<_type>>::CreateInPlace(ystdex::ref(obj));
1032 case Copy:
1033 return HolderOperations<ValueHolder<_type>>::CreateInPlace(obj);
1034 case Move:
1035 return
1036 HolderOperations<ValueHolder<_type>>::CreateInPlace(std::move(obj));
1037 default:
1038 ystdex::throw_invalid_construction();
1039 }
1040 }
1041
1042
1048 template<typename _type>
1049 struct IsValueHolder : ystdex::false_
1050 {};
1051
1052 template<typename _type>
1053 struct IsValueHolder<ValueHolder<_type>> : ystdex::true_
1054 {};
1056
1057
1067 class YF_API ValueObject : private ystdex::equality_comparable<ValueObject>
1068 {
1069 public:
1074 using Content = any;
1079 template<typename _type>
1080 using InPlaceStorable = any_ops::is_in_place_storable<_type>;
1081
1082 private:
1084 template<typename _type, class _tAlloc>
1085 using alloc_holder_t = AllocatorHolder<ystdex::decay_t<_type>,
1086 ystdex::rebind_alloc_t<_tAlloc, byte>>;
1088 template<typename _type>
1089 using add_vh_t
1090 // XXX: This cannot use %ystdex::vseq::ctor_of_t because it does not
1091 // work for %std::_Tuple_impl instances. See $2019-01
1092 // @ %Documentation::Workflow.
1093 = ystdex::cond_t<IsValueHolder<_type>, _type, ValueHolder<_type>>;
1094
1096 Content content;
1097
1098 public:
1104 DefDeCtor(ValueObject)
1111 template<typename _type,
1112 yimpl(typename = ystdex::exclude_self_t<ValueObject, _type>),
1113 yimpl(typename = ystdex::exclude_self_t<std::allocator_arg_t, _type>)>
1114 inline
1115 ValueObject(_type&& obj)
1116 : content(any_ops::use_holder, in_place_type<add_vh_t<ystdex::decay_t<
1117 _type>>>, yforward(obj))
1118 {}
1124 template<typename _type, class _tAlloc,
1125 yimpl(typename = ystdex::exclude_self_t<ValueObject, _type>)>
1126 inline
1127 ValueObject(std::allocator_arg_t, const _tAlloc& a, _type&& arg)
1128 : ValueObject(std::allocator_arg, a,
1129 in_place_type<ystdex::decay_t<_type>>, yforward(arg))
1130 {}
1132
1133
1142 template<typename _type, typename... _tParams>
1143 explicit inline
1144 ValueObject(in_place_type_t<_type>, _tParams&&... args)
1145 : content(any_ops::use_holder,
1146 in_place_type<ValueHolder<_type>>, yforward(args)...)
1147 {}
1152 template<typename _type, class _tAlloc, typename... _tParams>
1153 inline
1154 ValueObject(std::allocator_arg_t, const _tAlloc& a, in_place_type_t<_type>,
1155 _tParams&&... args)
1156 : content(std::allocator_arg, a, any_ops::use_holder,
1157 in_place_type<alloc_holder_t<_type, _tAlloc>>, yforward(args)...)
1158 {
1159 static_assert(typename any::allocated_holder_handler_t<_tAlloc,
1160 alloc_holder_t<_type, _tAlloc>>::base::local_storage(),
1161 "Non-local storage found.");
1162 }
1164
1166
1170 template<typename _tHolder, typename... _tParams>
1171 inline
1172 ValueObject(any_ops::use_holder_t, in_place_type_t<_tHolder>,
1173 _tParams&&... args)
1174 : content(any_ops::use_holder, in_place_type<_tHolder>,
1175 yforward(args)...)
1176 {
1177 static_assert(ystdex::is_convertible<_tHolder&, IValueHolder&>(),
1178 "Invalid holder found.");
1179 }
1184 template<typename _tHolder, class _tAlloc, typename... _tParams>
1185 inline
1186 ValueObject(std::allocator_arg_t, const _tAlloc& a, any_ops::use_holder_t,
1187 in_place_type_t<_tHolder>, _tParams&&... args)
1188 : content(std::allocator_arg, a, any_ops::use_holder,
1189 in_place_type<_tHolder>, yforward(args)...)
1190 {
1191 static_assert(ystdex::is_convertible<_tHolder&, IValueHolder&>(),
1192 "Invalid holder found.");
1193 }
1195
1196
1197 private:
1202 ValueObject(const IValueHolder& h, const any& x, IValueHolder::Creation c)
1203 : content(h.Create(c, x))
1204 {}
1205
1206 public:
1211 template<typename _type>
1212 inline
1213 ValueObject(_type& obj, OwnershipTag<>)
1214 : content(any_ops::use_holder,
1215 in_place_type<RefHolder<_type>>, ystdex::ref(obj))
1216 {
1217 static_assert(InPlaceStorable<RefHolder<_type>>(),
1218 "Suboptimal holder found.");
1219 }
1229 template<typename _type>
1230 inline
1231 ValueObject(_type* p, PointerTag)
1232 : content(any_ops::use_holder,
1233 in_place_type<PointerHolder<_type>>, p)
1234 {}
1239 template<typename _type>
1240 inline
1241 ValueObject(unique_ptr<_type>&& p, PointerTag)
1242 : ValueObject(p.get(), PointerTag())
1243 {
1244 p.release();
1245 }
1247 DefDeCopyMoveCtorAssignment(ValueObject)
1250 template<class _tAlloc>
1251 inline
1252 ValueObject(std::allocator_arg_t, const _tAlloc& a, const ValueObject& vo)
1253 : content(std::allocator_arg, a, vo.content)
1254 {}
1256 template<class _tAlloc>
1257 inline
1258 ValueObject(std::allocator_arg_t, const _tAlloc& a, ValueObject&& vo)
1259 : content(std::allocator_arg, a, std::move(vo.content))
1260 {}
1265 DefDeDtor(ValueObject)
1266
1267
1271 DefBoolNeg(explicit, content.has_value())
1272
1274
1275
1279 YB_ATTR_nodiscard YB_PURE friend
1280 PDefHOp(bool, ==, const ValueObject& x, const ValueObject& y)
1281 ImplRet(x.Equals(y))
1283
1284
1286 template<typename _type>
1287 YB_ATTR_nodiscard YB_PURE friend inline bool
1288 operator==(const ValueObject& x, const _type& y)
1289 {
1290 return x.Equals(y);
1291 }
1292 template<typename _type>
1293 YB_ATTR_nodiscard YB_PURE friend inline bool
1294 operator==(const _type& x, const ValueObject& y)
1295 {
1296 return y.Equals(x);
1297 }
1299
1301
1302 template<typename _type>
1303 YB_ATTR_nodiscard friend inline bool
1304 operator!=(const ValueObject& x, const _type& y)
1305 {
1306 return !(x == y);
1307 }
1308 template<typename _type>
1309 YB_ATTR_nodiscard friend inline bool
1310 operator!=(const _type& x, const ValueObject& y)
1311 {
1312 return !(x == y);
1313 }
1315
1316
1317
1322 DefGetter(const ynothrow, const Content&, Content, content)
1324
1325 YB_ATTR_nodiscard YB_PURE IValueHolder*
1327 GetHolderPtr() const;
1332 YB_ATTR_nodiscard YB_PURE IValueHolder&
1333 GetHolderRef() const;
1335
1342 template<typename _type>
1343 YB_ATTR_nodiscard YB_PURE inline _type&
1344 GetObject()
1345 {
1346 return Deref(YSLib::unchecked_any_cast<_type>(&content));
1347 }
1348 template<typename _type>
1349 YB_ATTR_nodiscard YB_PURE inline const _type&
1350 GetObject() const
1351 {
1352 return Deref(YSLib::unchecked_any_cast<const _type>(&content));
1353 }
1355
1362 template<typename _type>
1363 YB_ATTR_nodiscard YB_PURE inline _type&
1364 Access()
1365 {
1366 return YSLib::any_cast<_type&>(content);
1367 }
1368 template<typename _type>
1369 YB_ATTR_nodiscard YB_PURE inline const _type&
1370 Access() const
1371 {
1372 return YSLib::any_cast<const _type&>(content);
1373 }
1375
1381 template<typename _type>
1382 YB_ATTR_nodiscard YB_PURE inline observer_ptr<_type>
1383 AccessPtr() ynothrow
1384 {
1385 return YSLib::make_observer(YSLib::any_cast<_type>(&content));
1386 }
1387 template<typename _type>
1388 YB_ATTR_nodiscard YB_PURE inline observer_ptr<const _type>
1389 AccessPtr() const ynothrow
1390 {
1391 return YSLib::make_observer(YSLib::any_cast<const _type>(&content));
1392 }
1394
1400 PDefH(void, Clear, ) ynothrow
1401 ImplExpr(content.reset())
1402
1407 YB_ATTR_nodiscard PDefH(ValueObject, CopyMove, )
1408 ImplRet(ystdex::copy_or_move(!OwnsUnique(), *this))
1409
1414 YB_ATTR_nodiscard YB_PURE ValueObject
1415 Create(IValueHolder::Creation) const;
1416
1425 YB_ATTR_nodiscard YB_PURE bool
1426 Equals(const ValueObject&) const;
1427 template<typename _type>
1428 YB_ATTR_nodiscard YB_PURE bool
1429 Equals(const _type& x) const
1430 {
1431 if(const auto p_holder = content.get_holder())
1432 return p_holder->type() == ystdex::type_id<_type>()
1433 && EqualsRaw(std::addressof(x));
1434 return {};
1435 }
1436
1438 YB_ATTR_nodiscard YB_PURE bool
1439 EqualsRaw(const void*) const;
1440
1445 YB_ATTR_nodiscard YB_PURE bool
1446 EqualsUnchecked(const void*) const;
1448
1453 YB_ATTR_nodiscard YB_PURE PDefH(ValueObject, MakeCopy, ) const
1454 ImplRet(Create(IValueHolder::Copy))
1455
1460 YB_ATTR_nodiscard YB_PURE PDefH(ValueObject, MakeIndirect, ) const
1461 ImplRet(Create(IValueHolder::Indirect))
1462
1467 YB_ATTR_nodiscard YB_PURE PDefH(ValueObject, MakeMove, ) const
1468 ImplRet(Create(IValueHolder::Move))
1469
1474 YB_ATTR_nodiscard YB_PURE PDefH(ValueObject, MakeMoveCopy, ) const
1475 ImplRet(Create(OwnsUnique() ? IValueHolder::Move : IValueHolder::Copy))
1476
1481 YB_ATTR_nodiscard YB_PURE size_t
1482 OwnsCount() const ynothrow;
1483
1488 YB_ATTR_nodiscard YB_PURE PDefH(bool, OwnsUnique, ) const ynothrow
1489 ImplRet(OwnsCount() == 1)
1490
1500 YB_ATTR_nodiscard YB_PURE any
1501 Query(uintmax_t = 0) const;
1502
1504
1505 template<typename _type, typename... _tParams,
1506 yimpl(typename = ystdex::exclude_tagged_params_t<_tParams...>)>
1507 inline void
1508 emplace(_tParams&&... args)
1509 {
1510 using Holder = ValueHolder<ystdex::decay_t<_type>>;
1511
1512 content.emplace<Holder>(any_ops::use_holder, Holder(yforward(args)...));
1513 }
1515 template<typename _type, class _tAlloc, typename... _tParams>
1516 inline void
1517 emplace(std::allocator_arg_t, const _tAlloc& a, _tParams&&... args)
1518 {
1519 using Holder = alloc_holder_t<_type, _tAlloc>;
1520 static_assert(typename any::allocated_holder_handler_t<_tAlloc,
1521 alloc_holder_t<_type, _tAlloc>>::base::local_storage(),
1522 "Non-local storage found.");
1523
1524 content.emplace<Holder>(std::allocator_arg, a, any_ops::use_holder,
1525 Holder(yforward(args)...));
1526 }
1527 template<typename _type>
1528 inline void
1529 emplace(_type* p, PointerTag)
1530 {
1531 using Holder = PointerHolder<ystdex::decay_t<_type>>;
1532
1533 content.emplace<Holder>(any_ops::use_holder, Holder(p));
1534 }
1536
1541 friend PDefH(void, swap, ValueObject& x, ValueObject& y) ynothrow
1542 ImplExpr(x.content.swap(y.content))
1543
1544
1549 YB_ATTR_nodiscard PDefH(const type_info&, type, ) const ynothrow
1550 ImplRet(content.type())
1551 };
1552
1558
1560 template<typename _type>
1561 YB_ATTR_nodiscard YB_PURE inline observer_ptr<_type>
1562 AccessPtr(ValueObject& vo) ynothrow
1563 {
1564 return vo.AccessPtr<_type>();
1565 }
1566 template<typename _type>
1567 YB_ATTR_nodiscard YB_PURE inline observer_ptr<const _type>
1568 AccessPtr(const ValueObject& vo) ynothrow
1569 {
1570 return vo.AccessPtr<_type>();
1571 }
1573
1583 template<typename _type, typename... _tParams>
1584 void
1585 EmplaceCallResult(ValueObject&, _type&&, ystdex::false_, _tParams&&...) ynothrow
1586 {}
1587 template<typename _type>
1588 inline void
1589 EmplaceCallResult(ValueObject& vo, _type&& res, ystdex::true_, ystdex::true_)
1590 ynoexcept_spec(vo = yforward(res))
1591 {
1592 vo = yforward(res);
1593 }
1595 template<typename _type, class _tAlloc>
1596 inline void
1597 EmplaceCallResult(ValueObject& vo, _type&& res, ystdex::true_, ystdex::true_,
1598 const _tAlloc&)
1599 ynoexcept_spec(vo = yforward(res))
1600 {
1601 // XXX: The allocator argument is ignored. This is more efficient and there
1602 // is no allocation type limitation on the value as the allocator-aware
1603 // move constructor.
1604 vo = yforward(res);
1605 }
1606 template<typename _type, class _tAlloc>
1607 inline void
1608 EmplaceCallResult(ValueObject& vo, _type&& res, ystdex::true_, ystdex::false_,
1609 const _tAlloc& a)
1610 {
1611 vo.emplace<ystdex::decay_t<_type>>(std::allocator_arg, a, yforward(res));
1612 }
1613 template<typename _type>
1614 inline void
1615 EmplaceCallResult(ValueObject& vo, _type&& res, ystdex::true_, ystdex::false_)
1616 {
1617 vo.emplace<ystdex::decay_t<_type>>(yforward(res));
1618 }
1619 template<typename _type>
1620 inline void
1621 EmplaceCallResult(ValueObject& vo, _type&& res, ystdex::true_)
1622 {
1623 YSLib::EmplaceCallResult(vo, yforward(res), ystdex::true_(),
1624 std::is_same<ystdex::decay_t<_type>, ValueObject>());
1625 }
1626 template<typename _type, class _tAlloc>
1627 inline void
1628 EmplaceCallResult(ValueObject& vo, _type&& res, ystdex::true_,
1629 const _tAlloc& a)
1630 {
1631 YSLib::EmplaceCallResult(vo, yforward(res), ystdex::true_(),
1632 std::is_same<ystdex::decay_t<_type>, ValueObject>(), a);
1633 }
1634 template<typename _type>
1635 inline void
1636 EmplaceCallResult(ValueObject& vo, _type&& res)
1637 {
1638 YSLib::EmplaceCallResult(vo, yforward(res), ystdex::not_<
1639 std::is_same<ystdex::decay_t<_type>, ystdex::pseudo_output>>());
1640 }
1641 template<typename _type, class _tAlloc>
1642 inline void
1643 EmplaceCallResult(ValueObject& vo, _type&& res, const _tAlloc& a)
1644 {
1645 YSLib::EmplaceCallResult(vo, yforward(res), ystdex::not_<
1646 std::is_same<ystdex::decay_t<_type>, ystdex::pseudo_output>>(), a);
1647 }
1649
1650 template<typename _type, typename... _tParams>
1651 YB_ATTR_nodiscard _type&
1652 EmplaceIfEmpty(ValueObject& vo, _tParams&&... args)
1653 {
1654 if(!vo)
1655 {
1656 vo.emplace<_type>(yforward(args)...);
1657 return vo.GetObject<_type>();
1658 }
1659 return vo.Access<_type>();
1660 }
1661
1663 YB_ATTR_nodiscard YB_PURE inline
1664 PDefH(bool, HoldSame, const ValueObject& x, const ValueObject& y)
1665 ImplRet(ystdex::hold_same(x.GetContent(), y.GetContent()))
1667
1668
1669
1680 template<typename _type, class _tOwnerPointer = shared_ptr<_type>>
1681 class GDependency
1682 {
1683 public:
1684 using DependentType = _type;
1685 using PointerType = _tOwnerPointer;
1686 using ConstReferenceType = decltype(*PointerType());
1687 using ReferentType = ystdex::remove_const_t<ystdex::remove_reference_t<
1688 ConstReferenceType>>;
1689 using ReferenceType = ReferentType&;
1690
1691 private:
1692 PointerType ptr;
1693
1694 public:
1695 inline
1696 GDependency(PointerType p = PointerType())
1697 : ptr(p)
1698 {
1699 GetCopyOnWritePtr();
1700 }
1701
1702 DefDeCopyAssignment(GDependency)
1703 DefDeMoveAssignment(GDependency)
1704
1705 DefCvt(const ynothrow, ConstReferenceType, *ptr)
1706 DefCvt(ynothrow, ReferenceType, *ptr)
1707 DefCvt(const ynothrow, bool, bool(ptr))
1708
1709 DefGetter(const ynothrow, ConstReferenceType, Ref,
1710 operator ConstReferenceType())
1711 DefGetter(ynothrow, ReferenceType, Ref, operator ReferenceType())
1712 DefGetter(ynothrow, ReferenceType, NewRef, *GetCopyOnWritePtr())
1713
1715 YB_ATTR_nodiscard PointerType
1716 GetCopyOnWritePtr()
1717 {
1718 if(!ptr)
1719 ptr = PointerType(new DependentType());
1720 else if(!ptr.unique())
1721 ptr = PointerType(ystdex::clone_monomorphic(Deref(ptr)));
1722 return Nonnull(ptr);
1723 }
1724
1725 PDefH(void, Reset, )
1726 ImplExpr(reset(ptr))
1727 };
1728
1729
1735 template<typename _type>
1736 class GMRange
1737 {
1738 public:
1739 using ValueType = _type;
1740
1741 protected:
1742 ValueType max_value;
1743 ValueType value;
1744
1748 GMRange(ValueType m, ValueType v)
1749 : max_value(m), value(v)
1750 {}
1751
1752 public:
1753 DefGetter(const ynothrow, ValueType, MaxValue, max_value)
1754 DefGetter(const ynothrow, ValueType, Value, value)
1755 };
1756
1757 } // namespace YSLib;
1758
1759 #endif
1760
YSLib::HeldEqual
判断动态泛型的持有值是否相等。
Definition: YObject.h:218
YSLib::ValueHolder
带等于接口的值类型动态泛型持有者。
Definition: YObject.h:551
YSLib::PointerHolder
带等于接口的指针类型动态泛型持有者。
Definition: YObject.h:847
YSLib::ValueHolder::Create
Create
Definition: YObject.h:576
YSLib::GMRange
判断是否持有相同对象。
Definition: YObject.h:1737
YSLib::GMRange< ScrollEventArgs::ValueType >::ValueType
ScrollEventArgs::ValueType ValueType
Definition: YObject.h:1739
YB_ATTR_nodiscard
#define YB_ATTR_nodiscard
标记返回值不被忽略的属性。
Definition: ydef.h:715
ystdex::cpp2017::apply
auto apply(_func &&f, _tTuple &&t) -> decltype(call_projection< _tTuple, make_index_sequence< std::tuple_size< decay_t< _tTuple >>::value >>::apply_invoke(std::forward< decltype(f)>(f), std::forward< decltype(t)>(t)))
应用函数对象和参数元组。
Definition: apply.hpp:199
YSLib::PolymorphicAllocatorHolder::DefDeCopyMoveCtorAssignment
DefDeCopyMoveCtorAssignment(PolymorphicAllocatorHolder) YB_ATTR_nodiscard PDefH(any
YSLib::HeldEqual< weak_ptr< _type1 >, weak_ptr< _type2 > >::are_equal
YB_ATTR_nodiscard static YB_PURE bool are_equal(const weak_ptr< _type1 > &x, const weak_ptr< _type2 > &y)
Definition: YObject.h:226
x
const EncapsulationBase & x
Definition: NPLA1Forms.cpp:1536
EndDecl
#define EndDecl
Definition: YBaseMacro.h:406
YSLib::swap
void swap(ValueNode &x, ValueNode &y) ynothrowv
Definition: ValueNode.cpp:95
platform::Nonnull
YB_PURE _type && Nonnull(_type &&p) ynothrowv
断言并返回非空参数。
Definition: Debug.h:518
CatchIgnore
#define CatchIgnore(_ex)
指定异常处理器忽略指定异常。
Definition: YBaseMacro.h:133
CHRLib::c
c
Definition: CharacterProcessing.h:84
ystdex::boxed_value::boxed_value
boxed_value()
Definition: utility.hpp:171
ystdex::lref
左值引用包装。
Definition: ref.hpp:61
YSLib::EmplaceIfEmpty
YB_ATTR_nodiscard _type & EmplaceIfEmpty(ValueObject &vo, _tParams &&... args)
Definition: YObject.h:1652
YSLib::GetRawPtrOf
YB_ATTR_nodiscard YB_PURE yconstfn auto GetRawPtrOf(const _type &p) ynothrow -> decltype(get_raw(p))
取内建指针。
Definition: YObject.h:517
YB_PURE
#define YB_PURE
指示函数或函数模板实例为纯函数。
Definition: ydef.h:919
YSLib::MoveTag
指示转移的标记。
Definition: YObject.h:99
YSLib::GMRange::DefGetter
DefGetter(const ynothrow, ValueType, MaxValue, max_value) DefGetter(const ynothrow
YSLib::ValueObject::Access
YB_ATTR_nodiscard YB_PURE _type & Access()
访问指定类型对象。
Definition: YObject.h:1364
typeindex.h
ISO C++ 类型索引扩展。
YSLib::EmplaceCallResult
void EmplaceCallResult(ValueObject &, _type &&, ystdex::false_, _tParams &&...) ynothrow
以指定参数按需构造替换值。
Definition: YObject.h:1585
YSLib::Drawing::r
The boundary is out of the const Graphics const Rect const Point const Point Color c const Rect const Rect & r
Definition: YDraw.h:174
YSLib::ValueObject::ValueObject
ValueObject(const IValueHolder &h, const any &x, IValueHolder::Creation c)
构造：使用持有者、源和和动态创建选项。
Definition: YObject.h:1202
YSLib::IO::_tTraits
const string &path const String &path class class _tTraits
Definition: YSLib/Service/FileSystem.h:582
ystdex::cpp2014::enable_if_t
typename enable_if< _bCond, _type >::type enable_if_t
Definition: meta.hpp:199
ystdex::details::any_emplace::emplace
decay_t< _type > & emplace(_tParams &&... args)
Definition: any.h:1418
YSLib::ValueObject::ValueObject
ValueObject(unique_ptr< _type > &&p, PointerTag)
构造：使用对象 unique_ptr 指针。
Definition: YObject.h:1241
ystdex::dep_ops::equality_comparable
_t< details::ops_seq< _type, _type2, _tOpt, cond_t< is_same< _type, _type2 >, index_sequence< 7 >, index_sequence< 6, 7, 8 > >> > equality_comparable
Definition: operators.hpp:265
ystdex::exclude_self_params_t
enable_if_t< not_< cond_or_t< bool_< sizeof...(_tParams)==1 >, false_, is_same_param, _tSelected, _tParams... > >::value, void > exclude_self_params_t
排除选择类型的特定参数类型的重载。
Definition: type_op.hpp:295
ystdex::unchecked_any_cast
_type * unchecked_any_cast(any *p)
未检查的动态泛型转换。
Definition: any.h:2324
YSLib::HolderOperations::CreateInPlaceConditionally
YB_ATTR_nodiscard static YB_NORETURN any CreateInPlaceConditionally(std::allocator_arg_t, const _tAlloc &, ystdex::false_, _tParams &&...)
Definition: YObject.h:337
YSLib::PointerHolder::shared
typename traits_type::shared shared
Definition: YObject.h:860
YSLib::ValueObject::ValueObject
ValueObject(std::allocator_arg_t, const _tAlloc &a, _type &&arg)
构造：使用对象引用和分配器。
Definition: YObject.h:1127
YSLib::ValueObject::ValueObject
ValueObject(_type &obj, OwnershipTag<>)
构造：使用无所有权的引用。
Definition: YObject.h:1213
YSLib::operator==
bool operator==(const shared_ptr< _type > &sp, _type *p)
比较： shared_ptr 和内建指针类型的相等关系。
Definition: YShellDefinition.h:62
YSLib::IsNullPointer
YB_ATTR_nodiscard YB_PURE yconstfn bool IsNullPointer(const _type &p) ynothrow
判断指针值是否为有效的空值。
Definition: YObject.h:493
YSLib::PolymorphicAllocatorHolder::Creation
IValueHolder::Creation Creation
Definition: YObject.h:735
ystdex::any::allocated_holder_handler_t
cond_t< any::opt_in_place_t< _tHolder >, any_ops::holder_handler< _tHolder >, any_ops::allocator_holder_handler_t< _tAlloc, _tHolder > > allocated_holder_handler_t
根据分配器类型和存储对象的类型取使用分配器和持有者构造时的处理器。
Definition: any.h:1694
ynoexcept_spec
#define ynoexcept_spec(...)
表达式 noexcept 异常规范。
Definition: ydef.h:1181
ystdex::nullptr_t
空指针类。
Definition: ydef.h:1321
ystdex::is_cv
判断指定类型是否为 const 或 volatile 类型。
Definition: meta.hpp:588
YSLib::PointerHolderTraits::PDefH
YB_ATTR_nodiscard static YB_PURE PDefH(size_t, count_owner, const holder_pointer &p_held) ynothrow ImplRet(count_owner(shared()
YSLib::AllocatedHolderOperations::GetByteAllocatorOf
YB_ATTR_nodiscard static YB_PURE const _tByteAlloc & GetByteAllocatorOf(const any &x) ynothrowv
Definition: YObject.h:469
YSLib::DeclDerivedI
DeclDerivedI(YF_API, IValueHolder, any_ops::holder) enum Creation
带等于接口的动态泛型持有者接口。
Definition: YObject.h:126
YSLib::HolderOperations::CreateInPlaceWithAllocatorImpl
YB_ATTR_nodiscard static YB_NORETURN any CreateInPlaceWithAllocatorImpl(void *, _tParams &&...)
Definition: YObject.h:318
YF_API
#define YF_API
Definition: Platform.h:56
ystdex::examiners::equal_examiner
等于操作检测。
Definition: examiner.hpp:83
ystdex::any_ops
Definition: any.h:68
ystdex::has_get_allocator
判断类型具有返回分配器的无异常抛出的 get_allocator 成员函数。
Definition: allocator.hpp:670
YSLib::PointerHolder::PointerHolder
PointerHolder(pointer value)
取得所有权。
Definition: YObject.h:868
YSLib::ValueHolder< _tTarget >::value_type
_tTarget value_type
Definition: YObject.h:557
ystdex::is_byte_allocator
判断类型是 byte 分配器。
Definition: allocator.hpp:616
YSLib::ValueObject::Access
YB_ATTR_nodiscard YB_PURE const _type & Access() const
Definition: YObject.h:1370
YSLib::UI::Move
@ Move
移动：位置调整。
Definition: YWidgetEvent.h:381
YSLib::HolderOperations::Creation
IValueHolder::Creation Creation
Definition: YObject.h:270
ystdex::bad_any_cast
动态泛型转换失败异常。
Definition: any.h:1091
YSLib::ValueObject::DefDeDtor
DefDeDtor(ValueObject) DefBoolNeg(explicit
析构：默认实现。
YSLib::operator!=
bool operator!=(const shared_ptr< _type > &sp, _type *p)
比较： shared_ptr 左值和内建指针类型的不等关系。
Definition: YShellDefinition.h:84
YSLib::ValueObject::ValueObject
ValueObject(any_ops::use_holder_t, in_place_type_t< _tHolder >, _tParams &&... args)
构造：使用持有者。
Definition: YObject.h:1172
YSLib::PointerHolderTraits::holder_pointer
_tPointer holder_pointer
Definition: YObject.h:790
YSLib::AllocatorHolder::get_allocator
YB_ATTR_nodiscard YB_PURE auto get_allocator() const ynothrow -> decltype(std::declval< const _tObj & >().get_allocator())
Definition: YObject.h:718
ystdex::clone_monomorphic_ptr
auto clone_monomorphic_ptr(const _tPointer &p) -> decltype(ystdex::clone_monomorphic(*p))
若指针非空，使用 new 复制指针指向的对象。
Definition: memory.hpp:1161
ystdex::is_decayed
判断指定类型是否已退化为指定类型。
Definition: meta.hpp:672
YSLib::HolderOperations::CreateHolder
YB_ATTR_nodiscard static YB_PURE any CreateHolder(Creation c, _tValue &val, _tCopyParams &&args_copy, _tMoveParams &&args_move)
Definition: YObject.h:377
YSLib::RefHolder::ref
lref< value_type > ref
Definition: YObject.h:970
ystdex::default_init
const struct ystdex::default_init_t default_init
ystdex::get_raw
_type * get_raw(_type *const &p)
Definition: memory.hpp:449
examiner.hpp
C++ 类型操作检测。
YSLib::AllocatorHolder
在复制初始化时传播分配器的值持有者。
Definition: YObject.h:672
YSLib::IsValueHolder
Definition: YObject.h:1050
YSLib::ValueObject::content
Content content
Definition: YObject.h:1096
ystdex::details::_type2
_type2
Definition: operators.hpp:241
yassume
#define yassume(_expr)
假定：环境语义。
Definition: cassert.h:96
YSLib::PointerHolder::PointerHolder
PointerHolder(const PointerHolder &h)
Definition: YObject.h:881
ystdex::cpp2014::decay_t
typename decay< _type >::type decay_t
Definition: meta.hpp:196
ystdex::exclude_tagged_params_t
enable_if_t< sizeof...(_tParams)==0 ? true :details::decayed_not_tag_t< vseq::front_t< empty_base< _tParams... > >>::value > exclude_tagged_params_t
排除选择类型的第一个参数为标签的重载。
Definition: any.h:1184
YSLib::ValueObject::PDefH
PDefH(void, Clear,) ynothrow ImplExpr(content.reset()) YB_ATTR_nodiscard PDefH(ValueObject
清除。
YSLib::AllocatedHolderOperations::CreateInPlaceFunctor::Allocator
const _tByteAlloc & Allocator
Definition: YObject.h:404
YSLib::PolymorphicValueHolder::Creation
IValueHolder::Creation Creation
Definition: YObject.h:616
YSLib::HolderOperations::CreateInPlaceFunctor::operator()
auto operator()(_tParams &&... args) -> decltype(CreateInPlace(yforward(args)...))
Definition: YObject.h:366
any.h
动态泛型类型。
YB_ATTR_returns_nonnull
#define YB_ATTR_returns_nonnull
指示返回非空属性。
Definition: ydef.h:761
DefBoolNeg
#define DefBoolNeg(_spec,...)
定义表示显式转换 bool 操作符及其否定的 operator! 。
Definition: YBaseMacro.h:228
YSLib::PointerHolder::PointerHolder
PointerHolder(holder_pointer &&p)
Definition: YObject.h:876
YSLib::YAssert
YAssert(!(v< Deref(a)), "Value less than lower bound found.")
YSLib::PointerHolder::PointerHolder
PointerHolder(const PointerHolder &h, ystdex::true_)
Definition: YObject.h:889
YSLib::ValueObject::ValueObject
ValueObject(std::allocator_arg_t, const _tAlloc &a, ValueObject &&vo)
Definition: YObject.h:1258
YB_NORETURN
#define YB_NORETURN
指定无返回值函数。
Definition: ydef.h:877
ystdex::make_observer
observer_ptr< _type > make_observer(_type *p)
Definition: pointer.hpp:405
YSLib::AllocatedHolderOperations::CreateDispatched
YB_ATTR_nodiscard static YB_PURE any CreateDispatched(Creation c, const any &x, ystdex::false_, _tValue &val, _tParams &&... args)
Definition: YObject.h:430
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 转发对应参数。
Definition: ydef.h:1508
ystdex::boxed_value
包装类类型的值的对象。
Definition: utility.hpp:159
YSLib::HolderOperations::CreateInPlaceFunctor
Definition: YObject.h:363
YSLib::PointerHolderTraits
指针持有者特征。
Definition: YObject.h:788
ystdex::any_ops::get_allocator_type
@ get_allocator_type
取重绑定到 byte 的分配器的类型。
Definition: any.h:324
YSLib::ValueObject
值类型对象类。
Definition: YObject.h:1068
YSLib::HasOwnershipOf
标签类型元运算。
Definition: YObject.h:118
YSLib::PointerHolder::traits_type
_tTraits traits_type
Definition: YObject.h:855
YSLib::AllocatedHolderOperations::CreateInPlaceFunctor
Definition: YObject.h:403
YSLib::PolymorphicValueHolder::value_type
_type value_type
Definition: YObject.h:617
ystdex::throw_invalid_construction
void throw_invalid_construction()
Definition: ystdex/exception.cpp:49
ystdex::boxed_value::value
_type value
Definition: utility.hpp:164
YSLib::PolymorphicAllocatorHolder::PolymorphicAllocatorHolder
PolymorphicAllocatorHolder(_tParams &&... args)
Definition: YObject.h:749
YSLib::AreEqualHeld
YB_ATTR_nodiscard YB_PURE yconstfn bool AreEqualHeld(const _type1 &x, const _type2 &y)
判断动态泛型的持有值是否相等。
Definition: YObject.h:252
YSLib::ValueObject::AccessPtr
YB_ATTR_nodiscard YB_PURE observer_ptr< const _type > AccessPtr() const ynothrow
Definition: YObject.h:1389
std
Definition: optional.h:982
ystdex::owns_nonnull
bool owns_nonnull(_type *const &)
Definition: memory.hpp:514
YSLib::PointerHolder::value_type
_type value_type
Definition: YObject.h:853
YSLib::ValueObject::yimpl
yimpl(typename=ystdex::exclude_self_t< std::allocator_arg_t, _type >)> inline ValueObject(_type &&obj)
Definition: YObject.h:1113
YSLib::ValueObject::ValueObject
ValueObject(std::allocator_arg_t, const _tAlloc &a, in_place_type_t< _type >, _tParams &&... args)
构造：使用对象和分配器初始化参数。
Definition: YObject.h:1154
ystdex::pseudo_output
伪输出对象。
Definition: invoke.hpp:67
YSLib::yimpl
YF_API yimpl(GUIApplication &) FetchGlobalInstance()
取全局应用程序实例。
YSLib::PointerHolder::DefDeMoveCtor
DefDeMoveCtor(PointerHolder) DefDeCopyAssignment(PointerHolder) DefDeMoveAssignment(PointerHolder) DefGetter(ynothrow
operators.hpp
重载操作符。
YSLib::ValueObject::ValueObject
ValueObject(_type *p, PointerTag)
构造：使用对象指针。
Definition: YObject.h:1231
ystdex::clone_monomorphic
_type * clone_monomorphic(const _type &v)
使用 new 复制对象。
Definition: memory.hpp:1145
YSLib::OwnershipTag
指定对参数指定类型的成员具有所有权的标签。
Definition: YObject.h:91
YSLib::RefHolder::DefDeCopyMoveCtorAssignment
DefDeCopyMoveCtorAssignment(RefHolder) YB_ATTR_nodiscard PDefH(any
YSLib::HolderOperations::CreateInPlaceImpl
YB_ATTR_nodiscard static YB_NORETURN any CreateInPlaceImpl(void *, _tParams &&...)
Definition: YObject.h:300
YSLib::AllocatorHolder< _tTarget, _tByteAlloc >::Creation
IValueHolder::Creation Creation
Definition: YObject.h:682
YSLib::PolymorphicValueHolder
带等于接口的值类型多态动态泛型持有者。
Definition: YObject.h:614
YSLib::PolymorphicValueHolder::PolymorphicValueHolder
PolymorphicValueHolder(_tParams &&... args)
Definition: YObject.h:630
YSLib::HolderOperations::CreateInPlace
static YB_ATTR_nodiscard any CreateInPlace(std::allocator_arg_t, const _tAlloc &a, _tParams &&... args)
Definition: YObject.h:281
YSLib::RefHolder
带等于接口的引用动态泛型持有者。
Definition: YObject.h:961
ystdex::type_id
const type_info & type_id()
Definition: typeinfo.h:149
ystdex::any_cast
_type any_cast(any &x)
动态泛型转换。
Definition: any.h:2241
YSLib::ValueHolder::ImplI
Creation const any &const ImplI(IValueHolder) ImplRet(CreateHolder(c
ystdex::cpp2014::remove_const_t
typename remove_const< _type >::type remove_const_t
ISO C++ 14 兼容类型操作别名。
Definition: meta.hpp:136
YSLib::ValueHolder::PDefH
Creation const any &const this value YB_ATTR_nodiscard YB_PURE PDefH(bool, Equals, const void *p) const ImplI(IValueHolder) ImplRet(bool(p) &&AreEqualHeld(this -> value, Deref(static_cast< const value_type * >(p)))) YB_ATTR_nodiscard YB_PURE PDefH(size_t, OwnsCount,) const ynothrow ImplI(IValueHolder) ImplRet(1) YB_ATTR_nodiscard YB_PURE PDefH(any, Query, uintmax_t) const ynothrow ImplI(IValueHolder) ImplRet(
Definition: YObject.h:581
ystdex::rebind_alloc_t
typename allocator_traits< _tAlloc >::template rebind_alloc< _type > rebind_alloc_t
Definition: allocator.hpp:423
implements
#define implements
Definition: YBaseMacro.h:358
YSLib::UI::y
SPos SPos y
Definition: YWidget.cpp:44
YSLib::GMRange::value
ValueType value
值。
Definition: YObject.h:1743
CatchExpr
#define CatchExpr(_ex,...)
指定表达式作为异常处理器。
Definition: YBaseMacro.h:129
YSLib::AllocatorHolder::AllocatorHolder
AllocatorHolder(_tParams &&... args)
Definition: YObject.h:698
YSLib::PointerHolder::PointerHolder
PointerHolder(const PointerHolder &h, ystdex::false_)
Definition: YObject.h:886
YSLib::ValueObject::GetObject
YB_ATTR_nodiscard YB_PURE _type & GetObject()
取指定类型的对象。
Definition: YObject.h:1344
ystdex::true_
bool_< true > true_
Definition: integral_constant.hpp:109
DefDeCopyAssignment
#define DefDeCopyAssignment(_t)
Definition: YBaseMacro.h:186
YSLib::HolderOperations
持有者操作。
Definition: YObject.h:265
ystdex::unsafe_any_cast
_type * unsafe_any_cast(any *p)
非安全动态泛型转换。
Definition: any.h:2356
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:46
YSLib::AllocatedHolderOperations::CreateInPlaceFunctor::operator()
auto operator()(_tParams &&... args) -> decltype(HolderOperations< _tHolder >::CreateInPlace(std::allocator_arg, Allocator, yforward(args)...))
Definition: YObject.h:408
YSLib::ValueObject::yimpl
yimpl(typename=ystdex::exclude_self_t< ValueObject, _type >)
ystdex::pvoid
enable_if_t< or_< is_object< _type >, is_void< _type > >::value, void * > pvoid(_type *p)
取 void* 类型的指针。
Definition: addressof.hpp:166
YSLib::PointerTag
指示指针的标记。
Definition: YObject.h:107
ystdex::is_allocatable
判断类型是否符合分配器要求的目标类型。
Definition: allocator.hpp:440
ystdex::cond_t
_t< cond< _tCond, _tThen, _tElse > > cond_t
Definition: meta.hpp:794
YModules.h
YSLib 用户界面模块配置文件。
YSLib::ValueObject::emplace
void emplace(_type *p, PointerTag)
Definition: YObject.h:1529
YSLib::HeldEqual< pair< _type1, _type2 >, pair< _type3, _type4 > >::are_equal
YB_ATTR_nodiscard static YB_PURE yconstfn bool are_equal(const pair< _type1, _type2 > &x, const pair< _type3, _type4 > &y)
Definition: YObject.h:236
ystdex::exclude_self_t
enable_if_t<!is_same_param< _tSelected, _tParam >::value, _type > exclude_self_t
排除选择类型的特定参数的重载。
Definition: meta.hpp:865
YSLib::GMRange::GMRange
GMRange(ValueType m, ValueType v)
构造：使用指定最大取值和值。
Definition: YObject.h:1748
YSLib::ynothrow
YB_PURE const _type size_t n ynothrow
Definition: YCoreUtilities.h:169
YSLib::ValueHolder::c
Creation c
Definition: YObject.h:576
YSLib::ValueObject::ValueObject
ValueObject(in_place_type_t< _type >, _tParams &&... args)
构造：使用对象初始化参数。
Definition: YObject.h:1144
YSLib::GMRange::max_value
ValueType max_value
最大取值。
Definition: YObject.h:1742
YSLib::AllocatedHolderOperations::CreateHolder
YB_ATTR_nodiscard static YB_PURE any CreateHolder(Creation c, const any &x, _tValue &val, _tCopyParams &&args_copy, _tMoveParams &&args_move)
Definition: YObject.h:450
YSLib::PointerHolder::p_held
holder_pointer p_held
Definition: YObject.h:863
platform::Deref
YB_PURE yconstfn auto Deref(_type &&p) -> decltype(*p)
断言并解引用非空指针。
Definition: Debug.h:547
YSLib::ImplRet
ImplRet(FetchGlobalInstance().GetGUIHostRef()) YF_API void Execute(GUIApplication &
执行程序主消息循环。
YSLib::HolderOperations::CreateInPlaceConditionally
YB_ATTR_nodiscard static YB_NORETURN any CreateInPlaceConditionally(ystdex::false_, _tParams &&...)
Definition: YObject.h:330
YSLib::RefHolder::RefHolder
RefHolder(_type &r) ynothrow
不取得所有权。
Definition: YObject.h:977
v
byte v
Definition: CharRenderer.cpp:76
ynothrowv
#define ynothrowv
YSLib 无异常抛出保证验证：有条件地使用无异常抛出规范。
Definition: ydef.h:1219
ystdex
<memory> 特性测试宏。
Definition: ydef.h:1262
YSLib::PolymorphicValueHolder::DefDeCopyMoveCtorAssignment
DefDeCopyMoveCtorAssignment(PolymorphicValueHolder) YB_ATTR_nodiscard PDefH(any
ystdex::uniformed_tags::in_place_type_t
in_place_tag(*)(empty_base< _type >) in_place_type_t
原地类型标记模板。
Definition: placement.hpp:191
YSLib::HolderOperations::CreateInPlace
static YB_ATTR_nodiscard any CreateInPlace(_tParams &&... args)
Definition: YObject.h:275
YSLib::AccessPtr
YB_ATTR_nodiscard YB_PURE observer_ptr< _type > AccessPtr(ValueNode &node) ynothrow
访问节点的指定类型对象指针。
Definition: ValueNode.h:976
YSLib::PointerHolder::pointer
decltype(traits_type::get(std::declval< const holder_pointer & >())) pointer
Definition: YObject.h:858
YSLib::_tParams
YB_ATTR_nodiscard YB_PURE typename _tParams
Definition: ValueNode.h:1294
YSLib::reset
bool reset(_type *&p) ynothrow
Definition: YShellDefinition.h:46
ystdex::examiners::equal::are_equal
static auto are_equal(_type &&x, _type2 &&y) -> decltype(bool(x==y))
Definition: examiner.hpp:53
ystdex::owns_unique
bool owns_unique(const _type &)
Definition: memory.hpp:546
ystdex::cpp2017::in_place_type
uniformed_tags::in_place_tag in_place_type(empty_base< _type >)
Definition: placement.hpp:255
ystdex::any_ops::get_allocator_ptr
@ get_allocator_ptr
取指向重绑定到 byte 的分配器对象的指针。
Definition: any.h:333
ystdex::any
基于类型擦除的动态泛型对象。
Definition: any.h:1634
ystdex::addressof
enable_if_t< has_no_overloaded_addressof< _type >::value, _type * > addressof(_type &r)
尝试对非重载 operator& 提供 constexpr 的 std::addressof 替代。
Definition: addressof.hpp:131
YSLib::ValueObject::DefDeCtor
DefDeCtor(ValueObject) template< typename _type
无参数构造。
DefCvt
#define DefCvt(_q, _t,...)
Definition: YBaseMacro.h:206
YSLib::AllocatedHolderOperations::Create
static YB_ATTR_nodiscard any Create(Creation c, const any &x, _tValue &val, _tParams &&... args)
Definition: YObject.h:422
YSLib::PointerHolder::holder_pointer
typename traits_type::holder_pointer holder_pointer
Definition: YObject.h:856
ImplExpr
#define ImplExpr(...)
简单通用函数实现。
Definition: YBaseMacro.h:96
YSLib::AllocatedHolderOperations::CreateDispatched
YB_ATTR_nodiscard static YB_PURE any CreateDispatched(Creation c, const any &, ystdex::true_, _tValue &val, _tParams &&...)
Definition: YObject.h:437
DefGetter
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:241
YSLib::ValueHolder::DefDeCtor
DefDeCtor(ValueHolder) template< typename _tParam
YSLib::AllocatedHolderOperations::Creation
IValueHolder::Creation Creation
Definition: YObject.h:418
ystdex::cpp2014::remove_reference_t
typename remove_reference< _type >::type remove_reference_t
Definition: meta.hpp:155
YSLib::DeclIEntry
YB_ATTR_nodiscard DeclIEntry(any Create(Creation, const any &) const) YB_ATTR_nodiscard YB_PURE DeclIEntry(bool Equals(const void *) const) YB_ATTR_nodiscard YB_PURE DeclIEntry(size_t OwnsCount() const ynothrow) YB_ATTR_nodiscard YB_PURE DeclIEntry(any Query(uintmax_t) const) template< typename _type > YB_ATTR_nodiscard static any CreateHolder(Creation
创建新的持有者。
platform::p
return p p
Definition: YCLib/FileSystem.h:209
YSLib::HolderOperations::CreateInPlaceWithAllocatorImpl
static YB_ATTR_nodiscard auto CreateInPlaceWithAllocatorImpl(nullptr_t, const _tAlloc &a, _tParams &&... args) -> decltype(any(std::allocator_arg, a, any_ops::use_holder, in_place_type< _tHolder >, yforward(args)...))
Definition: YObject.h:307
ystdex::any_ops::holder
抽象动态泛型持有者接口。
Definition: any.h:82
YSLib::HolderOperations::CreateInPlaceImpl
static YB_ATTR_nodiscard auto CreateInPlaceImpl(nullptr_t, _tParams &&... args) -> decltype(any(any_ops::use_holder, in_place_type< _tHolder >, yforward(args)...))
Definition: YObject.h:290
ystdex::any_ops::use_holder_t
使用持有者标记。
Definition: any.h:453
const
const Decapsulate const Decapsulate &y ynothrow ContextNode &ctx const
Definition: NPLA1Forms.cpp:1629
YSLib::PointerHolder::PointerHolder
PointerHolder(const holder_pointer &p)
Definition: YObject.h:873
platform::bool
YB_ATTR_nodiscard std::FILE *fp bool
Definition: FileIO.h:1271
DefDeMoveAssignment
#define DefDeMoveAssignment(_t)
Definition: YBaseMacro.h:191
ystdex::any_ops::use_holder
const struct ystdex::any_ops::use_holder_t use_holder
ystdex::not_
逻辑非。
Definition: integral_constant.hpp:193
ystdex::false_
bool_< false > false_
Definition: integral_constant.hpp:110
ystdex::any::get_holder
any_ops::holder * get_holder() const
Definition: any.h:2051
YSLib::HolderOperations::CreateInPlaceConditionally
static YB_ATTR_nodiscard any CreateInPlaceConditionally(std::allocator_arg_t, const _tAlloc &a, ystdex::true_, _tParams &&... args)
Definition: YObject.h:352
YSLib::vo
vo
Definition: YApplication.h:231
YSLib::AllocatedHolderOperations
带有分配器的持有者操作。
Definition: YObject.h:396
YSLib::PolymorphicAllocatorHolder
在复制初始化时传播分配器的多态值持有者。
Definition: YObject.h:733
YSLib::ValueObject::emplace
void emplace(std::allocator_arg_t, const _tAlloc &a, _tParams &&... args)
Definition: YObject.h:1517
TryRet
#define TryRet(...)
指定表达式在 try 块中求值并返回。
Definition: YBaseMacro.h:124
YSLib::ValueObject::GetObject
YB_ATTR_nodiscard YB_PURE const _type & GetObject() const
Definition: YObject.h:1350
YSLib::ValueHolder::DefDeCopyMoveCtorAssignment
DefDeCopyMoveCtorAssignment(ValueHolder) YB_ATTR_nodiscard PDefH(any
ystdex::copy_or_move
_type copy_or_move(bool copy, _type &obj)
按参数复制或转移。
Definition: utility.hpp:96
YSLib::args
YB_ATTR_nodiscard YB_PURE typename _tParams && args
Definition: ValueNode.h:1299
ynoexcept
#define ynoexcept(...)
YSLib 无异常抛出保证：指定特定的异常规范。
Definition: ydef.h:1151
YSLib::HolderOperations::CreateInPlaceConditionally
static YB_ATTR_nodiscard any CreateInPlaceConditionally(ystdex::true_, _tParams &&... args)
Definition: YObject.h:345
YSLib::AllocatorHolder::ImplI
const any &x const ImplI(IValueHolder)
Definition: YObject.h:707
NPL::get
PDefH(void, LiftTermRef, TermNode &term, const TermNode &tm) ImplExpr(NPL ref get()
Definition: NPLA.h:1737
ystdex::ref
void ref(const _type &&)=delete
ystdex::is_sharing
判断指定类型是否为已知的持有共享所有权的对象类型。
Definition: memory.hpp:154
platform_ex::Reset
unsigned long Reset(COMPtr< _iCOM > &ptr) ynothrow
Definition: Win32/include/YCLib/COM.h:406
YSLib::ValueObject::add_vh_t
ystdex::cond_t< IsValueHolder< _type >, _type, ValueHolder< _type > > add_vh_t
Definition: YObject.h:1093
YSLib::ValueObject::AccessPtr
YB_ATTR_nodiscard YB_PURE observer_ptr< _type > AccessPtr() ynothrow
访问指定类型对象指针。
Definition: YObject.h:1383
YSLib::RefHolder::value_type
ystdex::remove_reference_t< ystdex::unwrap_reference_t< _type > > value_type
Definition: YObject.h:966
ystdex::hold_same
bool hold_same(const any &x, const any &y)
判断是否持有相同对象。
Definition: any.h:2305
YSLib::ValueObject::ValueObject
ValueObject(std::allocator_arg_t, const _tAlloc &a, any_ops::use_holder_t, in_place_type_t< _tHolder >, _tParams &&... args)
构造：使用持有者和分配器。
Definition: YObject.h:1186
ystdex::cpp2017::as_const
add_const_t< _type > & as_const(_type &t)
转换 const 引用。
Definition: utility.hpp:77
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:1073
YSLib::a
YB_PURE const _type * a
Definition: YCoreUtilities.h:168
NPL::_tParam
_tParam
Definition: NPLA.h:2367
YSLib::ValueHolder::yimpl
yimpl(typename=ystdex::exclude_self_t< ValueHolder, _tParam >, typename=ystdex::enable_if_t< std::is_constructible< _type, _tParam >::value >)> inline ValueHolder(_tParam &&arg) ynoexcept(std
Definition: YObject.h:562
YSLib::ValueObject::PDefH
friend PDefH(void, swap, ValueObject &x, ValueObject &y) ynothrow ImplExpr(x.content.swap(y.content)) YB_ATTR_nodiscard PDefH(const type_info &
交换。
ystdex::and_
逻辑操作元函数。
Definition: integral_constant.hpp:151
YSLib::PolymorphicAllocatorHolder::value_type
_type value_type
Definition: YObject.h:736