91 static const unsigned int _LocalFlag = 1 << 0;
92 static const unsigned int _TrivialCopyFlag = 1 << 1;
93 static const unsigned int _ProxyFlag = 1 << 2;
94 static const unsigned int _AllFlags =
95 _LocalFlag | _TrivialCopyFlag | _ProxyFlag;
99 explicit _Counted(T
const &obj) : _obj(obj) {
102 explicit _Counted(T &&obj) : _obj(std::move(obj)) {
105 bool IsUnique()
const {
return _refCount == 1; }
106 T
const &Get()
const {
return _obj; }
107 T &GetMutable() {
return _obj; }
111 mutable std::atomic<int> _refCount;
113 friend inline void TfDelegatedCountIncrement(_Counted
const *d) {
114 d->_refCount.fetch_add(1, std::memory_order_relaxed);
116 friend inline void TfDelegatedCountDecrement(_Counted
const *d)
noexcept {
117 if (d->_refCount.fetch_sub(1, std::memory_order_release) == 1) {
118 std::atomic_thread_fence(std::memory_order_acquire);
127 static const size_t _MaxLocalSize =
sizeof(
void*);
128 typedef std::aligned_storage<
129 _MaxLocalSize, _MaxLocalSize>::type _Storage;
132 using _IsTriviallyCopyable = std::integral_constant<bool,
133 std::is_trivially_default_constructible_v<T> &&
134 std::is_trivially_copyable_v<T> &&
135 std::is_trivially_copy_assignable_v<T> &&
136 std::is_trivially_destructible_v<T>>;
141 using _UsesLocalStore = std::integral_constant<bool,
142 (
sizeof(T) <=
sizeof(_Storage)) &&
143 VtValueTypeHasCheapCopy<T>::value &&
144 std::is_nothrow_move_constructible<T>::value &&
145 std::is_nothrow_move_assignable<T>::value>;
150 struct alignas(8) _TypeInfo {
152 using _CopyInitFunc = void (*)(_Storage
const &, _Storage &);
153 using _DestroyFunc = void (*)(_Storage &);
154 using _MoveFunc = void (*)(_Storage &, _Storage &);
155 using _CanHashFunc = bool (*)(_Storage
const &);
156 using _HashFunc = size_t (*)(_Storage
const &);
157 using _EqualFunc = bool (*)(_Storage
const &, _Storage
const &);
158 using _EqualPtrFunc = bool (*)(_Storage
const &,
void const *);
159 using _MakeMutableFunc = void (*)(_Storage &);
161 using _GetValueRefFunc =
VtValueRef (*)(_Storage
const &, bool);
162 using _StreamOutFunc =
163 std::ostream & (*)(_Storage
const &, std::ostream &);
164 using _GetTypeidFunc = std::type_info
const & (*)(_Storage
const &);
165 using _IsArrayValuedFunc = bool (*)(_Storage
const &);
166 using _GetElementTypeidFunc =
167 std::type_info
const & (*)(_Storage
const &);
168 using _GetShapeDataFunc =
const Vt_ShapeData* (*)(_Storage
const &);
169 using _GetNumElementsFunc = size_t (*)(_Storage
const &);
170 using _ProxyHoldsTypeFunc = bool (*)(_Storage
const &, std::type_info
const &);
171 using _GetProxiedTypeFunc =
TfType (*)(_Storage
const &);
172 using _GetProxiedTypeidFunc =
173 std::type_info
const & (*)(_Storage
const &);
174 using _GetProxiedObjPtrFunc =
void const *(*)(_Storage
const &);
175 using _GetProxiedAsVtValueFunc =
VtValue (*)(_Storage
const &);
178 constexpr _TypeInfo(
const std::type_info &ti,
179 const std::type_info &elementTi,
186 _CopyInitFunc copyInit,
187 _DestroyFunc destroy,
189 _CanHashFunc canHash,
192 _EqualPtrFunc equalPtr,
193 _MakeMutableFunc makeMutable,
194 _GetPyObjFunc getPyObj,
195 _GetValueRefFunc getValueRef,
196 _StreamOutFunc streamOut,
197 _GetTypeidFunc getTypeid,
198 _IsArrayValuedFunc isArrayValued,
199 _GetElementTypeidFunc getElementTypeid,
200 _GetShapeDataFunc getShapeData,
201 _GetNumElementsFunc getNumElements,
202 _ProxyHoldsTypeFunc proxyHoldsType,
203 _GetProxiedTypeFunc getProxiedType,
204 _GetProxiedTypeidFunc getProxiedTypeid,
205 _GetProxiedObjPtrFunc getProxiedObjPtr,
206 _GetProxiedAsVtValueFunc getProxiedAsVtValue)
208 , elementTypeInfo(elementTi)
209 , knownTypeIndex(knownTypeIndex)
212 , isHashable(isHashable)
213 , canComposeOver(canComposeOver)
214 , canTransform(canTransform)
216 , _copyInit(copyInit)
222 , _equalPtr(equalPtr)
223 , _makeMutable(makeMutable)
224 , _getPyObj(getPyObj)
225 , _getValueRef(getValueRef)
226 , _streamOut(streamOut)
227 , _getTypeid(getTypeid)
228 , _isArrayValued(isArrayValued)
229 , _getElementTypeid(getElementTypeid)
230 , _getShapeData(getShapeData)
231 , _getNumElements(getNumElements)
232 , _proxyHoldsType(proxyHoldsType)
233 , _getProxiedType(getProxiedType)
234 , _getProxiedTypeid(getProxiedTypeid)
235 , _getProxiedObjPtr(getProxiedObjPtr)
236 , _getProxiedAsVtValue(getProxiedAsVtValue)
240 void CopyInit(_Storage
const &src, _Storage &dst)
const {
243 void Destroy(_Storage &storage)
const {
246 void Move(_Storage &src, _Storage &dst)
const noexcept {
249 bool CanHash(_Storage
const &storage)
const {
250 return _canHash(storage);
252 size_t Hash(_Storage
const &storage)
const {
253 return _hash(storage);
255 bool Equal(_Storage
const &lhs, _Storage
const &rhs)
const {
256 return _equal(lhs, rhs);
258 bool EqualPtr(_Storage
const &lhs,
void const *rhs)
const {
259 return _equalPtr(lhs, rhs);
261 void MakeMutable(_Storage &storage)
const {
262 _makeMutable(storage);
265 return _getPyObj(storage);
267 inline VtValueRef GetValueRef(_Storage
const &storage,
269 std::ostream &StreamOut(_Storage
const &storage,
270 std::ostream &out)
const {
271 return _streamOut(storage, out);
274 return _isArrayValued(storage);
277 return _getElementTypeid(storage);
279 std::type_info
const &
GetTypeid(_Storage
const &storage)
const {
280 return _getTypeid(storage);
282 const Vt_ShapeData* GetShapeData(_Storage
const &storage)
const {
283 return _getShapeData(storage);
285 size_t GetNumElements(_Storage
const &storage)
const {
286 return _getNumElements(storage);
288 bool ProxyHoldsType(_Storage
const &storage,
289 std::type_info
const &t)
const {
290 return _proxyHoldsType(storage, t);
292 TfType GetProxiedType(_Storage
const &storage)
const {
293 return _getProxiedType(storage);
295 std::type_info
const &GetProxiedTypeid(_Storage
const &storage)
const {
296 return _getProxiedTypeid(storage);
298 VtValue GetProxiedAsVtValue(_Storage
const &storage)
const {
299 return _getProxiedAsVtValue(storage);
301 void const *GetProxiedObjPtr(_Storage
const &storage)
const {
302 return _getProxiedObjPtr(storage);
305 const std::type_info &typeInfo;
306 const std::type_info &elementTypeInfo;
315 _CopyInitFunc _copyInit;
316 _DestroyFunc _destroy;
318 _CanHashFunc _canHash;
321 _EqualPtrFunc _equalPtr;
322 _MakeMutableFunc _makeMutable;
323 _GetPyObjFunc _getPyObj;
324 _GetValueRefFunc _getValueRef;
325 _StreamOutFunc _streamOut;
326 _GetTypeidFunc _getTypeid;
327 _IsArrayValuedFunc _isArrayValued;
328 _GetElementTypeidFunc _getElementTypeid;
329 _GetShapeDataFunc _getShapeData;
330 _GetNumElementsFunc _getNumElements;
331 _ProxyHoldsTypeFunc _proxyHoldsType;
332 _GetProxiedTypeFunc _getProxiedType;
333 _GetProxiedTypeidFunc _getProxiedTypeid;
334 _GetProxiedObjPtrFunc _getProxiedObjPtr;
335 _GetProxiedAsVtValueFunc _getProxiedAsVtValue;
343 struct _NonArrayHelper
345 static const Vt_ShapeData* GetShapeData(T
const &) {
return NULL; }
346 static size_t GetNumElements(T
const &) {
return 0; }
347 constexpr static std::type_info
const &GetElementTypeid() {
352 template <
class Array>
353 struct _IsArrayHelper
355 static const Vt_ShapeData* GetShapeData(Array
const &obj) {
356 return obj._GetShapeData();
358 static size_t GetNumElements(Array
const &obj) {
361 constexpr static std::type_info
const &GetElementTypeid() {
362 return typeid(
typename Array::ElementType);
367 template <
class ArrayEdit>
368 struct _IsArrayEditHelper : _NonArrayHelper<ArrayEdit>
370 constexpr static std::type_info
const &GetElementTypeid() {
371 return typeid(
typename ArrayEdit::ElementType);
379 using _ArrayHelper = TfConditionalType<
381 TfConditionalType<VtIsArrayEdit<T>::value,
382 _IsArrayEditHelper<T>, _NonArrayHelper<T>>
388 _TypedProxyEqualityImpl(T
const &a, T
const &b,
int) ->
decltype(a == b) {
392 template <
class NoEqual>
394 _TypedProxyEqualityImpl(NoEqual
const &a, NoEqual
const &b,
long) {
395 return VtGetProxiedObject(a) == VtGetProxiedObject(b);
400 _ErasedProxyEqualityImpl(T
const &a, T
const &b,
int) ->
decltype(a == b) {
404 template <
class NoEqual>
406 _ErasedProxyEqualityImpl(NoEqual
const &a, NoEqual
const &b,
long) {
407 return *VtGetErasedProxiedVtValue(a) == *VtGetErasedProxiedVtValue(b);
412 struct _TypedProxyHelper
414 using ProxiedType =
typename VtGetProxiedType<T>::type;
417 static size_t Hash(T
const &obj) {
420 static bool Equal(T
const &a, T
const &b) {
425 return _TypedProxyEqualityImpl(a, b, 0);
428#ifdef PXR_PYTHON_SUPPORT_ENABLED
429 ProxiedType
const &p = VtGetProxiedObject(obj);
431 return pxr_boost::python::api::object(p);
437 static std::ostream &StreamOut(T
const &obj, std::ostream &out) {
438 return VtStreamOut(VtGetProxiedObject(obj), out);
440 static Vt_ShapeData
const *GetShapeData(T
const &obj) {
441 return _ArrayHelper<ProxiedType>::GetShapeData(
442 VtGetProxiedObject(obj));
444 static size_t GetNumElements(T
const &obj) {
445 return _ArrayHelper<ProxiedType>::GetNumElements(
446 VtGetProxiedObject(obj));
451 static std::type_info
const &
GetTypeid(T
const &) {
452 return typeid(ProxiedType);
455 return _ArrayHelper<ProxiedType>::GetElementTypeid();
457 static VtValue GetProxiedAsVtValue(T
const &obj) {
458 return VtValue(VtGetProxiedObject(obj));
460 static bool HoldsType(T
const &tp, std::type_info
const &query) {
463 static TfType GetTfType(T
const &tp) {
466 static void const *GetObjPtr(T
const &tp) {
467 return static_cast<void const *
>(&VtGetProxiedObject(tp));
472 template <
class ErasedProxy>
473 struct _ErasedProxyHelper
475 static bool CanHash(ErasedProxy
const &proxy) {
476 return VtGetErasedProxiedVtValue(proxy)->CanHash();
478 static size_t Hash(ErasedProxy
const &proxy) {
479 return VtGetErasedProxiedVtValue(proxy)->GetHash();
481 static bool Equal(ErasedProxy
const &a, ErasedProxy
const &b) {
486 return _ErasedProxyEqualityImpl(a, b, 0);
489#ifdef PXR_PYTHON_SUPPORT_ENABLED
490 VtValue const *val = VtGetErasedProxiedVtValue(obj);
492 return pxr_boost::python::api::object(*val);
497 static VtValueRef GetValueRef(ErasedProxy
const &obj);
498 static std::ostream &
499 StreamOut(ErasedProxy
const &obj, std::ostream &out) {
500 return VtStreamOut(obj, out);
502 static Vt_ShapeData
const *GetShapeData(ErasedProxy
const &obj) {
503 return VtGetErasedProxiedVtValue(obj)->_GetShapeData();
505 static size_t GetNumElements(ErasedProxy
const &obj) {
506 return VtGetErasedProxiedVtValue(obj)->_GetNumElements();
509 return VtGetErasedProxiedVtValue(obj)->IsArrayValued();
511 static std::type_info
const &
GetTypeid(ErasedProxy
const &obj) {
512 return VtGetErasedProxiedVtValue(obj)->GetTypeid();
515 return VtGetErasedProxiedVtValue(obj)->GetElementTypeid();
517 static VtValue GetProxiedAsVtValue(ErasedProxy
const &ep) {
518 return *VtGetErasedProxiedVtValue(ep);
521 HoldsType(ErasedProxy
const &ep, std::type_info
const &query) {
522 return VtErasedProxyHoldsType(ep, query);
524 static TfType GetTfType(ErasedProxy
const &ep) {
525 return VtGetErasedProxiedTfType(ep);
527 static void const *GetObjPtr(ErasedProxy
const &ep) {
528 VtValue const *val = VtGetErasedProxiedVtValue(ep);
529 return val ? val->_GetProxiedObjPtr() :
nullptr;
536 template <
class T,
class Container,
class Derived>
537 struct _TypeInfoImpl :
public _TypeInfo
539 static const bool IsLocal = _UsesLocalStore<T>::value;
540 static const bool HasTrivialCopy = _IsTriviallyCopyable<T>::value;
541 static const bool IsProxy = VtIsValueProxy<T>::value;
543 using ProxyHelper = TfConditionalType<
544 VtIsErasedValueProxy<T>::value,
545 _ErasedProxyHelper<T>, _TypedProxyHelper<T>>;
547 using This = _TypeInfoImpl;
549 constexpr _TypeInfoImpl()
550 : _TypeInfo(
typeid(T),
551 _ArrayHelper<T>::GetElementTypeid(),
552 Vt_KnownValueTypeDetail::GetIndex<T>(),
573 &This::_IsArrayValued,
574 &This::_GetElementTypeid,
575 &This::_GetShapeData,
576 &This::_GetNumElements,
579 &This::_ProxyHoldsType,
580 &This::_GetProxiedType,
581 &This::_GetProxiedTypeid,
582 &This::_GetProxiedObjPtr,
583 &This::_GetProxiedAsVtValue)
588 static T
const &GetObj(_Storage
const &storage) {
589 return Derived::_GetObj(_Container(storage));
592 static T &GetMutableObj(_Storage &storage) {
593 return Derived::_GetMutableObj(_Container(storage));
597 static void InitObj(Arg &&objSrc, _Storage &dst) {
598 Derived::_Place(&_Container(dst), std::forward<Arg>(objSrc));
602 static_assert(
sizeof(Container) <=
sizeof(_Storage),
603 "Container size cannot exceed storage size.");
607 static void _CopyInit(_Storage
const &src, _Storage &dst) {
608 new (&_Container(dst)) Container(_Container(src));
611 static void _Destroy(_Storage &storage) {
612 _Container(storage).~Container();
615 static bool _CanHash(_Storage
const &storage) {
616 return ProxyHelper::CanHash(GetObj(storage));
619 static size_t _Hash(_Storage
const &storage) {
620 return ProxyHelper::Hash(GetObj(storage));
623 static bool _Equal(_Storage
const &lhs, _Storage
const &rhs) {
627 return ProxyHelper::Equal(GetObj(lhs), GetObj(rhs));
630 static bool _EqualPtr(_Storage
const &lhs,
void const *rhs) {
634 return ProxyHelper::Equal(
635 GetObj(lhs), *
static_cast<T
const *
>(rhs));
638 static void _Move(_Storage &src, _Storage &dst)
noexcept {
639 new (&_Container(dst)) Container(std::move(_Container(src)));
643 static void _MakeMutable(_Storage &storage) {
644 GetMutableObj(storage);
648 return ProxyHelper::GetPyObj(GetObj(storage));
651 static VtValueRef _GetValueRef(_Storage
const &storage,
bool rvalue);
653 static std::ostream &_StreamOut(
654 _Storage
const &storage, std::ostream &out) {
655 return ProxyHelper::StreamOut(GetObj(storage), out);
658 static std::type_info
const &_GetTypeid(_Storage
const &storage) {
659 return ProxyHelper::GetTypeid(GetObj(storage));
662 static bool _IsArrayValued(_Storage
const &storage) {
663 return ProxyHelper::IsArrayValued(GetObj(storage));
666 static std::type_info
const &
667 _GetElementTypeid(_Storage
const &storage) {
668 return ProxyHelper::GetElementTypeid(GetObj(storage));
671 static const Vt_ShapeData* _GetShapeData(_Storage
const &storage) {
672 return ProxyHelper::GetShapeData(GetObj(storage));
675 static size_t _GetNumElements(_Storage
const &storage) {
676 return ProxyHelper::GetNumElements(GetObj(storage));
680 _ProxyHoldsType(_Storage
const &storage, std::type_info
const &t) {
681 return ProxyHelper::HoldsType(GetObj(storage), t);
685 _GetProxiedType(_Storage
const &storage) {
686 return ProxyHelper::GetTfType(GetObj(storage));
689 static std::type_info
const &
690 _GetProxiedTypeid(_Storage
const &storage) {
691 return ProxyHelper::GetTypeid(GetObj(storage));
695 _GetProxiedObjPtr(_Storage
const &storage) {
696 return ProxyHelper::GetObjPtr(GetObj(storage));
700 _GetProxiedAsVtValue(_Storage
const &storage) {
701 return ProxyHelper::GetProxiedAsVtValue(GetObj(storage));
707 static Container &_Container(_Storage &storage) {
709 return *
reinterpret_cast<Container *
>(&storage);
711 static Container
const &_Container(_Storage
const &storage) {
713 return *
reinterpret_cast<Container
const *
>(&storage);
721 struct _LocalTypeInfo : _TypeInfoImpl<
727 constexpr _LocalTypeInfo()
728 : _TypeInfoImpl<T, T, _LocalTypeInfo<T>>()
732 static T &_GetMutableObj(T &obj) {
return obj; }
733 static T
const &_GetObj(T
const &obj) {
return obj; }
736 static void _Place(T *dst, Arg &&arg) {
737 new (dst) T(std::forward<Arg>(arg));
745 struct _RemoteTypeInfo : _TypeInfoImpl<
747 TfDelegatedCountPtr<_Counted<T>>,
751 constexpr _RemoteTypeInfo()
753 T, TfDelegatedCountPtr<_Counted<T>>, _RemoteTypeInfo<T>>()
756 using Ptr = TfDelegatedCountPtr<_Counted<T>>;
758 static T &_GetMutableObj(Ptr &ptr) {
759 if (!ptr->IsUnique()) {
760 ptr = TfMakeDelegatedCountPtr<_Counted<T>>(ptr->Get());
762 return ptr->GetMutable();
764 static T
const &_GetObj(Ptr
const &ptr) {
return ptr->Get(); }
767 static void _Place(Ptr *dst, Arg &&arg) {
768 new (dst) Ptr(TfDelegatedCountIncrementTag,
769 new _Counted<T>(std::forward<Arg>(arg)));
776 TfConditionalType<_UsesLocalStore<T>::value,
777 _LocalTypeInfo<T>, _RemoteTypeInfo<T>>;
785 friend struct _HoldAside;
787 explicit _HoldAside(
VtValue *val)
788 : info((val->
IsEmpty() || val->_IsLocalAndTriviallyCopyable())
789 ?
static_cast<_TypeInfo
const *
>(NULL) : val->_info.
Get()) {
791 info->Move(val->_storage, storage);
795 info->Destroy(storage);
798 _TypeInfo
const *info;
803 using StoredType =
typename Vt_ValueGetStored<T>::Type;
804 using TypeInfo = _TypeInfoFor<StoredType>;
810 static const TypeInfo ti;
811 static constexpr unsigned int flags =
812 (TypeInfo::IsLocal ? _LocalFlag : 0) |
813 (TypeInfo::HasTrivialCopy ? _TrivialCopyFlag : 0) |
814 (TypeInfo::IsProxy ? _ProxyFlag : 0);
819 static void Init(
VtValue *val, Arg &&obj) {
820 val->_info = _GetTypeInfo();
821 if constexpr (std::is_same_v<T, StoredType>) {
822 TypeInfo::InitObj(std::forward<Arg>(obj), val->_storage);
826 StoredType{std::forward<Arg>(obj)}, val->_storage);
858 _Init<T>::Init(
this, obj);
862 template <
class T, std::enable_if_t<!std::is_lvalue_reference_v<T>,
int> = 0>
864 _Init<T>::Init(
this, std::move(obj));
914 if (ARCH_LIKELY(
this != &other))
921 if (ARCH_LIKELY(
this != &other))
929 return *
this =
const_cast<VtValue const &
>(other);
932 return *
this = other;
956 template <
class T, std::enable_if_t<!std::is_lvalue_reference_v<T>,
int> = 0>
962 if (!
IsEmpty() || !rhs.IsEmpty()) {
981 static_assert(std::is_same_v<T, typename Vt_ValueGetStored<T>::Type>,
982 "Can only VtValue::Swap with a type T that stores as T");
995 static_assert(std::is_same_v<T, typename Vt_ValueGetStored<T>::Type>,
996 "Can only VtValue::Swap with a type T that stores as T");
998 swap(_GetMutable<T>(), rhs);
1029 template <
class T,
class Fn>
1032 static_assert(std::is_same_v<T, typename Vt_ValueGetStored<T>::Type>,
1033 "Can only VtValue::Mutate a type T that stores as T");
1044 template <
class T,
class Fn>
1047 static_assert(std::is_same_v<T, typename Vt_ValueGetStored<T>::Type>,
1048 "Can only VtValue::Mutate a type T that stores as T");
1052 T &stored =_GetMutable<T>();
1053 T tmp = std::move(stored);
1054 std::forward<Fn>(mutateFn)(tmp);
1055 stored = std::move(tmp);
1094 if (ARCH_UNLIKELY(_IsProxy())) {
1095 return _info->GetProxiedAsVtValue(
1098 return _info.
GetLiteral() ? _info->knownTypeIndex : -1;
1123 typedef Vt_DefaultValueFactory<T> Factory;
1128 return *(
static_cast<T
const *
>(
1129 _FailGet(Factory::Invoke,
typeid(T))));
1140 typedef Vt_DefaultValueFactory<T> Factory;
1145 return *(
static_cast<T
const *
>(
1146 _FailGet(Factory::Invoke,
typeid(T))));
1162 template <
typename From,
typename To>
1164 _RegisterCast(
typeid(From),
typeid(To), castFn);
1169 template <
typename From,
typename To>
1171 _RegisterCast(
typeid(From),
typeid(To), _SimpleCast<From, To>);
1176 template <
typename From,
typename To>
1189 template <
typename T>
1220 std::type_info
const &to) {
1221 return _CanCast(from, to);
1231 template <
typename T>
1235 return *
this = _PerformCast(
typeid(T), *
this);
1258 *
this = _PerformCast(type, *
this);
1266 template <
typename T>
1268 return _CanCast(
GetTypeid(),
typeid(T));
1310 friend inline
size_t hash_value(
VtValue const &val) {
1329 template <
typename T>
1331 typedef typename Vt_ValueGetStored<T>::Type Stored;
1334 template <
typename T>
1340 template <
typename T>
1342 return !(lhs == rhs);
1344 template <
typename T>
1346 return !(lhs == rhs);
1352 if (empty || rhsEmpty) {
1354 return empty == rhsEmpty;
1358 return _info.
Get()->Equal(_storage, rhs._storage);
1360 return _EqualityImpl(rhs);
1365 VT_API
friend std::ostream &
1369 VT_API
const Vt_ShapeData* _GetShapeData()
const;
1370 VT_API
size_t _GetNumElements()
const;
1371 friend struct Vt_ValueShapeDataAccess;
1379 _HoldAside tmp(&dst);
1380 dst._info = src._info;
1381 if (src._IsLocalAndTriviallyCopyable()) {
1382 dst._storage = src._storage;
1384 dst._info->CopyInit(src._storage, dst._storage);
1394 _HoldAside tmp(&dst);
1395 dst._info = src._info;
1396 if (src._IsLocalAndTriviallyCopyable()) {
1397 dst._storage = src._storage;
1399 dst._info->Move(src._storage, dst._storage);
1402 src._info.
Set(
nullptr, 0);
1408 if constexpr (VtIsKnownValueType_Workaround<T>::value) {
1410 ARCH_UNLIKELY(_IsProxy() && _TypeIsImpl(
typeid(T)));
1413 std::type_info
const &t =
typeid(T);
1415 ARCH_UNLIKELY(_IsProxy() && _TypeIsImpl(t));
1419 VT_API
bool _TypeIsImpl(std::type_info
const &queriedType)
const;
1421 VT_API
bool _EqualityImpl(
VtValue const &rhs)
const;
1426 using TypeInfo = _TypeInfoFor<T>;
1427 if constexpr (!VtIsValueProxy<T>::value) {
1430 if (ARCH_UNLIKELY(_IsProxy())) {
1431 *
this = _info->GetProxiedAsVtValue(_storage);
1434 return TypeInfo::GetMutableObj(_storage);
1440 using TypeInfo = _TypeInfoFor<T>;
1441 if constexpr (!VtIsValueProxy<T>::value) {
1444 if (ARCH_UNLIKELY(_IsProxy())) {
1445 return *
static_cast<T
const *
>(_GetProxiedObjPtr());
1448 return TypeInfo::GetObj(_storage);
1451 void const *_GetProxiedObjPtr()
const {
1452 return _info->GetProxiedObjPtr(_storage);
1458 _FailGet(Vt_DefaultValueHolder (*factory)(),
1459 std::type_info
const &queryType)
const;
1461 inline void _Clear() {
1465ARCH_PRAGMA_MAYBE_UNINITIALIZED
1466 if (_info.
GetLiteral() && !_IsLocalAndTriviallyCopyable())
1467 _info.
Get()->Destroy(_storage);
1469 _info.
Set(
nullptr, 0);
1472 inline bool _IsLocalAndTriviallyCopyable()
const {
1473 unsigned int bits = _info.
BitsAs<
unsigned int>();
1474 return (bits & (_LocalFlag | _TrivialCopyFlag)) ==
1475 (_LocalFlag | _TrivialCopyFlag);
1478 inline bool _IsProxy()
const {
1479 return _info.
BitsAs<
unsigned int>() & _ProxyFlag;
1482 VT_API
static void _RegisterCast(std::type_info
const &from,
1483 std::type_info
const &to,
1489 _PerformCast(std::type_info
const &to,
VtValue const &val);
1494 _CanCast(std::type_info
const &from, std::type_info
const &to);
1497 template <
typename From,
typename To>
1507 Vt_GetPythonObjectFromHeldValue(
VtValue const &self);
1514 friend struct Vt_ValueTestAccess;
1518 VT_API
const void *_GetHeldObjectPtrForDebugger()
const;