YSTest: YObject.h 源文件

YSTest PreAlpha_b800_20170810 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

YObject.h
浏览该文件的文档.
1 /*
2 © 2009-2017 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 ystdex::copy_or_move;
33 #include <ystdex/any.h> // for ystdex::any_ops::holder, ystdex::boxed_value,
34 // ystdex::any, ystdex::is_sharing, ystdex::pseudo_output;
35 #include <ystdex/examiner.hpp> // for ystdex::examiners::equal_examiner;
36 #include <ystdex/operators.hpp> // for ystdex::equality_comparable;
37
38 namespace YSLib
39 {
40
42 using ystdex::type_info;
43
44
50 template<typename = void>
51 struct OwnershipTag
52 {};
53
54
59 struct MoveTag
60 {};
61
62
67 struct PointerTag
68 {};
69
70
75 template<class _tOwner, typename _type>
76 struct HasOwnershipOf : std::is_base_of<OwnershipTag<_type>, _tOwner>
77 {};
78
79
85 template<class _tHolder, typename... _tParams>
86 ystdex::any
87 CreateHolderInPlace(ystdex::true_, _tParams&&... args)
88 {
89 return ystdex::any(ystdex::any_ops::use_holder,
90 ystdex::in_place<_tHolder>, yforward(args)...);
91 }
93 template<class _tHolder, typename... _tParams>
94 YB_NORETURN ystdex::any
95 CreateHolderInPlace(ystdex::false_, _tParams&&...)
96 {
97 ystdex::throw_invalid_construction();
98 }
100
101
107 DeclDerivedI(YF_API, IValueHolder, ystdex::any_ops::holder)
113 enum Creation
114 {
121 Indirect,
130 Copy,
138 Move
139 };
140
150 DeclIEntry(bool Equals(const void*) const)
155 DeclIEntry(size_t OwnsCount() const ynothrow)
172 DeclIEntry(ystdex::any Create(Creation) const)
173
178 template<typename _type>
179 static ystdex::any
180 CreateHolder(Creation, _type&);
182 EndDecl
183
184
186
187
192 template<typename _type1, typename _type2>
193 struct HeldEqual : private ystdex::examiners::equal_examiner
194 {
195 using ystdex::examiners::equal_examiner::are_equal;
196 };
197
198 template<typename _type1, typename _type2>
199 struct HeldEqual<weak_ptr<_type1>, weak_ptr<_type2>>
200 {
201 static bool
202 are_equal(const weak_ptr<_type1>& x, const weak_ptr<_type2>& y)
203 {
204 return x == y;
205 }
206 };
207
208 template<typename _type1, typename _type2, typename _type3, typename _type4>
209 struct HeldEqual<pair<_type1, _type2>, pair<_type3, _type4>>
210 {
211 static yconstfn bool
212 are_equal(const pair<_type1, _type2>& x, const pair<_type3, _type4>& y)
213 {
214 return x.first == y.first && x.second == y.second;
215 }
216 };
218
219
226 template<typename _type1, typename _type2>
227 yconstfn bool
228 AreEqualHeld(const _type1& x, const _type2& y)
229 {
230 return HeldEqual<_type1, _type2>::are_equal(x, y);
231 }
233
234
246 template<typename _type>
247 class ValueHolder
248 : protected ystdex::boxed_value<_type>, implements IValueHolder
249 {
250 static_assert(std::is_object<_type>(), "Non-object type found.");
251 static_assert(!ystdex::is_cv<_type>(), "Cv-qualified type found.");
252
253 public:
255 using value_type = _type;
256
258
259 DefDeCtor(ValueHolder)
260 template<typename _tParam,
261 yimpl(typename = ystdex::exclude_self_t<ValueHolder, _tParam>)>
262 ValueHolder(_tParam&& arg)
263 ynoexcept(std::is_nothrow_constructible<_type, _tParam&&>())
264 : ystdex::boxed_value<_type>(yforward(arg))
265 {}
266 using ystdex::boxed_value<_type>::boxed_value;
268 DefDeCopyMoveCtorAssignment(ValueHolder)
270
271
272 PDefH(ystdex::any, Create, Creation c) const ImplI(IValueHolder)
273 ImplRet(CreateHolder(c, this->value))
274
276 PDefH(bool, Equals, const void* p) const ImplI(IValueHolder)
277 ImplRet(bool(p) && AreEqualHeld(this->value,
278 Deref(static_cast<const value_type*>(p))))
279
281 PDefH(size_t, OwnsCount, ) const ynothrow ImplI(IValueHolder)
282 ImplRet(1)
283
285 PDefH(void*, get, ) const ImplI(IValueHolder)
286 ImplRet(std::addressof(this->value))
287
289 PDefH(const type_info&, type, ) const ynothrow ImplI(IValueHolder)
290 ImplRet(ystdex::type_id<_type>())
291 };
292
293
299 template<typename _tPointer>
300 struct PointerHolderTraits : std::pointer_traits<_tPointer>
301 {
302 using holder_pointer = _tPointer;
303 using shared = ystdex::is_sharing<holder_pointer>;
304
306
307 static PDefH(size_t, count_owner, const holder_pointer& p_held) ynothrow
308 ImplRet(count_owner(shared(), p_held))
309
310 private:
311 static PDefH(size_t, count_owner, ystdex::false_,
312 const holder_pointer& p_held) ynothrow
313 ImplRet(is_owner(p_held) ? 1 : 0)
314 static PDefH(size_t, count_owner, ystdex::true_,
315 const holder_pointer& p_held) ynothrow
316 ImplRet(size_t(p_held.use_count()))
318
319 public:
321 static PDefH(auto, get, const holder_pointer& p_held)
322 ynoexcept_spec(get_raw(p_held)) -> decltype(get_raw(p_held))
323 ImplRet(get_raw(p_held))
324
326 static PDefH(bool, is_unique_owner, const holder_pointer& p_held) ynothrow
327 ImplRet(owns_unique(p_held))
328
330 static PDefH(bool, is_owner, const holder_pointer& p_held) ynothrow
331 ImplRet(is_owner(std::is_pointer<holder_pointer>(), p_held))
332
333 private:
334 static PDefH(bool, is_owner, ystdex::false_, const holder_pointer& p_held)
335 ynothrow
336 ImplRet(owns_nonnull(p_held))
337 static PDefH(bool, is_owner, ystdex::true_, const holder_pointer& p_held)
338 ynothrow
339 ImplRet(bool(p_held))
340 };
341
342
353 template<typename _type,
354 class _tTraits = PointerHolderTraits<unique_ptr<_type>>>
355 class PointerHolder : implements IValueHolder
356 {
358 static_assert(ystdex::is_decayed<_type>(), "Invalid type found.");
359
360 public:
362 using value_type = _type;
364 using traits = _tTraits;
365 using holder_pointer = typename traits::holder_pointer;
366 using pointer
367 = decltype(traits::get(std::declval<const holder_pointer&>()));
369 using shared = typename traits::shared;
370
371 protected:
372 holder_pointer p_held;
373
374 public:
376 explicit
377 PointerHolder(pointer value)
378 : p_held(value)
379 {}
381
382 PointerHolder(const holder_pointer& p)
383 : p_held(p)
384 {}
385 PointerHolder(holder_pointer&& p)
386 : p_held(std::move(p))
387 {}
388
390 PointerHolder(const PointerHolder& h)
391 : PointerHolder(h, shared())
392 {}
393
394 private:
395 PointerHolder(const PointerHolder& h, ystdex::false_)
396 : PointerHolder(ystdex::clone_monomorphic_ptr(h.p_held))
397 {}
398 PointerHolder(const PointerHolder& h, ystdex::true_)
399 : p_held(h.p_held)
400 {}
402
403 public:
405 DefDeMoveCtor(PointerHolder)
406
407
408 DefDeCopyAssignment(PointerHolder)
409 DefDeMoveAssignment(PointerHolder)
410
412 DefGetter(ynothrow, const holder_pointer&, Held, p_held)
413
415 ystdex::any
416 Create(Creation c) const ImplI(IValueHolder)
417 {
418 if(shared() && c == IValueHolder::Copy)
419 return CreateHolderInPlace<PointerHolder>(shared(), p_held);
420 if(const auto& p = traits::get(p_held))
421 return CreateHolder(c, *p);
422 ystdex::throw_invalid_construction();
423 }
424
426 PDefH(bool, Equals, const void* p) const ImplI(IValueHolder)
427 ImplRet(traits::is_owner(p_held) && p
428 ? AreEqualHeld(Deref(traits::get(p_held)),
429 Deref(static_cast<const value_type*>(p))) : !get())
430
432 PDefH(size_t, OwnsCount, ) const ynothrow ImplI(IValueHolder)
433 ImplRet(traits::count_owner(p_held))
434
436 PDefH(void*, get, ) const ImplI(IValueHolder)
437 ImplRet(traits::get(p_held))
438
440 PDefH(const type_info&, type, ) const ynothrow ImplI(IValueHolder)
441 ImplRet(traits::is_owner(p_held)
442 ? ystdex::type_id<_type>() : ystdex::type_id<void>())
443 };
444
450 template<typename _tPointer>
451 using HolderFromPointer = PointerHolder<typename PointerHolderTraits<
452 _tPointer>::element_type, PointerHolderTraits<_tPointer>>;
453
454
463 template<typename _type>
464 class RefHolder : implements IValueHolder
465 {
466 static_assert(std::is_object<_type>(), "Invalid type found.");
467
468 public:
469 using value_type
470 = ystdex::remove_reference_t<ystdex::unwrap_reference_t<_type>>;
471
472 private:
473 ValueHolder<lref<value_type>> base;
474
475 public:
477 RefHolder(_type& r)
478 : base(r)
479 {}
480 DefDeCopyMoveCtorAssignment(RefHolder)
481
482
483 PDefH(ystdex::any, Create, Creation c) const ImplI(IValueHolder)
484 ImplRet(CreateHolder(c, Ref()))
485
487 PDefH(bool, Equals, const void* p) const ImplI(IValueHolder)
488 ImplRet(bool(p) && AreEqualHeld(Deref(static_cast<const value_type*>(
489 get())), Deref(static_cast<const value_type*>(p))))
490
492 PDefH(size_t, OwnsCount, ) const ynothrow ImplI(IValueHolder)
493 ImplRet(0)
494
495 private:
497 PDefH(value_type&, Ref, ) const
498 ImplRet(Deref(static_cast<lref<value_type>*>(base.get())).get())
499
500 public:
501 PDefH(void*, get, ) const ImplI(IValueHolder)
502 ImplRet(ystdex::pvoid(std::addressof(Ref())))
503
504 PDefH(const type_info&, type, ) const ynothrow ImplI(IValueHolder)
505 ImplRet(ystdex::type_id<value_type>())
506 };
508
509 template<typename _type>
510 ystdex::any
511 IValueHolder::CreateHolder(Creation c, _type& obj)
512 {
513 switch(c)
514 {
515 case Indirect:
516 return CreateHolderInPlace<RefHolder<_type>>(ystdex::true_(),
517 ystdex::ref(obj));
518 case Copy:
519 return CreateHolderInPlace<ValueHolder<_type>>(
520 std::is_copy_constructible<_type>(), obj);
521 case Move:
522 return CreateHolderInPlace<ValueHolder<_type>>(
523 std::is_move_constructible<_type>(), std::move(obj));
524 default:
525 ystdex::throw_invalid_construction();
526 }
527 }
528
529
539 class YF_API ValueObject : private ystdex::equality_comparable<ValueObject>
540 {
541 public:
546 using Content = ystdex::any;
547
548 private:
550 Content content;
551
552 public:
558 DefDeCtor(ValueObject)
564 template<typename _type,
565 yimpl(typename = ystdex::exclude_self_t<ValueObject, _type>)>
566 ValueObject(_type&& obj)
567 : content(ystdex::any_ops::use_holder,
568 ystdex::in_place<ValueHolder<ystdex::decay_t<_type>>>, yforward(obj))
569 {}
577 template<typename _type, typename... _tParams>
578 ValueObject(ystdex::in_place_type_t<_type>, _tParams&&... args)
579 : content(ystdex::any_ops::use_holder,
580 ystdex::in_place<ValueHolder<_type>>, yforward(args)...)
581 {}
586 template<typename _tHolder, typename... _tParams>
587 ValueObject(ystdex::any_ops::use_holder_t,
588 ystdex::in_place_type_t<_tHolder>, _tParams&&... args)
589 : content(ystdex::any_ops::use_holder,
590 ystdex::in_place<_tHolder>, yforward(args)...)
591 {}
592
593 private:
598 ValueObject(const IValueHolder& h, IValueHolder::Creation c)
599 : content(h.Create(c))
600 {}
601
602 public:
607 template<typename _type>
608 ValueObject(_type& obj, OwnershipTag<>)
609 : content(ystdex::any_ops::use_holder,
610 ystdex::in_place<RefHolder<_type>>, ystdex::ref(obj))
611 {}
621 template<typename _type>
622 ValueObject(_type* p, PointerTag)
623 : content(ystdex::any_ops::use_holder,
624 ystdex::in_place<PointerHolder<_type>>, p)
625 {}
630 template<typename _type>
631 ValueObject(unique_ptr<_type>&& p, PointerTag)
632 : ValueObject(p.get(), PointerTag())
633 {
634 p.release();
635 }
637
641 DefDeCopyCtor(ValueObject)
646 DefDeMoveCtor(ValueObject)
651 DefDeDtor(ValueObject)
652
654
655 DefDeCopyAssignment(ValueObject)
656 DefDeMoveAssignment(ValueObject)
658
663 DefBoolNeg(explicit, content.has_value())
664
666
667
671 friend PDefHOp(bool, ==, const ValueObject& x, const ValueObject& y)
672 ImplRet(x.Equals(y))
674
675
677 template<typename _type>
678 friend inline bool
679 operator==(const ValueObject& x, const _type& y)
680 {
681 return x.Equals(y);
682 }
683 template<typename _type>
684 friend inline bool
685 operator==(const _type& x, const ValueObject& y)
686 {
687 return y.Equals(x);
688 }
690
692
693 template<typename _type>
694 friend inline bool
695 operator!=(const ValueObject& x, const _type& y)
696 {
697 return !(x == y);
698 }
699 template<typename _type>
700 friend inline bool
701 operator!=(const _type& x, const ValueObject& y)
702 {
703 return !(x == y);
704 }
706
707
708
713 DefGetter(const ynothrow, const Content&, Content, content)
715
716 IValueHolder*
718 GetHolderPtr() const;
723 IValueHolder&
724 GetHolderRef() const;
726
732 template<typename _type>
733 inline _type&
734 GetObject() ynothrowv
735 {
736 return Deref(ystdex::unchecked_any_cast<_type>(&content));
737 }
738 template<typename _type>
739 inline const _type&
740 GetObject() const ynothrowv
741 {
742 return Deref(ystdex::unchecked_any_cast<const _type>(&content));
743 }
745
752 template<typename _type>
753 inline _type&
754 Access()
755 {
756 return ystdex::any_cast<_type&>(content);
757 }
758 template<typename _type>
759 inline const _type&
760 Access() const
761 {
762 return ystdex::any_cast<const _type&>(content);
763 }
765
771 template<typename _type>
772 inline observer_ptr<_type>
773 AccessPtr() ynothrow
774 {
775 return YSLib::make_observer(ystdex::any_cast<_type>(&content));
776 }
777 template<typename _type>
778 inline observer_ptr<const _type>
779 AccessPtr() const ynothrow
780 {
781 return YSLib::make_observer(ystdex::any_cast<const _type>(&content));
782 }
784
790 PDefH(void, Clear, ) ynothrow
791 ImplExpr(content.reset())
792
797 PDefH(ValueObject, CopyMove, )
798 ImplRet(ystdex::copy_or_move(!OwnsUnique(), *this))
799
804 ValueObject
805 Create(IValueHolder::Creation) const;
806
815 bool
816 Equals(const ValueObject&) const;
817 template<typename _type>
818 bool
819 Equals(const _type& x) const
820 {
821 if(const auto p_holder = content.get_holder())
822 return p_holder->type() == ystdex::type_id<_type>()
823 && EqualsRaw(std::addressof(x));
824 return {};
825 }
826
828 bool
829 EqualsRaw(const void*) const;
830
835 bool
836 EqualsUnchecked(const void*) const;
838
843 PDefH(ValueObject, MakeCopy, ) const
844 ImplRet(Create(IValueHolder::Copy))
845
850 PDefH(ValueObject, MakeMove, ) const
851 ImplRet(Create(IValueHolder::Move))
852
857 PDefH(ValueObject, MakeMoveCopy, ) const
858 ImplRet(Create(OwnsUnique() ? IValueHolder::Move : IValueHolder::Copy))
859
864 PDefH(ValueObject, MakeIndirect, ) const
865 ImplRet(Create(IValueHolder::Indirect))
866
871 size_t
872 OwnsCount() const ynothrow;
873
878 PDefH(bool, OwnsUnique, ) const ynothrow
879 ImplRet(OwnsCount() == 1)
880
882
883 template<typename _type, typename... _tParams>
884 void
885 emplace(_tParams&&... args)
886 {
887 using Holder = ValueHolder<ystdex::decay_t<_type>>;
888
889 content.emplace<Holder>(ystdex::any_ops::use_holder,
890 Holder(yforward(args)...));
891 }
892 template<typename _type>
893 void
894 emplace(_type* p, PointerTag)
895 {
896 using Holder = PointerHolder<ystdex::decay_t<_type>>;
897
898 content.emplace<Holder>(ystdex::any_ops::use_holder, Holder(p));
899 }
901
906 friend PDefH(void, swap, ValueObject& x, ValueObject& y) ynothrow
907 ImplExpr(x.content.swap(y.content))
908
914 PDefH(const type_info&, type, ) const ynothrow
915 ImplRet(content.type())
916 };
917
923
925 template<typename _type>
926 inline observer_ptr<_type>
927 AccessPtr(ValueObject& vo) ynothrow
928 {
929 return vo.AccessPtr<_type>();
930 }
931 template<typename _type>
932 inline observer_ptr<const _type>
933 AccessPtr(const ValueObject& vo) ynothrow
934 {
935 return vo.AccessPtr<_type>();
936 }
938
948 template<typename _type, typename... _tParams>
949 void
950 EmplaceCallResult(ValueObject&, _type&&, ystdex::false_) ynothrow
951 {}
952 template<typename _type, typename... _tParams>
953 inline void
954 EmplaceCallResult(ValueObject& vo, _type&& res, ystdex::true_, ystdex::true_)
955 ynoexcept_spec(vo = yforward(res))
956 {
957 vo = yforward(res);
958 }
959 template<typename _type, typename... _tParams>
960 inline void
961 EmplaceCallResult(ValueObject& vo, _type&& res, ystdex::true_, ystdex::false_)
962 {
963 vo.emplace<ystdex::decay_t<_type>>(yforward(res));
964 }
965 template<typename _type, typename... _tParams>
966 inline void
967 EmplaceCallResult(ValueObject& vo, _type&& res, ystdex::true_)
968 {
969 YSLib::EmplaceCallResult(vo, yforward(res), ystdex::true_(),
970 std::is_same<ystdex::decay_t<_type>, ValueObject>());
971 }
972 template<typename _type, typename... _tParams>
973 inline void
974 EmplaceCallResult(ValueObject& vo, _type&& res)
975 {
976 YSLib::EmplaceCallResult(vo, yforward(res), ystdex::not_<
977 std::is_same<ystdex::decay_t<_type>, ystdex::pseudo_output>>());
978 }
980
981 template<typename _type, typename... _tParams>
982 _type&
983 EmplaceIfEmpty(ValueObject& vo, _tParams&&... args)
984 {
985 if(!vo)
986 {
987 vo.emplace<_type>(yforward(args)...);
988 return vo.GetObject<_type>();
989 }
990 return vo.Access<_type>();
991 }
992
994 inline PDefH(bool, HoldSame, const ValueObject& x, const ValueObject& y)
995 ImplRet(ystdex::hold_same(x.GetContent(), y.GetContent()))
997
998
999
1010 template<typename _type, class _tOwnerPointer = shared_ptr<_type>>
1011 class GDependency
1012 {
1013 public:
1014 using DependentType = _type;
1015 using PointerType = _tOwnerPointer;
1016 using ConstReferenceType = decltype(*PointerType());
1017 using ReferentType = ystdex::remove_const_t<ystdex::remove_reference_t<
1018 ConstReferenceType>>;
1019 using ReferenceType = ReferentType&;
1020
1021 private:
1022 PointerType ptr;
1023
1024 public:
1025 inline
1026 GDependency(PointerType p = PointerType())
1027 : ptr(p)
1028 {
1029 GetCopyOnWritePtr();
1030 }
1031
1032 DefDeCopyAssignment(GDependency)
1033 DefDeMoveAssignment(GDependency)
1034
1035 DefCvt(const ynothrow, ConstReferenceType, *ptr)
1036 DefCvt(ynothrow, ReferenceType, *ptr)
1037 DefCvt(const ynothrow, bool, bool(ptr))
1038
1039 DefGetter(const ynothrow, ConstReferenceType, Ref,
1040 operator ConstReferenceType())
1041 DefGetter(ynothrow, ReferenceType, Ref, operator ReferenceType())
1042 DefGetter(ynothrow, ReferenceType, NewRef, *GetCopyOnWritePtr())
1043
1045 PointerType
1046 GetCopyOnWritePtr()
1047 {
1048 if(!ptr)
1049 ptr = PointerType(new DependentType());
1050 else if(!ptr.unique())
1051 ptr = PointerType(ystdex::clone_monomorphic(Deref(ptr)));
1052 return Nonnull(ptr);
1053 }
1054
1055 PDefH(void, Reset, )
1056 ImplExpr(reset(ptr))
1057 };
1058
1059
1065 template<typename _type>
1066 class GMRange
1067 {
1068 public:
1069 using ValueType = _type;
1070
1071 protected:
1072 ValueType max_value;
1073 ValueType value;
1074
1078 GMRange(ValueType m, ValueType v)
1079 : max_value(m), value(v)
1080 {}
1081
1082 public:
1083 DefGetter(const ynothrow, ValueType, MaxValue, max_value)
1084 DefGetter(const ynothrow, ValueType, Value, value)
1085 };
1086
1087 } // namespace YSLib;
1088
1089 #endif
1090
YSLib::DeclDerivedI
DeclDerivedI(YF_API, IValueHolder, ystdex::any_ops::holder) enum Creation
带等于接口的动态泛型持有者接口。
Definition: YObject.h:107
any.h
动态泛型类型。
DefDeCopyAssignment
#define DefDeCopyAssignment(_t)
Definition: YBaseMacro.h:186
YSLib::UI::Move
移动：位置调整。
Definition: YWidgetEvent.h:382
ystdex::boxed_value
包装类类型的值的对象。
Definition: utility.hpp:252
DeclIEntry
#define DeclIEntry(_sig)
Definition: YBaseMacro.h:396
ystdex::true_
bool_< true > true_
Definition: type_traits.hpp:391
YSLib::PointerHolder::PointerHolder
PointerHolder(const PointerHolder &h, ystdex::true_)
Definition: YObject.h:398
YSLib::HeldEqual< pair< _type1, _type2 >, pair< _type3, _type4 > >::are_equal
static yconstfn bool are_equal(const pair< _type1, _type2 > &x, const pair< _type3, _type4 > &y)
Definition: YObject.h:212
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:680
v
byte v
Definition: CharRenderer.cpp:75
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
YSLib::PointerHolder::PointerHolder
PointerHolder(const PointerHolder &h)
Definition: YObject.h:390
DefBoolNeg
#define DefBoolNeg(_spec,...)
定义表示显式转换 bool 操作符及其否定的 operator! 。
Definition: YBaseMacro.h:228
ystdex::make_observer
observer_ptr< _type > make_observer(_type *p)
Definition: pointer.hpp:326
YSLib::reset
bool reset(_type *&p) ynothrow
Definition: YShellDefinition.h:46
platform::Deref
yconstfn auto Deref(_type &&p) -> decltype(*p)
断言并解引用非空指针。
Definition: Debug.h:451
YSLib::UI::y
SPos SPos y
Definition: YWidget.cpp:44
NPL::x
const TermNode &term ynothrow const TermNode &term ynothrow const TermNode &term ynothrow TermNode &term const TermNode &term ValueNode &node const ValueNode &node const _type & x
Definition: SContext.h:94
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
ystdex::any_ops::holder
抽象动态泛型持有者接口。
Definition: any.h:66
YSLib::HeldEqual
判断相等。
Definition: YObject.h:193
YSLib::ValueObject::AccessPtr
observer_ptr< const _type > AccessPtr() const ynothrow
Definition: YObject.h:779
ystdex::false_
bool_< false > false_
Definition: type_traits.hpp:392
ystdex::not_
Definition: type_traits.hpp:456
YSLib::AreEqualHeld
yconstfn bool AreEqualHeld(const _type1 &x, const _type2 &y)
判断动态泛型的持有值是否相等。
Definition: YObject.h:228
YSLib::PointerHolder::PointerHolder
PointerHolder(const holder_pointer &p)
Definition: YObject.h:382
ynoexcept_spec
#define ynoexcept_spec(...)
表达式 noexcept 异常规范。
Definition: ydef.h:794
YSLib::ValueObject::ValueObject
ValueObject(unique_ptr< _type > &&p, PointerTag)
构造：使用对象 unique_ptr 指针。
Definition: YObject.h:631
DefDeMoveCtor
#define DefDeMoveCtor(_t)
Definition: YBaseMacro.h:167
ImplI
#define ImplI(...)
Definition: YBaseMacro.h:388
YSLib::RefHolder::value_type
ystdex::remove_reference_t< ystdex::unwrap_reference_t< _type >> value_type
Definition: YObject.h:470
ystdex::is_cv
判断指定类型是否为 const 或 volatile 类型。
Definition: type_traits.hpp:882
DefDeCopyMoveCtorAssignment
#define DefDeCopyMoveCtorAssignment(_t)
Definition: YBaseMacro.h:202
CHRLib::args
_tParams && args
Definition: CharacterProcessing.h:538
YSLib::ValueObject::ValueObject
ValueObject(ystdex::in_place_type_t< _type >, _tParams &&...args)
构造：使用对象初始化参数。
Definition: YObject.h:578
ystdex::owns_nonnull
bool owns_nonnull(_type *const &p)
Definition: memory.hpp:609
YSLib::RefHolder::RefHolder
RefHolder(_type &r)
不取得所有权。
Definition: YObject.h:477
YSLib::PointerHolder::shared
typename traits::shared shared
Definition: YObject.h:369
ystdex::lref
左值引用包装。
Definition: ref.hpp:74
YSLib::ValueObject::ValueObject
ValueObject(const IValueHolder &h, IValueHolder::Creation c)
构造：使用持有者和动态创建选项。
Definition: YObject.h:598
ystdex::any::type
const type_info & type() const
Definition: any.h:1024
YSLib::PDefH
PDefH(Environment &, FetchEnvironment,) ImplRet(FetchGlobalInstance().GetEnvironmentRef()) inline PDefH(GUIHost &
取单一环境对象引用。
ystdex::any
基于类型擦除的动态泛型对象。
Definition: any.h:845
YSLib::ValueObject::AccessPtr
observer_ptr< _type > AccessPtr(ValueObject &vo) ynothrow
Definition: YObject.h:927
DefDeMoveAssignment
#define DefDeMoveAssignment(_t)
Definition: YBaseMacro.h:191
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:243
ystdex::copy_or_move
_type copy_or_move(bool copy, _type &obj)
按参数复制或转移。
Definition: utility.hpp:185
YSLib::ValueObject
值类型对象类。
Definition: YObject.h:539
ystdex::cpp2014::decay_t
typename decay< _type >::type decay_t
Definition: type_traits.hpp:340
YSLib::GMRange::max_value
ValueType max_value
最大取值。
Definition: YObject.h:1072
YSLib::GMRange::value
ValueType value
值。
Definition: YObject.h:1073
YSLib::ValueObject::Equals
bool Equals(const _type &x) const
Definition: YObject.h:819
ystdex
特性测试宏。
Definition: ydef.h:822
YSLib::ValueHolder::yimpl
yimpl(typename=ystdex::exclude_self_t< ValueHolder, _tParam >)> ValueHolder(_tParam &&arg) ynoexcept(std
Definition: YObject.h:261
DefDeDtor
#define DefDeDtor(_t)
Definition: YBaseMacro.h:177
YSLib::PointerHolder::PointerHolder
PointerHolder(holder_pointer &&p)
Definition: YObject.h:385
YSLib::PointerHolder::PointerHolder
PointerHolder(const PointerHolder &h, ystdex::false_)
Definition: YObject.h:395
YSLib::ValueHolder
带等于接口的值类型动态泛型持有者。
Definition: YObject.h:247
ystdex::details::any_emplace::emplace
void emplace(_tParams &&...args)
Definition: any.h:800
ystdex::examiners::equal::are_equal
static auto are_equal(_type1 &&x, _type2 &&y) -> decltype(bool(x==y))
Definition: examiner.hpp:53
YF_API
#define YF_API
Definition: Platform.h:56
ystdex::boxed_value::boxed_value
boxed_value()
Definition: utility.hpp:260
EndDecl
#define EndDecl
Definition: YBaseMacro.h:398
YSLib::PointerHolder::traits
_tTraits traits
Definition: YObject.h:364
ystdex::in_place
in_place_tag in_place(empty_base<>)
原地标记函数。
Definition: placement.hpp:85
YSLib::ValueObject::content
Content content
Definition: YObject.h:550
YSLib::ynothrow
YB_PURE const _type size_t n ynothrow
Definition: YCoreUtilities.h:168
YSLib::RefHolder
带等于接口的引用动态泛型持有者。
Definition: YObject.h:464
ystdex::is_decayed
判断指定类型是否已退化。
Definition: type_traits.hpp:906
YSLib::ValueHolder::DefDeCtor
DefDeCtor(ValueHolder) template< typename _tParam
operators.hpp
重载操作符。
ynothrowv
#define ynothrowv
YSLib 无异常抛出保证验证：有条件地使用无异常抛出规范。
Definition: ydef.h:786
YSLib::HasOwnershipOf
标签类型元运算。
Definition: YObject.h:76
YSLib::RefHolder::base
ValueHolder< lref< value_type > > base
Definition: YObject.h:473
YSLib::PointerHolderTraits
指针持有者特征。
Definition: YObject.h:300
ystdex::clone_monomorphic_ptr
auto clone_monomorphic_ptr(const _tPointer &p) -> decltype(ystdex::clone_monomorphic(*p))
若指针非空，使用 new 复制指针指向的对象。
Definition: memory.hpp:1091
YSLib::ValueObject::ValueObject
ValueObject(ystdex::any_ops::use_holder_t, ystdex::in_place_type_t< _tHolder >, _tParams &&...args)
构造：使用持有者。
Definition: YObject.h:587
platform_ex::Reset
unsigned long Reset(COMPtr< _iCOM > &ptr) ynothrow
Definition: COM.h:406
ystdex::exclude_self_t
enable_if_t<!is_same< _tClass &, decay_t< _tParam > & >::value, _type > exclude_self_t
移除选择类类型的特定重载避免构造模板和复制/转移特殊成员函数冲突。
Definition: type_traits.hpp:748
ystdex::pseudo_output
伪输出对象。
Definition: ref.hpp:307
YSLib::PointerHolder::p_held
holder_pointer p_held
Definition: YObject.h:372
ystdex::cpp2014::remove_reference_t
typename remove_reference< _type >::type remove_reference_t
Definition: type_traits.hpp:299
YSLib::ValueObject::EmplaceCallResult
void EmplaceCallResult(ValueObject &, _type &&, ystdex::false_) ynothrow
以指定参数按需构造替换值。
Definition: YObject.h:950
YSLib::CreateHolderInPlace
ystdex::any CreateHolderInPlace(ystdex::true_, _tParams &&...args)
第一个参数指定的选项创建擦除类型的持有者或抛出异常。
Definition: YObject.h:87
std
Definition: memory.hpp:1183
YSLib::ImplRet
ImplRet(FetchGlobalInstance().GetGUIHostRef()) YF_API void Execute(GUIApplication &
执行程序主消息循环。
YSLib::operator!=
bool operator!=(const shared_ptr< _type > &sp, _type *p)
比较： shared_ptr 左值和内建指针类型的不等关系。
Definition: YShellDefinition.h:84
DefGetter
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:241
ystdex::type_id
const type_info & type_id()
Definition: typeinfo.h:149
platform::Nonnull
_type && Nonnull(_type &&p) ynothrowv
断言并返回非空参数。
Definition: Debug.h:422
ystdex::owns_unique
bool owns_unique(const _type &)
Definition: memory.hpp:641
ystdex::in_place_type_t
in_place_tag(&)(empty_base< _type >) in_place_type_t
原地类型标记模板。
Definition: placement.hpp:73
ystdex::any_ops::use_holder
const struct ystdex::any_ops::use_holder_t use_holder
DefCvt
#define DefCvt(_q, _t,...)
Definition: YBaseMacro.h:206
YSLib::ValueObject::Access
const _type & Access() const
Definition: YObject.h:760
YSLib::ValueObject::GetObject
const _type & GetObject() const ynothrowv
Definition: YObject.h:740
YSLib::ValueObject::ValueObject
ValueObject(_type *p, PointerTag)
构造：使用对象指针。
Definition: YObject.h:622
YB_NORETURN
#define YB_NORETURN
指定无返回值函数。
Definition: ydef.h:504
YSLib::GMRange::GMRange
GMRange(ValueType m, ValueType v)
构造：使用指定最大取值和值。
Definition: YObject.h:1078
YModules.h
DefDeCopyCtor
#define DefDeCopyCtor(_t)
Definition: YBaseMacro.h:162
ystdex::cpp2014::remove_const_t
typename remove_const< _type >::type remove_const_t
ISO C++ 14 兼容类型操作别名。
Definition: type_traits.hpp:280
ystdex::throw_invalid_construction
void throw_invalid_construction()
Definition: ystdex/exception.cpp:49
YSLib::PointerHolderTraits::holder_pointer
_tPointer holder_pointer
Definition: YObject.h:302
YSLib::MoveTag
指示转移的标记。
Definition: YObject.h:59
YSLib::ValueObject::ValueObject
ValueObject(_type &obj, OwnershipTag<>)
构造：使用无所有权的引用。
Definition: YObject.h:608
YSLib::ValueObject::Access
_type & Access()
访问指定类型对象。 空实例或类型检查失败 。
Definition: YObject.h:754
YSLib::GMRange< float >::ValueType
float ValueType
Definition: YObject.h:1069
ystdex::get_raw
_type * get_raw(_type *const &p)
Definition: memory.hpp:544
ystdex::pvoid
enable_if_t< or_< is_object< _type >, is_void< _type > >::value, void * > pvoid(_type *p)
取 void* 类型的指针。
Definition: addressof.hpp:101
CHRLib::c
c
Definition: CharacterProcessing.h:81
YSLib::PointerTag
指示指针的标记。
Definition: YObject.h:67
implements
#define implements
Definition: YBaseMacro.h:352
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 传递对应参数。
Definition: ydef.h:995
examiner.hpp
C++ 类型操作检测。
YSLib::PointerHolder::PointerHolder
PointerHolder(pointer value)
取得所有权。
Definition: YObject.h:377
ystdex::is_sharing
判断指定类型是否为已知的持有共享所有权的对象类型。
Definition: memory.hpp:366
YSLib::PointerHolder::value_type
_type value_type
Definition: YObject.h:362
ystdex::clone_monomorphic
_type * clone_monomorphic(const _type &v)
使用 new 复制对象。
Definition: memory.hpp:1075
YSLib::OwnershipTag
指定对参数指定类型的成员具有所有权的标签。
Definition: YObject.h:51
YSLib::PointerHolder
带等于接口的指针类型动态泛型持有者。
Definition: YObject.h:355
YSLib::vo
vo
Definition: YApplication.h:231
YSLib::GMRange
判断是否持有相同对象。
Definition: YObject.h:1066
YSLib::HeldEqual< weak_ptr< _type1 >, weak_ptr< _type2 > >::are_equal
static bool are_equal(const weak_ptr< _type1 > &x, const weak_ptr< _type2 > &y)
Definition: YObject.h:202
ystdex::any::get_holder
any_ops::holder * get_holder() const
Definition: any.h:963
YSLib::ValueHolder::value_type
_type value_type
Definition: YObject.h:255
ystdex::ref
lref< _type > ref(_type &t)
构造引用包装。
Definition: ref.hpp:132
YSLib::ValueObject::emplace
void emplace(_type *p, PointerTag)
Definition: YObject.h:894
YSLib::PointerHolder::pointer
decltype(traits::get(std::declval< const holder_pointer & >())) pointer
Definition: YObject.h:367
ystdex::any_ops::use_holder_t
使用持有者标记。
Definition: any.h:268
YSLib::ValueObject::AccessPtr
observer_ptr< _type > AccessPtr() ynothrow
访问指定类型对象指针。
Definition: YObject.h:773
ystdex::boxed_value::value
_type value
Definition: utility.hpp:255
ynoexcept
#define ynoexcept(...)
YSLib 无异常抛出保证：指定特定的异常规范。
Definition: ydef.h:746
CHRLib::p
const auto p(d)
YSLib::operator==
bool operator==(const shared_ptr< _type > &sp, _type *p)
比较： shared_ptr 和内建指针类型的相等关系。
Definition: YShellDefinition.h:62
YSLib::swap
void swap(ValueNode &x, ValueNode &y) ynothrow
Definition: ValueNode.cpp:73
ystdex::details::get
get())
Definition: cast.hpp:102