7#ifndef PXR_EXEC_VDF_FIXED_SIZE_HOLDER_H
8#define PXR_EXEC_VDF_FIXED_SIZE_HOLDER_H
19PXR_NAMESPACE_OPEN_SCOPE
24class Vdf_FixedSizeHolderRemoteStorage
27 Vdf_FixedSizeHolderRemoteStorage() {
29 __ARCH_PRETTY_FUNCTION__);
30 _pointer.reset(
new T);
34 explicit Vdf_FixedSizeHolderRemoteStorage(U &&value) {
36 __ARCH_PRETTY_FUNCTION__);
37 _pointer.reset(
new T(std::forward<U>(value)));
40 Vdf_FixedSizeHolderRemoteStorage(
41 Vdf_FixedSizeHolderRemoteStorage
const &other) {
43 __ARCH_PRETTY_FUNCTION__);
44 _pointer.reset(
new T(other.Get()));
46 Vdf_FixedSizeHolderRemoteStorage &operator=(
47 Vdf_FixedSizeHolderRemoteStorage
const &other) {
50 __ARCH_PRETTY_FUNCTION__);
51 _pointer.reset(
new T(other.Get()));
56 Vdf_FixedSizeHolderRemoteStorage(
57 Vdf_FixedSizeHolderRemoteStorage &&) =
default;
58 Vdf_FixedSizeHolderRemoteStorage &operator=(
59 Vdf_FixedSizeHolderRemoteStorage &&) =
default;
61 inline T
const &Get()
const {
64 inline T &GetMutable() {
68 std::unique_ptr<T> _pointer;
74class Vdf_FixedSizeHolderLocalStorage
77 Vdf_FixedSizeHolderLocalStorage() =
default;
80 explicit Vdf_FixedSizeHolderLocalStorage(U &&value)
81 : _value(
std::forward<U>(value))
83 inline T
const &Get()
const {
86 inline T &GetMutable() {
105template <
class T,
size_t Size>
110 static_assert(
sizeof(Vdf_FixedSizeHolderRemoteStorage<int>) <= Size,
111 "Size too small to allow remote storage");
115 typedef typename std::conditional<
117 Vdf_FixedSizeHolderLocalStorage<T>,
118 Vdf_FixedSizeHolderRemoteStorage<T>
119 >::type _StorageType;
136 : _storage(other._storage)
141 : _storage(std::move(other._storage))
146 _storage.~_StorageType();
150 _storage = other._storage;
155 _storage = std::move(other._storage);
159 inline T
const &Get()
const {
160 return _storage.Get();
163 inline T &GetMutable() {
164 return _storage.GetMutable();
167 inline void Set(T
const &value) {
168 _storage.GetMutable() = value;
171 inline void Set(T &&value) {
172 _storage.GetMutable() = std::move(value);
177 _StorageType _storage;
182PXR_NAMESPACE_CLOSE_SCOPE
Vdf_FixedSizeHolder holds an object of type T of any size, but the sizeof(Vdf_FixedSizeHolder<T>) is ...
Define preprocessor function name macros.