24 #ifndef PXR_BASE_VT_VALUE_H
25 #define PXR_BASE_VT_VALUE_H
50 #include <hboost/intrusive_ptr.hpp>
51 #include <hboost/type_traits/has_trivial_assign.hpp>
52 #include <hboost/type_traits/has_trivial_constructor.hpp>
53 #include <hboost/type_traits/has_trivial_copy.hpp>
54 #include <hboost/type_traits/has_trivial_destructor.hpp>
58 #include <type_traits>
99 : _ptr(std::move(
ptr)), _type(&type) {}
102 std::type_info
const *_type;
111 #define VT_VALUE_SET_STORED_TYPE(SRC, DST) \
112 template <> struct Vt_ValueStoredType<SRC> { typedef DST Type; }
118 #ifdef PXR_PYTHON_SUPPORT_ENABLED
120 #endif // PXR_PYTHON_SUPPORT_ENABLED
122 #undef VT_VALUE_SET_STORED_TYPE
168 static const unsigned int _LocalFlag = 1 << 0;
169 static const unsigned int _TrivialCopyFlag = 1 << 1;
170 static const unsigned int _ProxyFlag = 1 << 2;
174 explicit _Counted(
T const &
obj) : _obj(obj) {
177 bool IsUnique()
const {
return _refCount == 1; }
178 T const &
Get()
const {
return _obj; }
179 T &GetMutable() {
return _obj; }
183 mutable std::atomic<int> _refCount;
186 d->_refCount.fetch_add(1, std::memory_order_relaxed);
189 if (d->_refCount.fetch_sub(1, std::memory_order_release) == 1) {
190 std::atomic_thread_fence(std::memory_order_acquire);
199 static const size_t _MaxLocalSize =
sizeof(
void*);
200 typedef std::aligned_storage<
201 _MaxLocalSize, _MaxLocalSize>
::type _Storage;
204 using _IsTriviallyCopyable = std::integral_constant<bool,
213 using _UsesLocalStore = std::integral_constant<bool,
214 (
sizeof(
T) <=
sizeof(_Storage)) &&
222 using _CopyInitFunc =
void (*)(_Storage
const &, _Storage &);
223 using _DestroyFunc =
void (*)(_Storage &);
224 using _MoveFunc =
void (*)(_Storage &, _Storage &);
225 using _CanHashFunc = bool (*)(_Storage
const &);
226 using _HashFunc = size_t (*)(_Storage
const &);
227 using _EqualFunc = bool (*)(_Storage
const &, _Storage
const &);
228 using _EqualPtrFunc = bool (*)(_Storage
const &,
void const *);
229 using _MakeMutableFunc =
void (*)(_Storage &);
231 using _StreamOutFunc =
232 std::ostream & (*)(_Storage
const &, std::ostream &);
233 using _GetTypeidFunc = std::type_info
const & (*)(_Storage
const &);
234 using _IsArrayValuedFunc = bool (*)(_Storage
const &);
235 using _GetElementTypeidFunc =
236 std::type_info
const & (*)(_Storage
const &);
237 using _GetShapeDataFunc =
const Vt_ShapeData* (*)(_Storage
const &);
238 using _GetNumElementsFunc = size_t (*)(_Storage
const &);
239 using _ProxyHoldsTypeFunc = bool (*)(_Storage
const &, std::type_info
const &);
240 using _GetProxiedTypeFunc =
TfType (*)(_Storage
const &);
241 using _GetProxiedTypeidFunc =
242 std::type_info
const & (*)(_Storage
const &);
243 using _GetProxiedObjPtrFunc =
void const *(*)(_Storage
const &);
244 using _GetProxiedAsVtValueFunc =
VtValue (*)(_Storage
const &);
247 constexpr _TypeInfo(
const std::type_info &ti,
248 const std::type_info &elementTi,
252 _CopyInitFunc copyInit,
253 _DestroyFunc destroy,
255 _CanHashFunc canHash,
258 _EqualPtrFunc equalPtr,
259 _MakeMutableFunc makeMutable,
260 _GetPyObjFunc getPyObj,
261 _StreamOutFunc streamOut,
262 _GetTypeidFunc getTypeid,
263 _IsArrayValuedFunc isArrayValued,
264 _GetElementTypeidFunc getElementTypeid,
265 _GetShapeDataFunc getShapeData,
266 _GetNumElementsFunc getNumElements,
267 _ProxyHoldsTypeFunc proxyHoldsType,
268 _GetProxiedTypeFunc getProxiedType,
269 _GetProxiedTypeidFunc getProxiedTypeid,
270 _GetProxiedObjPtrFunc getProxiedObjPtr,
271 _GetProxiedAsVtValueFunc getProxiedAsVtValue)
273 , elementTypeInfo(elementTi)
276 , isHashable(isHashable)
278 , _copyInit(copyInit)
284 , _equalPtr(equalPtr)
285 , _makeMutable(makeMutable)
286 , _getPyObj(getPyObj)
287 , _streamOut(streamOut)
288 , _getTypeid(getTypeid)
289 , _isArrayValued(isArrayValued)
290 , _getElementTypeid(getElementTypeid)
291 , _getShapeData(getShapeData)
292 , _getNumElements(getNumElements)
293 , _proxyHoldsType(proxyHoldsType)
294 , _getProxiedType(getProxiedType)
295 , _getProxiedTypeid(getProxiedTypeid)
296 , _getProxiedObjPtr(getProxiedObjPtr)
297 , _getProxiedAsVtValue(getProxiedAsVtValue)
301 void CopyInit(_Storage
const &
src, _Storage &
dst)
const {
304 void Destroy(_Storage &
storage)
const {
307 void Move(_Storage &src, _Storage &dst)
const noexcept {
310 bool CanHash(_Storage
const &storage)
const {
311 return _canHash(storage);
313 size_t Hash(_Storage
const &storage)
const {
314 return _hash(storage);
316 bool Equal(_Storage
const &lhs, _Storage
const &rhs)
const {
317 return _equal(lhs, rhs);
319 bool EqualPtr(_Storage
const &lhs,
void const *rhs)
const {
320 return _equalPtr(lhs, rhs);
322 void MakeMutable(_Storage &storage)
const {
323 _makeMutable(storage);
326 return _getPyObj(storage);
328 std::ostream &StreamOut(_Storage
const &storage,
329 std::ostream &out)
const {
330 return _streamOut(storage, out);
333 return _isArrayValued(storage);
336 return _getElementTypeid(storage);
338 std::type_info
const &
GetTypeid(_Storage
const &storage)
const {
339 return _getTypeid(storage);
341 const Vt_ShapeData* GetShapeData(_Storage
const &storage)
const {
342 return _getShapeData(storage);
344 size_t GetNumElements(_Storage
const &storage)
const {
345 return _getNumElements(storage);
347 bool ProxyHoldsType(_Storage
const &storage,
348 std::type_info
const &
t)
const {
349 return _proxyHoldsType(storage, t);
351 TfType GetProxiedType(_Storage
const &storage)
const {
352 return _getProxiedType(storage);
354 std::type_info
const &GetProxiedTypeid(_Storage
const &storage)
const {
355 return _getProxiedTypeid(storage);
357 VtValue GetProxiedAsVtValue(_Storage
const &storage)
const {
358 return _getProxiedAsVtValue(storage);
360 void const *GetProxiedObjPtr(_Storage
const &storage)
const {
361 return _getProxiedObjPtr(storage);
364 const std::type_info &typeInfo;
365 const std::type_info &elementTypeInfo;
371 _CopyInitFunc _copyInit;
372 _DestroyFunc _destroy;
374 _CanHashFunc _canHash;
377 _EqualPtrFunc _equalPtr;
378 _MakeMutableFunc _makeMutable;
379 _GetPyObjFunc _getPyObj;
380 _StreamOutFunc _streamOut;
381 _GetTypeidFunc _getTypeid;
382 _IsArrayValuedFunc _isArrayValued;
383 _GetElementTypeidFunc _getElementTypeid;
384 _GetShapeDataFunc _getShapeData;
385 _GetNumElementsFunc _getNumElements;
386 _ProxyHoldsTypeFunc _proxyHoldsType;
387 _GetProxiedTypeFunc _getProxiedType;
388 _GetProxiedTypeidFunc _getProxiedTypeid;
389 _GetProxiedObjPtrFunc _getProxiedObjPtr;
390 _GetProxiedAsVtValueFunc _getProxiedAsVtValue;
396 template <
class T,
class Enable=
void>
399 static const Vt_ShapeData* GetShapeData(
T const &) {
return NULL; }
400 static size_t GetNumElements(
T const &) {
return 0; }
405 template <
class Array>
407 Array, typename std::enable_if<VtIsArray<Array>::value>
::type>
410 return obj._GetShapeData();
412 static size_t GetNumElements(Array
const &obj) {
416 return typeid(
typename Array::ElementType);
423 _TypedProxyEqualityImpl(
T const &
a,
T const &
b,
int) -> decltype(a == b) {
427 template <
class NoEqual>
429 _TypedProxyEqualityImpl(NoEqual
const &a, NoEqual
const &b,
long) {
435 _ErasedProxyEqualityImpl(
T const &a,
T const &b,
int) -> decltype(a == b) {
439 template <
class NoEqual>
441 _ErasedProxyEqualityImpl(NoEqual
const &a, NoEqual
const &b,
long) {
442 return *VtGetErasedProxiedVtValue(a) == *VtGetErasedProxiedVtValue(b);
446 template <
class T,
class Enable =
void>
451 static bool CanHash(
T const &) {
return VtIsHashable<ProxiedType>(); }
455 static bool Equal(
T const &a,
T const &b) {
460 return _TypedProxyEqualityImpl(a, b, 0);
463 #ifdef PXR_PYTHON_SUPPORT_ENABLED
469 #endif //PXR_PYTHON_SUPPORT_ENABLED
471 static std::ostream &StreamOut(
T const &obj, std::ostream &out) {
475 return _ArrayHelper<ProxiedType>::GetShapeData(
478 static size_t GetNumElements(
T const &obj) {
479 return _ArrayHelper<ProxiedType>::GetNumElements(
485 static std::type_info
const &
GetTypeid(
T const &) {
486 return typeid(ProxiedType);
489 return _ArrayHelper<ProxiedType>::GetElementTypeid();
491 static VtValue GetProxiedAsVtValue(
T const &obj) {
494 static bool HoldsType(
T const &tp, std::type_info
const &
query) {
497 static TfType GetTfType(
T const &tp) {
498 return TfType::Find<ProxiedType>();
500 static void const *GetObjPtr(
T const &tp) {
505 template <
class ErasedProxy>
507 ErasedProxy, typename std::enable_if<
508 VtIsErasedValueProxy<ErasedProxy>::value>
::type>
510 static bool CanHash(ErasedProxy
const &proxy) {
511 return VtGetErasedProxiedVtValue(proxy)->CanHash();
513 static size_t Hash(ErasedProxy
const &proxy) {
514 return VtGetErasedProxiedVtValue(proxy)->GetHash();
516 static bool Equal(ErasedProxy
const &a, ErasedProxy
const &b) {
521 return _ErasedProxyEqualityImpl(a, b, 0);
524 #ifdef PXR_PYTHON_SUPPORT_ENABLED
525 VtValue const *
val = VtGetErasedProxiedVtValue(obj);
530 #endif //PXR_PYTHON_SUPPORT_ENABLED
532 static std::ostream &
533 StreamOut(ErasedProxy
const &obj, std::ostream &out) {
536 static Vt_ShapeData const *GetShapeData(ErasedProxy
const &obj) {
537 return VtGetErasedProxiedVtValue(obj)->_GetShapeData();
539 static size_t GetNumElements(ErasedProxy
const &obj) {
540 return VtGetErasedProxiedVtValue(obj)->_GetNumElements();
543 return VtGetErasedProxiedVtValue(obj)->IsArrayValued();
545 static std::type_info
const &
GetTypeid(ErasedProxy
const &obj) {
546 return VtGetErasedProxiedVtValue(obj)->GetTypeid();
549 return VtGetErasedProxiedVtValue(obj)->GetElementTypeid();
551 static VtValue GetProxiedAsVtValue(ErasedProxy
const &ep) {
552 return *VtGetErasedProxiedVtValue(ep);
555 HoldsType(ErasedProxy
const &ep, std::type_info
const &
query) {
556 return VtErasedProxyHoldsType(ep, query);
558 static TfType GetTfType(ErasedProxy
const &ep) {
559 return VtGetErasedProxiedTfType(ep);
561 static void const *GetObjPtr(ErasedProxy
const &ep) {
562 VtValue const *
val = VtGetErasedProxiedVtValue(ep);
563 return val ? val->_GetProxiedObjPtr() :
nullptr;
570 template <
class T,
class Container,
class Derived>
571 struct _TypeInfoImpl :
public _TypeInfo
573 static const bool IsLocal = _UsesLocalStore<T>::value;
574 static const bool HasTrivialCopy = _IsTriviallyCopyable<T>::value;
577 using ProxyHelper = _ProxyHelper<T>;
579 using This = _TypeInfoImpl;
581 constexpr _TypeInfoImpl()
582 : _TypeInfo(
typeid(
T),
583 _ArrayHelper<T>::GetElementTypeid(),
601 &This::_IsArrayValued,
602 &This::_GetElementTypeid,
603 &This::_GetShapeData,
604 &This::_GetNumElements,
607 &This::_ProxyHoldsType,
608 &This::_GetProxiedType,
609 &This::_GetProxiedTypeid,
610 &This::_GetProxiedObjPtr,
611 &This::_GetProxiedAsVtValue)
616 static T const &GetObj(_Storage
const &
storage) {
617 return Derived::_GetObj(_Container(storage));
620 static T &GetMutableObj(_Storage &storage) {
621 return Derived::_GetMutableObj(_Container(storage));
624 static void CopyInitObj(
T const &objSrc, _Storage &
dst) {
625 Derived::_PlaceCopy(&_Container(dst), objSrc);
629 static_assert(
sizeof(Container) <=
sizeof(_Storage),
630 "Container size cannot exceed storage size.");
634 static void _CopyInit(_Storage
const &
src, _Storage &dst) {
635 new (&_Container(dst)) Container(_Container(src));
638 static void _Destroy(_Storage &storage) {
639 _Container(storage).~Container();
642 static bool _CanHash(_Storage
const &storage) {
643 return ProxyHelper::CanHash(GetObj(storage));
646 static size_t _Hash(_Storage
const &storage) {
650 static bool _Equal(_Storage
const &lhs, _Storage
const &rhs) {
654 return ProxyHelper::Equal(GetObj(lhs), GetObj(rhs));
657 static bool _EqualPtr(_Storage
const &lhs,
void const *rhs) {
661 return ProxyHelper::Equal(
662 GetObj(lhs), *static_cast<T const *>(rhs));
665 static void _Move(_Storage &src, _Storage &dst) noexcept {
666 new (&_Container(dst)) Container(std::move(_Container(src)));
670 static void _MakeMutable(_Storage &storage) {
671 GetMutableObj(storage);
675 return ProxyHelper::GetPyObj(GetObj(storage));
678 static std::ostream &_StreamOut(
679 _Storage
const &storage, std::ostream &out) {
680 return ProxyHelper::StreamOut(GetObj(storage), out);
683 static std::type_info
const &_GetTypeid(_Storage
const &storage) {
684 return ProxyHelper::GetTypeid(GetObj(storage));
687 static bool _IsArrayValued(_Storage
const &storage) {
688 return ProxyHelper::IsArrayValued(GetObj(storage));
691 static std::type_info
const &
692 _GetElementTypeid(_Storage
const &storage) {
693 return ProxyHelper::GetElementTypeid(GetObj(storage));
696 static const Vt_ShapeData* _GetShapeData(_Storage
const &storage) {
697 return ProxyHelper::GetShapeData(GetObj(storage));
700 static size_t _GetNumElements(_Storage
const &storage) {
701 return ProxyHelper::GetNumElements(GetObj(storage));
705 _ProxyHoldsType(_Storage
const &storage, std::type_info
const &
t) {
706 return ProxyHelper::HoldsType(GetObj(storage), t);
710 _GetProxiedType(_Storage
const &storage) {
711 return ProxyHelper::GetTfType(GetObj(storage));
714 static std::type_info
const &
715 _GetProxiedTypeid(_Storage
const &storage) {
716 return ProxyHelper::GetTypeid(GetObj(storage));
720 _GetProxiedObjPtr(_Storage
const &storage) {
721 return ProxyHelper::GetObjPtr(GetObj(storage));
725 _GetProxiedAsVtValue(_Storage
const &storage) {
726 return ProxyHelper::GetProxiedAsVtValue(GetObj(storage));
732 static Container &_Container(_Storage &storage) {
734 return *
reinterpret_cast<Container *
>(&
storage);
736 static Container
const &_Container(_Storage
const &storage) {
738 return *
reinterpret_cast<Container
const *
>(&
storage);
746 struct _LocalTypeInfo : _TypeInfoImpl<
752 constexpr _LocalTypeInfo()
753 : _TypeInfoImpl<T, T, _LocalTypeInfo<T>>()
757 static T &_GetMutableObj(
T &
obj) {
return obj; }
758 static T const &_GetObj(
T const &obj) {
return obj; }
760 static void _PlaceCopy(
T *
dst,
T const &
src) {
new (
dst)
T(src); }
767 struct _RemoteTypeInfo : _TypeInfoImpl<
769 hboost::intrusive_ptr<_Counted<T> >,
773 constexpr _RemoteTypeInfo()
775 T, hboost::intrusive_ptr<_Counted<T>>, _RemoteTypeInfo<T>>()
778 typedef hboost::intrusive_ptr<_Counted<T> > Ptr;
780 static T &_GetMutableObj(Ptr &
ptr) {
781 if (!ptr->IsUnique())
782 ptr.reset(
new _Counted<T>(ptr->Get()));
783 return ptr->GetMutable();
785 static T const &_GetObj(Ptr
const &ptr) {
return ptr->Get(); }
787 static void _PlaceCopy(Ptr *
dst,
T const &
src) {
788 new (
dst) Ptr(
new _Counted<T>(src));
794 struct _TypeInfoFor {
798 _RemoteTypeInfo<T>>
Type;
803 struct _TypeInfoFor<char[N]> : _TypeInfoFor<std::string> {};
809 typedef typename _TypeInfoFor<T>::Type TI;
811 static constexpr
unsigned int flags =
812 (TI::IsLocal ? _LocalFlag : 0) |
813 (TI::HasTrivialCopy ? _TrivialCopyFlag : 0) |
814 (TI::IsProxy ? _ProxyFlag : 0);
827 : info((val->
IsEmpty() || val->_IsLocalAndTriviallyCopyable())
828 ? static_cast<_TypeInfo
const *>(NULL) : val->_info.
Get()) {
830 info->Move(val->_storage,
storage);
837 _TypeInfo
const *info;
843 _Init(
T const &
obj) {
844 _info = GetTypeInfo<T>();
846 TypeInfo::CopyInitObj(obj, _storage);
852 _Init(
T const &
obj) {
928 _TypeInfoFor<T>::Type::IsLocal &&
929 _TypeInfoFor<T>::Type::HasTrivialCopy,
946 !_TypeInfoFor<T>::Type::IsLocal ||
947 !_TypeInfoFor<T>::Type::HasTrivialCopy,
966 return *
this =
const_cast<char const *
>(cstr);
972 if (!
IsEmpty() || !rhs.IsEmpty()) {
1017 swap(_GetMutable<T>(), rhs);
1094 return *(
static_cast<T const *
>(
1095 _FailGet(Factory::Invoke,
typeid(
T))));
1107 return IsHolding<T>() ? UncheckedGet<T>() : def;
1111 template <
typename From,
typename To>
1113 _RegisterCast(
typeid(From),
typeid(To), castFn);
1118 template <
typename From,
typename To>
1120 _RegisterCast(
typeid(From),
typeid(To), _SimpleCast<From, To>);
1125 template <
typename From,
typename To>
1127 RegisterSimpleCast<From, To>();
1128 RegisterSimpleCast<To, From>();
1138 template <
typename T>
1141 return ret.
Cast<
T>();
1168 std::type_info
const &to) {
1169 return _CanCast(from, to);
1179 template <
typename T>
1183 return *
this = _PerformCast(
typeid(
T), *
this);
1206 *
this = _PerformCast(type, *
this);
1214 template <
typename T>
1247 template <
typename T>
1252 template <
typename T>
1258 template <
typename T>
1260 return !(lhs == rhs);
1262 template <
typename T>
1264 return !(lhs == rhs);
1270 if (empty || rhsEmpty) {
1272 return empty == rhsEmpty;
1276 return _info.
Get()->Equal(_storage, rhs._storage);
1278 return _EqualityImpl(rhs);
1283 VT_API friend std::ostream &
1288 VT_API size_t _GetNumElements()
const;
1298 dst._info = src._info;
1299 if (src._IsLocalAndTriviallyCopyable()) {
1300 dst._storage = src._storage;
1302 dst._info->CopyInit(src._storage, dst._storage);
1313 dst._info = src._info;
1314 if (src._IsLocalAndTriviallyCopyable()) {
1315 dst._storage = src._storage;
1317 dst._info->Move(src._storage, dst._storage);
1320 src._info.
Set(
nullptr, 0);
1324 inline bool _TypeIs()
const {
1325 std::type_info
const &
t =
typeid(
T);
1327 return ARCH_UNLIKELY(_IsProxy() && !cmp) ? _TypeIsImpl(t) : cmp;
1330 VT_API bool _TypeIsImpl(std::type_info
const &queriedType)
const;
1334 template <
class Proxy>
1338 return TypeInfo::GetMutableObj(_storage);
1346 *
this = _info->GetProxiedAsVtValue(_storage);
1349 return TypeInfo::GetMutableObj(_storage);
1352 template <
class Proxy>
1356 return TypeInfo::GetObj(_storage);
1364 return *
static_cast<T const *
>(_GetProxiedObjPtr());
1366 return TypeInfo::GetObj(_storage);
1369 void const *_GetProxiedObjPtr()
const {
1370 return _info->GetProxiedObjPtr(_storage);
1377 std::type_info
const &queryType)
const;
1379 inline void _Clear() {
1381 if (_info.
GetLiteral() && !_IsLocalAndTriviallyCopyable())
1382 _info.
Get()->Destroy(_storage);
1383 _info.
Set(
nullptr, 0);
1386 inline bool _IsLocalAndTriviallyCopyable()
const {
1387 unsigned int bits = _info.
BitsAs<
unsigned int>();
1388 return (bits & (_LocalFlag | _TrivialCopyFlag)) ==
1389 (_LocalFlag | _TrivialCopyFlag);
1392 inline bool _IsProxy()
const {
1393 return _info.
BitsAs<
unsigned int>() & _ProxyFlag;
1396 VT_API static void _RegisterCast(std::type_info
const &from,
1397 std::type_info
const &to,
1403 _PerformCast(std::type_info
const &to,
VtValue const &val);
1408 _CanCast(std::type_info
const &from, std::type_info
const &to);
1411 template <
typename From,
typename To>
1438 return Vt_DefaultValueHolder::Create<T>();
1444 return value._GetShapeData();
1448 return value._GetNumElements();
1462 #define _VT_DECLARE_ZERO_VALUE_FACTORY(r, unused, elem) \
1464 VT_API Vt_DefaultValueHolder Vt_DefaultValueFactory<VT_TYPE(elem)>::Invoke();
1472 #undef _VT_DECLARE_ZERO_VALUE_FACTORY
1481 VtValue::Get<VtValue>()
const {
1487 VtValue::UncheckedGet<VtValue>()
const {
1493 VtValue::IsHolding<VtValue>()
const {
1500 VtValue::IsHolding<void>()
const {
1510 #endif // PXR_BASE_VT_VALUE_H
T const & UncheckedGet() const
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.
GLboolean GLboolean GLboolean b
static Vt_DefaultValueHolder Create(T const &val)
STATIC_INLINE size_t Hash(const char *s, size_t len)
friend TfPyObjWrapper Vt_GetPythonObjectFromHeldValue(VtValue const &self)
static VtValue Take(T &obj)
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.
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.
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.
bool IsEmpty() const
Returns true iff this value is empty.
VtValue & operator=(char *cstr)
Assigning a char * gives a VtValue holding a std::string.
HBOOST_PP_SEQ_FOR_EACH(SDF_DECLARE_VALUE_TYPE_TRAITS,~, SDF_VALUE_TYPES)
T const & VtGetProxiedObject(T const &nonProxy)
static size_t _GetNumElements(const VtValue &value)
VtValue(VtValue const &other)
Copy construct with other.
IMATH_HOSTDEVICE constexpr int cmp(T a, T b) IMATH_NOEXCEPT
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)
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
GLboolean GLboolean GLboolean GLboolean a
GLsizei const GLchar *const * string
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.
#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)
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.
GLsizei const GLfloat * value
static void RegisterSimpleCast()
Register a simple cast from VtValue holding From to VtValue.
static Vt_DefaultValueHolder Invoke()
This function must return an object of type T.
getOption("OpenEXR.storage") storage
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
#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.