28 #ifndef YSL_INC_Core_yobject_h_
29 #define YSL_INC_Core_yobject_h_ 1
33 #include "../Adaptor/ycont.h"
70 template<
class _tOwner,
typename _type>
72 std::is_base_of<OwnershipTag<_type>, _tOwner>::value>
99 template<typename _type>
102 static_assert(std::is_object<_type>::value,
"Non-object type found.");
103 static_assert(!(std::is_const<_type>::value
104 || std::is_volatile<_type>::value),
"Cv-qualified type found.");
120 : held(std::move(value))
128 ImplI(IValueHolder)
bool
129 operator==(const IValueHolder& obj)
const override
132 static_cast<const ValueHolder&>(obj).held);
138 ImplI(IValueHolder)
void*
141 return std::addressof(held);
145 ImplI(IValueHolder) const std::type_info&
148 return typeid(_type);
159 template<
typename _type>
162 static_assert(std::is_object<_type>::value,
"Invalid type found.");
197 ImplI(IValueHolder)
bool
198 operator==(const IValueHolder& obj)
const
201 *static_cast<const PointerHolder&>(obj).p_held);
207 ImplI(IValueHolder)
void*
214 ImplI(IValueHolder) const std::type_info&
217 return p_held ?
typeid(_type) :
typeid(
void);
249 template<typename _type, typename = typename
250 std::enable_if<!std::is_same<_type&,
ValueObject&>::value,
int>::type>
253 typename ystdex::remove_rcv<_type>::type>>(
yforward(obj)))
261 template<
typename _type>
311 template<typename _type>
313 GetMutableObject()
const
315 YAssert(
bool(content),
"Null pointer found.");
316 YAssert(content.type() ==
typeid(_type),
"Invalid type found.");
318 return *
static_cast<_type*
>(content.get());
322 template<
typename _type>
326 return GetMutableObject<_type>();
328 template<
typename _type>
332 return GetMutableObject<_type>();
343 template<typename _type>
349 template<
typename _type>
362 template<
typename _type>
368 template<
typename _type>
397 template<typename _type>
416 template<
typename _type,
class _tOwnerPo
inter = shared_ptr<_type>>
423 typedef typename std::remove_const<typename std::remove_reference<
445 DefGetter(const ynothrow, ConstReferenceType, Ref,
446 operator ConstReferenceType())
447 DefGetter(ynothrow, ReferenceType, Ref, operator ReferenceType())
448 DefGetter(ynothrow, ReferenceType, NewRef, *GetCopyOnWritePtr())
455 else if(!ptr.unique())
458 YAssert(
bool(ptr),
"Null pointer found.");
476 template<
typename _type>
490 : max_value(m), value(v)