7#ifndef PXR_BASE_VT_VISIT_VALUE_H
8#define PXR_BASE_VT_VISIT_VALUE_H
12#include "pxr/base/vt/value.h"
14PXR_NAMESPACE_OPEN_SCOPE
16namespace Vt_ValueVisitDetail {
21template <
class T,
class Visitor,
22 class =
decltype(std::declval<Visitor>()(std::declval<T>()))>
24Visit(
VtValue const &val, Visitor &&visitor,
int) {
25 return std::forward<Visitor>(visitor)(val.
UncheckedGet<T>());
28template <
class T,
class Visitor>
30Visit(
VtValue const &val, Visitor &&visitor, ...) {
31 return std::forward<Visitor>(visitor)(val);
87template <
class Visitor>
88auto VtVisitValue(
VtValue const &value, Visitor &&visitor)
95#define VT_CASE_FOR_TYPE_INDEX(unused, elem) \
96 case VtGetKnownValueTypeIndex<VT_TYPE(elem)>(): \
97 return Vt_ValueVisitDetail::Visit<VT_TYPE(elem)>( \
98 value, std::forward<Visitor>(visitor), 0); \
100VT_FOR_EACH_VALUE_TYPE(VT_CASE_FOR_TYPE_INDEX)
101#undef VT_CASE_FOR_TYPE_INDEX
105 return Vt_ValueVisitDetail::Visit<VtValue>(
106 value, std::forward<Visitor>(visitor), 0);
111PXR_NAMESPACE_CLOSE_SCOPE
Provides a container which may hold any type, and provides introspection and iteration over array typ...
int GetKnownValueTypeIndex() const
Return VtKnownValueTypeIndex<T> for the held type T.
T const & UncheckedGet() const &
Returns a const reference to the held object if the held object is of type T.