24 #ifndef PXR_BASE_VT_VALUE_H
25 #define PXR_BASE_VT_VALUE_H
51 #include <hboost/intrusive_ptr.hpp>
52 #include <hboost/type_traits/has_trivial_assign.hpp>
53 #include <hboost/type_traits/has_trivial_constructor.hpp>
54 #include <hboost/type_traits/has_trivial_copy.hpp>
55 #include <hboost/type_traits/has_trivial_destructor.hpp>
59 #include <type_traits>
100 : _ptr(std::move(
ptr)), _type(&type) {}
103 std::type_info
const *_type;
112 #define VT_VALUE_SET_STORED_TYPE(SRC, DST) \
113 template <> struct Vt_ValueStoredType<SRC> { typedef DST Type; }
119 #ifdef PXR_PYTHON_SUPPORT_ENABLED
121 #endif // PXR_PYTHON_SUPPORT_ENABLED
123 #undef VT_VALUE_SET_STORED_TYPE
169 static const unsigned int _LocalFlag = 1 << 0;
170 static const unsigned int _TrivialCopyFlag = 1 << 1;
171 static const unsigned int _ProxyFlag = 1 << 2;
175 explicit _Counted(
T const &obj) : _obj(obj) {
178 bool IsUnique()
const {
return _refCount == 1; }
179 T const &
Get()
const {
return _obj; }
180 T &GetMutable() {
return _obj; }
184 mutable std::atomic<int> _refCount;
187 d->_refCount.fetch_add(1, std::memory_order_relaxed);
190 if (d->_refCount.fetch_sub(1, std::memory_order_release) == 1) {
191 std::atomic_thread_fence(std::memory_order_acquire);
200 static const size_t _MaxLocalSize =
sizeof(
void*);
201 typedef std::aligned_storage<
202 _MaxLocalSize, _MaxLocalSize>
::type _Storage;
205 using _IsTriviallyCopyable = std::integral_constant<bool,
214 using _UsesLocalStore = std::integral_constant<bool,
215 (
sizeof(
T) <=
sizeof(_Storage)) &&
223 using _CopyInitFunc =
void (*)(_Storage
const &, _Storage &);
224 using _DestroyFunc =
void (*)(_Storage &);
225 using _MoveFunc =
void (*)(_Storage &, _Storage &);
226 using _CanHashFunc = bool (*)(_Storage
const &);
227 using _HashFunc = size_t (*)(_Storage
const &);
228 using _EqualFunc = bool (*)(_Storage
const &, _Storage
const &);
229 using _EqualPtrFunc = bool (*)(_Storage
const &,
void const *);
230 using _MakeMutableFunc =
void (*)(_Storage &);
232 using _StreamOutFunc =
233 std::ostream & (*)(_Storage
const &, std::ostream &);
234 using _GetTypeidFunc = std::type_info
const & (*)(_Storage
const &);
235 using _IsArrayValuedFunc = bool (*)(_Storage
const &);
236 using _GetElementTypeidFunc =
237 std::type_info
const & (*)(_Storage
const &);
238 using _GetShapeDataFunc =
const Vt_ShapeData* (*)(_Storage
const &);
239 using _GetNumElementsFunc = size_t (*)(_Storage
const &);
240 using _ProxyHoldsTypeFunc = bool (*)(_Storage
const &, std::type_info
const &);
241 using _GetProxiedTypeFunc =
TfType (*)(_Storage
const &);
242 using _GetProxiedTypeidFunc =
243 std::type_info
const & (*)(_Storage
const &);
244 using _GetProxiedObjPtrFunc =
void const *(*)(_Storage
const &);
245 using _GetProxiedAsVtValueFunc =
VtValue (*)(_Storage
const &);
248 constexpr _TypeInfo(
const std::type_info &ti,
249 const std::type_info &elementTi,
254 _CopyInitFunc copyInit,
255 _DestroyFunc destroy,
257 _CanHashFunc canHash,
260 _EqualPtrFunc equalPtr,
261 _MakeMutableFunc makeMutable,
262 _GetPyObjFunc getPyObj,
263 _StreamOutFunc streamOut,
264 _GetTypeidFunc getTypeid,
265 _IsArrayValuedFunc isArrayValued,
266 _GetElementTypeidFunc getElementTypeid,
267 _GetShapeDataFunc getShapeData,
268 _GetNumElementsFunc getNumElements,
269 _ProxyHoldsTypeFunc proxyHoldsType,
270 _GetProxiedTypeFunc getProxiedType,
271 _GetProxiedTypeidFunc getProxiedTypeid,
272 _GetProxiedObjPtrFunc getProxiedObjPtr,
273 _GetProxiedAsVtValueFunc getProxiedAsVtValue)
275 , elementTypeInfo(elementTi)
276 , knownTypeIndex(knownTypeIndex)
279 , isHashable(isHashable)
281 , _copyInit(copyInit)
287 , _equalPtr(equalPtr)
288 , _makeMutable(makeMutable)
289 , _getPyObj(getPyObj)
290 , _streamOut(streamOut)
291 , _getTypeid(getTypeid)
292 , _isArrayValued(isArrayValued)
293 , _getElementTypeid(getElementTypeid)
294 , _getShapeData(getShapeData)
295 , _getNumElements(getNumElements)
296 , _proxyHoldsType(proxyHoldsType)
297 , _getProxiedType(getProxiedType)
298 , _getProxiedTypeid(getProxiedTypeid)
299 , _getProxiedObjPtr(getProxiedObjPtr)
300 , _getProxiedAsVtValue(getProxiedAsVtValue)
304 void CopyInit(_Storage
const &
src, _Storage &
dst)
const {
307 void Destroy(_Storage &
storage)
const {
310 void Move(_Storage &src, _Storage &dst)
const noexcept {
313 bool CanHash(_Storage
const &storage)
const {
314 return _canHash(storage);
316 size_t Hash(_Storage
const &storage)
const {
317 return _hash(storage);
319 bool Equal(_Storage
const &lhs, _Storage
const &rhs)
const {
320 return _equal(lhs, rhs);
322 bool EqualPtr(_Storage
const &lhs,
void const *rhs)
const {
323 return _equalPtr(lhs, rhs);
325 void MakeMutable(_Storage &storage)
const {
326 _makeMutable(storage);
329 return _getPyObj(storage);
331 std::ostream &StreamOut(_Storage
const &storage,
332 std::ostream &out)
const {
333 return _streamOut(storage, out);
336 return _isArrayValued(storage);
339 return _getElementTypeid(storage);
341 std::type_info
const &
GetTypeid(_Storage
const &storage)
const {
342 return _getTypeid(storage);
344 const Vt_ShapeData* GetShapeData(_Storage
const &storage)
const {
345 return _getShapeData(storage);
347 size_t GetNumElements(_Storage
const &storage)
const {
348 return _getNumElements(storage);
350 bool ProxyHoldsType(_Storage
const &storage,
351 std::type_info
const &
t)
const {
352 return _proxyHoldsType(storage, t);
354 TfType GetProxiedType(_Storage
const &storage)
const {
355 return _getProxiedType(storage);
357 std::type_info
const &GetProxiedTypeid(_Storage
const &storage)
const {
358 return _getProxiedTypeid(storage);
360 VtValue GetProxiedAsVtValue(_Storage
const &storage)
const {
361 return _getProxiedAsVtValue(storage);
363 void const *GetProxiedObjPtr(_Storage
const &storage)
const {
364 return _getProxiedObjPtr(storage);
367 const std::type_info &typeInfo;
368 const std::type_info &elementTypeInfo;
375 _CopyInitFunc _copyInit;
376 _DestroyFunc _destroy;
378 _CanHashFunc _canHash;
381 _EqualPtrFunc _equalPtr;
382 _MakeMutableFunc _makeMutable;
383 _GetPyObjFunc _getPyObj;
384 _StreamOutFunc _streamOut;
385 _GetTypeidFunc _getTypeid;
386 _IsArrayValuedFunc _isArrayValued;
387 _GetElementTypeidFunc _getElementTypeid;
388 _GetShapeDataFunc _getShapeData;
389 _GetNumElementsFunc _getNumElements;
390 _ProxyHoldsTypeFunc _proxyHoldsType;
391 _GetProxiedTypeFunc _getProxiedType;
392 _GetProxiedTypeidFunc _getProxiedTypeid;
393 _GetProxiedObjPtrFunc _getProxiedObjPtr;
394 _GetProxiedAsVtValueFunc _getProxiedAsVtValue;
400 template <
class T,
class Enable=
void>
403 static const Vt_ShapeData* GetShapeData(
T const &) {
return NULL; }
404 static size_t GetNumElements(
T const &) {
return 0; }
409 template <
class Array>
411 Array, typename std::enable_if<VtIsArray<Array>::value>
::type>
413 static const Vt_ShapeData* GetShapeData(Array
const &obj) {
414 return obj._GetShapeData();
416 static size_t GetNumElements(Array
const &obj) {
420 return typeid(
typename Array::ElementType);
427 _TypedProxyEqualityImpl(
T const &
a,
T const &
b,
int) -> decltype(a == b) {
431 template <
class NoEqual>
433 _TypedProxyEqualityImpl(NoEqual
const &a, NoEqual
const &b,
long) {
439 _ErasedProxyEqualityImpl(
T const &a,
T const &b,
int) -> decltype(a == b) {
443 template <
class NoEqual>
445 _ErasedProxyEqualityImpl(NoEqual
const &a, NoEqual
const &b,
long) {
446 return *VtGetErasedProxiedVtValue(a) == *VtGetErasedProxiedVtValue(b);
450 template <
class T,
class Enable =
void>
455 static bool CanHash(
T const &) {
return VtIsHashable<ProxiedType>(); }
456 static size_t Hash(
T const &obj) {
459 static bool Equal(
T const &a,
T const &b) {
464 return _TypedProxyEqualityImpl(a, b, 0);
467 #ifdef PXR_PYTHON_SUPPORT_ENABLED
473 #endif //PXR_PYTHON_SUPPORT_ENABLED
475 static std::ostream &StreamOut(
T const &obj, std::ostream &out) {
479 return _ArrayHelper<ProxiedType>::GetShapeData(
482 static size_t GetNumElements(
T const &obj) {
483 return _ArrayHelper<ProxiedType>::GetNumElements(
489 static std::type_info
const &
GetTypeid(
T const &) {
490 return typeid(ProxiedType);
493 return _ArrayHelper<ProxiedType>::GetElementTypeid();
495 static VtValue GetProxiedAsVtValue(
T const &obj) {
498 static bool HoldsType(
T const &tp, std::type_info
const &
query) {
501 static TfType GetTfType(
T const &tp) {
502 return TfType::Find<ProxiedType>();
504 static void const *GetObjPtr(
T const &tp) {
509 template <
class ErasedProxy>
511 ErasedProxy, typename std::enable_if<
512 VtIsErasedValueProxy<ErasedProxy>::value>
::type>
514 static bool CanHash(ErasedProxy
const &proxy) {
515 return VtGetErasedProxiedVtValue(proxy)->CanHash();
517 static size_t Hash(ErasedProxy
const &proxy) {
518 return VtGetErasedProxiedVtValue(proxy)->GetHash();
520 static bool Equal(ErasedProxy
const &a, ErasedProxy
const &b) {
525 return _ErasedProxyEqualityImpl(a, b, 0);
528 #ifdef PXR_PYTHON_SUPPORT_ENABLED
529 VtValue const *
val = VtGetErasedProxiedVtValue(obj);
534 #endif //PXR_PYTHON_SUPPORT_ENABLED
536 static std::ostream &
537 StreamOut(ErasedProxy
const &obj, std::ostream &out) {
540 static Vt_ShapeData const *GetShapeData(ErasedProxy
const &obj) {
541 return VtGetErasedProxiedVtValue(obj)->_GetShapeData();
543 static size_t GetNumElements(ErasedProxy
const &obj) {
544 return VtGetErasedProxiedVtValue(obj)->_GetNumElements();
547 return VtGetErasedProxiedVtValue(obj)->IsArrayValued();
549 static std::type_info
const &
GetTypeid(ErasedProxy
const &obj) {
550 return VtGetErasedProxiedVtValue(obj)->GetTypeid();
553 return VtGetErasedProxiedVtValue(obj)->GetElementTypeid();
555 static VtValue GetProxiedAsVtValue(ErasedProxy
const &ep) {
556 return *VtGetErasedProxiedVtValue(ep);
559 HoldsType(ErasedProxy
const &ep, std::type_info
const &
query) {
560 return VtErasedProxyHoldsType(ep, query);
562 static TfType GetTfType(ErasedProxy
const &ep) {
563 return VtGetErasedProxiedTfType(ep);
565 static void const *GetObjPtr(ErasedProxy
const &ep) {
566 VtValue const *
val = VtGetErasedProxiedVtValue(ep);
567 return val ? val->_GetProxiedObjPtr() :
nullptr;
574 template <
class T,
class Container,
class Derived>
575 struct _TypeInfoImpl :
public _TypeInfo
577 static const bool IsLocal = _UsesLocalStore<T>::value;
578 static const bool HasTrivialCopy = _IsTriviallyCopyable<T>::value;
581 using ProxyHelper = _ProxyHelper<T>;
583 using This = _TypeInfoImpl;
585 constexpr _TypeInfoImpl()
586 : _TypeInfo(
typeid(
T),
587 _ArrayHelper<T>::GetElementTypeid(),
588 Vt_KnownValueTypeDetail::GetIndex<T>(),
606 &This::_IsArrayValued,
607 &This::_GetElementTypeid,
608 &This::_GetShapeData,
609 &This::_GetNumElements,
612 &This::_ProxyHoldsType,
613 &This::_GetProxiedType,
614 &This::_GetProxiedTypeid,
615 &This::_GetProxiedObjPtr,
616 &This::_GetProxiedAsVtValue)
621 static T const &GetObj(_Storage
const &
storage) {
622 return Derived::_GetObj(_Container(storage));
625 static T &GetMutableObj(_Storage &storage) {
626 return Derived::_GetMutableObj(_Container(storage));
629 static void CopyInitObj(
T const &objSrc, _Storage &
dst) {
630 Derived::_PlaceCopy(&_Container(dst), objSrc);
634 static_assert(
sizeof(Container) <=
sizeof(_Storage),
635 "Container size cannot exceed storage size.");
639 static void _CopyInit(_Storage
const &
src, _Storage &dst) {
640 new (&_Container(dst)) Container(_Container(src));
643 static void _Destroy(_Storage &storage) {
644 _Container(storage).~Container();
647 static bool _CanHash(_Storage
const &storage) {
648 return ProxyHelper::CanHash(GetObj(storage));
651 static size_t _Hash(_Storage
const &storage) {
655 static bool _Equal(_Storage
const &lhs, _Storage
const &rhs) {
659 return ProxyHelper::Equal(GetObj(lhs), GetObj(rhs));
662 static bool _EqualPtr(_Storage
const &lhs,
void const *rhs) {
666 return ProxyHelper::Equal(
667 GetObj(lhs), *static_cast<T const *>(rhs));
670 static void _Move(_Storage &src, _Storage &dst) noexcept {
671 new (&_Container(dst)) Container(std::move(_Container(src)));
675 static void _MakeMutable(_Storage &storage) {
676 GetMutableObj(storage);
680 return ProxyHelper::GetPyObj(GetObj(storage));
683 static std::ostream &_StreamOut(
684 _Storage
const &storage, std::ostream &out) {
685 return ProxyHelper::StreamOut(GetObj(storage), out);
688 static std::type_info
const &_GetTypeid(_Storage
const &storage) {
689 return ProxyHelper::GetTypeid(GetObj(storage));
692 static bool _IsArrayValued(_Storage
const &storage) {
693 return ProxyHelper::IsArrayValued(GetObj(storage));
696 static std::type_info
const &
697 _GetElementTypeid(_Storage
const &storage) {
698 return ProxyHelper::GetElementTypeid(GetObj(storage));
701 static const Vt_ShapeData* _GetShapeData(_Storage
const &storage) {
702 return ProxyHelper::GetShapeData(GetObj(storage));
705 static size_t _GetNumElements(_Storage
const &storage) {
706 return ProxyHelper::GetNumElements(GetObj(storage));
710 _ProxyHoldsType(_Storage
const &storage, std::type_info
const &
t) {
711 return ProxyHelper::HoldsType(GetObj(storage), t);
715 _GetProxiedType(_Storage
const &storage) {
716 return ProxyHelper::GetTfType(GetObj(storage));
719 static std::type_info
const &
720 _GetProxiedTypeid(_Storage
const &storage) {
721 return ProxyHelper::GetTypeid(GetObj(storage));
725 _GetProxiedObjPtr(_Storage
const &storage) {
726 return ProxyHelper::GetObjPtr(GetObj(storage));
730 _GetProxiedAsVtValue(_Storage
const &storage) {
731 return ProxyHelper::GetProxiedAsVtValue(GetObj(storage));
737 static Container &_Container(_Storage &storage) {
739 return *
reinterpret_cast<Container *
>(&
storage);
741 static Container
const &_Container(_Storage
const &storage) {
743 return *
reinterpret_cast<Container
const *
>(&
storage);
751 struct _LocalTypeInfo : _TypeInfoImpl<
757 constexpr _LocalTypeInfo()
758 : _TypeInfoImpl<T, T, _LocalTypeInfo<T>>()
762 static T &_GetMutableObj(
T &obj) {
return obj; }
763 static T const &_GetObj(
T const &obj) {
return obj; }
765 static void _PlaceCopy(
T *
dst,
T const &
src) {
new (
dst)
T(src); }
772 struct _RemoteTypeInfo : _TypeInfoImpl<
774 hboost::intrusive_ptr<_Counted<T> >,
778 constexpr _RemoteTypeInfo()
780 T, hboost::intrusive_ptr<_Counted<T>>, _RemoteTypeInfo<T>>()
783 typedef hboost::intrusive_ptr<_Counted<T> > Ptr;
785 static T &_GetMutableObj(Ptr &
ptr) {
786 if (!ptr->IsUnique())
787 ptr.reset(
new _Counted<T>(ptr->Get()));
788 return ptr->GetMutable();
790 static T const &_GetObj(Ptr
const &ptr) {
return ptr->Get(); }
792 static void _PlaceCopy(Ptr *
dst,
T const &
src) {
793 new (
dst) Ptr(
new _Counted<T>(src));
799 struct _TypeInfoFor {
803 _RemoteTypeInfo<T>>
Type;
808 struct _TypeInfoFor<char[N]> : _TypeInfoFor<std::string> {};
814 typedef typename _TypeInfoFor<T>::Type TI;
816 static constexpr
unsigned int flags =
817 (TI::IsLocal ? _LocalFlag : 0) |
818 (TI::HasTrivialCopy ? _TrivialCopyFlag : 0) |
819 (TI::IsProxy ? _ProxyFlag : 0);
832 : info((val->
IsEmpty() || val->_IsLocalAndTriviallyCopyable())
833 ? static_cast<_TypeInfo
const *>(NULL) : val->_info.
Get()) {
835 info->Move(val->_storage,
storage);
842 _TypeInfo
const *info;
848 _Init(
T const &obj) {
849 _info = GetTypeInfo<T>();
851 TypeInfo::CopyInitObj(obj, _storage);
857 _Init(
T const &obj) {
933 _TypeInfoFor<T>::Type::IsLocal &&
934 _TypeInfoFor<T>::Type::HasTrivialCopy,
951 !_TypeInfoFor<T>::Type::IsLocal ||
952 !_TypeInfoFor<T>::Type::HasTrivialCopy,
971 return *
this =
const_cast<char const *
>(cstr);
977 if (!
IsEmpty() || !rhs.IsEmpty()) {
1002 if (!IsHolding<T>())
1022 swap(_GetMutable<T>(), rhs);
1084 return _info->GetProxiedAsVtValue(
1085 _storage).GetKnownValueTypeIndex();
1087 return _info.
GetLiteral() ? _info->knownTypeIndex : -1;
1116 return *(
static_cast<T const *
>(
1117 _FailGet(Factory::Invoke,
typeid(
T))));
1132 return *(
static_cast<T const *
>(
1133 _FailGet(Factory::Invoke,
typeid(
T))));
1136 return UncheckedRemove<T>();
1145 return IsHolding<T>() ? UncheckedGet<T>() : def;
1149 template <
typename From,
typename To>
1151 _RegisterCast(
typeid(From),
typeid(To), castFn);
1156 template <
typename From,
typename To>
1158 _RegisterCast(
typeid(From),
typeid(To), _SimpleCast<From, To>);
1163 template <
typename From,
typename To>
1165 RegisterSimpleCast<From, To>();
1166 RegisterSimpleCast<To, From>();
1176 template <
typename T>
1179 return ret.
Cast<
T>();
1206 std::type_info
const &to) {
1207 return _CanCast(from, to);
1217 template <
typename T>
1221 return *
this = _PerformCast(
typeid(
T), *
this);
1244 *
this = _PerformCast(type, *
this);
1252 template <
typename T>
1285 template <
typename T>
1290 template <
typename T>
1296 template <
typename T>
1298 return !(lhs == rhs);
1300 template <
typename T>
1302 return !(lhs == rhs);
1308 if (empty || rhsEmpty) {
1310 return empty == rhsEmpty;
1314 return _info.
Get()->Equal(_storage, rhs._storage);
1316 return _EqualityImpl(rhs);
1321 VT_API friend std::ostream &
1326 VT_API size_t _GetNumElements()
const;
1336 dst._info = src._info;
1337 if (src._IsLocalAndTriviallyCopyable()) {
1338 dst._storage = src._storage;
1340 dst._info->CopyInit(src._storage, dst._storage);
1351 dst._info = src._info;
1352 if (src._IsLocalAndTriviallyCopyable()) {
1353 dst._storage = src._storage;
1355 dst._info->Move(src._storage, dst._storage);
1358 src._info.
Set(
nullptr, 0);
1364 return _info->knownTypeIndex == VtGetKnownValueTypeIndex<T>() ||
1371 std::type_info
const &
t =
typeid(
T);
1376 VT_API bool _TypeIsImpl(std::type_info
const &queriedType)
const;
1380 template <
class Proxy>
1384 return TypeInfo::GetMutableObj(_storage);
1392 *
this = _info->GetProxiedAsVtValue(_storage);
1395 return TypeInfo::GetMutableObj(_storage);
1398 template <
class Proxy>
1402 return TypeInfo::GetObj(_storage);
1410 return *
static_cast<T const *
>(_GetProxiedObjPtr());
1412 return TypeInfo::GetObj(_storage);
1415 void const *_GetProxiedObjPtr()
const {
1416 return _info->GetProxiedObjPtr(_storage);
1423 std::type_info
const &queryType)
const;
1425 inline void _Clear() {
1430 if (_info.
GetLiteral() && !_IsLocalAndTriviallyCopyable())
1431 _info.
Get()->Destroy(_storage);
1433 _info.
Set(
nullptr, 0);
1436 inline bool _IsLocalAndTriviallyCopyable()
const {
1437 unsigned int bits = _info.
BitsAs<
unsigned int>();
1438 return (bits & (_LocalFlag | _TrivialCopyFlag)) ==
1439 (_LocalFlag | _TrivialCopyFlag);
1442 inline bool _IsProxy()
const {
1443 return _info.
BitsAs<
unsigned int>() & _ProxyFlag;
1446 VT_API static void _RegisterCast(std::type_info
const &from,
1447 std::type_info
const &to,
1453 _PerformCast(std::type_info
const &to,
VtValue const &val);
1458 _CanCast(std::type_info
const &from, std::type_info
const &to);
1461 template <
typename From,
typename To>
1483 return value._GetShapeData();
1487 return value._GetNumElements();
1502 return Vt_DefaultValueHolder::Create<T>();
1513 #define _VT_DECLARE_ZERO_VALUE_FACTORY(r, unused, elem) \
1515 VT_API Vt_DefaultValueHolder Vt_DefaultValueFactory<VT_TYPE(elem)>::Invoke();
1524 #undef _VT_DECLARE_ZERO_VALUE_FACTORY
1533 VtValue::Get<VtValue>()
const & {
1539 VtValue::Get<VtValue>() && {
1540 return std::move(*
this);
1545 VtValue::UncheckedGet<VtValue>()
const & {
1551 VtValue::UncheckedGet<VtValue>() && {
1552 return std::move(*
this);
1557 VtValue::IsHolding<VtValue>()
const {
1564 VtValue::IsHolding<void>()
const {
1574 #endif // PXR_BASE_VT_VALUE_H
typename std::enable_if< B, T >::type enable_if_t
Define Imath::enable_if_t to be std for C++14, equivalent for C++11.
static Vt_DefaultValueHolder Create(T const &val)
T const & UncheckedGet() const &
STATIC_INLINE size_t Hash(const char *s, size_t len)
friend TfPyObjWrapper Vt_GetPythonObjectFromHeldValue(VtValue const &self)
static VtValue Take(T &obj)
getFileOption("OpenEXR:storage") storage
void swap(UT::ArraySet< Key, MULTI, MAX_LOAD_FACTOR_256, Clearer, Hash, KeyEqual > &a, UT::ArraySet< Key, MULTI, MAX_LOAD_FACTOR_256, Clearer, Hash, KeyEqual > &b)
VtValue & CastToTypeOf(VtValue const &other)
static void RegisterCast(VtValue(*castFn)(VtValue const &))
Register a cast from VtValue holding From to VtValue holding To.
GLsizei const GLchar *const * string
GLsizei const GLfloat * value
static const Vt_ShapeData * _GetShapeData(const VtValue &value)
VtValue & operator=(char const *cstr)
Assigning a char const * gives a VtValue holding a std::string.
std::enable_if_t< !_TypeInfoFor< T >::Type::IsLocal||!_TypeInfoFor< T >::Type::HasTrivialCopy, VtValue & > operator=(T const &obj)
Assignment operator from any type.
GLboolean GLboolean GLboolean GLboolean a
size_t GetArraySize() const
std::enable_if_t< std::is_same< T, typename Vt_ValueGetStored< T >::Type >::value > Swap(T &rhs)
Swap the held value with rhs. If this value is holding a T,.
IMATH_HOSTDEVICE constexpr bool equal(T1 a, T2 b, T3 t) IMATH_NOEXCEPT
VtValue & Swap(VtValue &rhs) noexcept
Swap this with rhs.
**But if you need a result
bool IsEmpty() const
Returns true iff this value is empty.
#define VT_DUALQUATERNION_VALUE_TYPES
VtValue & operator=(char *cstr)
Assigning a char * gives a VtValue holding a std::string.
T const & VtGetProxiedObject(T const &nonProxy)
static size_t _GetNumElements(const VtValue &value)
VtValue(VtValue const &other)
Copy construct with other.
constexpr T * Get() const noexcept
Retrieve the pointer.
bool CanCastToTypeOf(VtValue const &other) const
static VT_API VtValue CastToTypeOf(VtValue const &val, VtValue const &other)
int GetKnownValueTypeIndex() const
constexpr uintptr_t GetLiteral() const noexcept
static VT_API VtValue CastToTypeid(VtValue const &val, std::type_info const &type)
void intrusive_ptr_release(T *x)
VT_API bool IsArrayValued() const
Returns true iff this is holding an array type (see VtIsArray<>).
VT_API std::type_info const & GetElementTypeid() const
std::enable_if_t< _TypeInfoFor< T >::Type::IsLocal &&_TypeInfoFor< T >::Type::HasTrivialCopy, VtValue & > operator=(T obj)
friend bool operator!=(VtValue const &lhs, T const &rhs)
Tests for inequality.
void UncheckedSwap(VtValue &rhs)
typename std::decay< decltype(VtGetProxiedObject(std::declval< T >()))>::type type
constexpr Integral BitsAs() const noexcept
Retrieve the stored bits as the integral type Integral.
static bool CanCastFromTypeidToTypeid(std::type_info const &from, std::type_info const &to)
friend bool operator==(VtValue const &lhs, T const &rhs)
Tests for equality.
#define VT_VEC_VALUE_TYPES
VT_API std::ostream & VtStreamOut(std::vector< VtValue > const &val, std::ostream &)
#define VT_VALUE_SET_STORED_TYPE(SRC, DST)
VtValue(VtValue &&other) noexcept
Move construct with other.
GLboolean GLboolean GLboolean b
#define _VT_DECLARE_ZERO_VALUE_FACTORY(r, unused, elem)
void const * GetPointer() const
VtValue & operator=(VtValue &&other) noexcept
Move assignment from another VtValue.
void Set(T *ptr) noexcept
Set the pointer value to ptr.
VT_API std::type_info const & GetTypeid() const
Returns the typeid of the type held by this value.
Array concept. By default, types are not arrays.
VT_API size_t GetHash() const
Return a hash code for the held object by calling VtHashValue() on it.
std::enable_if_t< std::is_same< T, typename Vt_ValueGetStored< T >::Type >::value > UncheckedSwap(T &rhs)
void intrusive_ptr_add_ref(T *x)
VtValue & operator=(VtValue const &other)
Copy assignment from another VtValue.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
friend size_t hash_value(VtValue const &val)
#define ARCH_PRAGMA_MAYBE_UNINITIALIZED
size_t VtHashValue(T const &val)
static VtValue Cast(VtValue const &val)
std::type_info const & GetType() const
static Vt_DefaultValueHolder Create()
VT_API std::string GetTypeName() const
Return the type name of the held typeid.
#define PXR_NAMESPACE_CLOSE_SCOPE
friend void swap(VtValue &lhs, VtValue &rhs)
Overloaded swap() for generic code/stl/etc.
static void RegisterSimpleCast()
Register a simple cast from VtValue holding From to VtValue.
static TfAnyUniquePtr New()
#define VT_QUATERNION_VALUE_TYPES
VtValue & CastToTypeid(std::type_info const &type)
PXR_NAMESPACE_OPEN_SCOPE bool TfSafeTypeCompare(const std::type_info &t1, const std::type_info &t2)
VtValue()
Default ctor gives empty VtValue.
static void RegisterSimpleBidirectionalCast()
VT_API friend std::ostream & operator<<(std::ostream &out, const VtValue &self)
Calls through to operator << on the held object.
T GetWithDefault(T const &def=T()) const
HBOOST_PP_SEQ_FOR_EACH(_VT_DECLARE_ZERO_VALUE_FACTORY, unused, VT_VEC_VALUE_TYPES VT_MATRIX_VALUE_TYPES VT_QUATERNION_VALUE_TYPES VT_DUALQUATERNION_VALUE_TYPES) template<> inline const VtValue &VtValue
static Vt_DefaultValueHolder Invoke()
#define VT_MATRIX_VALUE_TYPES
bool CanCastToTypeid(std::type_info const &type) const
VT_API TfType GetType() const
Returns the TfType of the type held by this value.
VT_API bool CanHash() const
Return true if the held object provides a hash implementation.
void const * Get() const
Return a pointer to the owned object.