53 using type =
typename T::generic_type;
118 template<
typename T,
typename... Args>
T &
emplace(Args &&...args);
135 template<
typename T>
T copy_as()
const;
149 template<
typename T>
const T *
get_if()
const;
150 template<
typename T>
T *
get_if();
196 template<
typename T>
T &init_default();
197 void *init_default(
const CPPType &type);
216 value_variant->
emplace<std::decay_t<T>>(std::forward<T>(value));
217 return *value_variant;
223 value_variant.
emplace<std::decay_t<T>>(std::forward<T>(value));
224 return value_variant;
229 using StorageT = to_storage_type<T>;
230 StorageT &value = value_.emplace<StorageT>(
T(std::forward<Args>(args)...));
231 static_assert(
sizeof(
T) ==
sizeof(StorageT));
232 return reinterpret_cast<T &
>(value);
237 using StorageT = to_storage_type<T>;
238 if (!value_.has_value()) {
241 const Info &info = value_.extra_info();
243 if (info.
type == requested_type) {
244 return &
reinterpret_cast<T &
>(value_.get<StorageT>());
247 return &
reinterpret_cast<T &
>(value_.get<StorageT>());
249 if (!info.
convert_to(requested_type, value_)) {
252 BLI_assert(value_.extra_info().is_interpretable_as(requested_type, value_));
253 return &
reinterpret_cast<T &
>(value_.get<StorageT>());
258 if (!value_.has_value()) {
261 const Info &info = value_.extra_info();
262 if (info.
type == type) {
274 return this->init_default<T>();
282 return this->init_default(type);
290 return copy.extract<
T>();
298 const Info &info = value_.extra_info();
300 if (info.
type == requested_type) {
301 return &value_.get<
T>();
305 using GenericT = T::generic_type;
306 return reinterpret_cast<const T *
>(&value_.get<GenericT>());
309 return &value_.get<
T>();
317 return const_cast<T *
>(std::as_const(*this).get_if<
T>());
325 const Info &info = value_.extra_info();
326 if (info.
type == type) {
337 return const_cast<void *
>(std::as_const(*this).get_if(type));
345 const Info &info = value_.extra_info();
346 return {info.
type, value_.
get()};
354 const Info &info = value_.extra_info();
355 return {info.
type, value_.
get()};
358template<
typename T>
inline T &SocketValueVariant::init_default()
360 return SocketValueVariant::init_default<T>(value_);
363inline void *SocketValueVariant::init_default(
const CPPType &type)
365 return SocketValueVariant::init_default(type, value_);
static const CPPType & get()
const CPPType * generic_type
static const CPPType * get_pre_register()
bool owns_direct_data() const
T & emplace(Args &&...args)
bool is_context_dependent_field() const
void ensure_owns_direct_data()
void * allocate_single(const CPPType &type)
void count_memory(MemoryCounter &memory) const
bool is_volume_grid() const
static SocketValueVariant & construct_in(void *ptr, T &&value)
SocketValueVariant()=default
static SocketValueVariant from(T &&value)
static void * allocate(const CPPType &type, detail::SocketValueVariantAny &value)
Any< SocketValueVariantTypeInfo, 32, 16 > SocketValueVariantAny
const CPPType & to_storage_type(const CPPType &type)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
constexpr bool is_same_any_v
static bool try_convert_fn(const CPPType &dst_type, SocketValueVariantAny &value)
static SocketValueVariantTypeInfo get()
bool(*) is_interpretable_as(const CPPType &dst_type, const SocketValueVariantAny &value)
bool(*) convert_to(const CPPType &dst_type, SocketValueVariantAny &value)
static bool is_interpretable_as_fn(const CPPType &dst_type, const SocketValueVariantAny &value)
typename T::generic_type type