24 #ifndef PXR_BASE_TF_FUNCTION_REF_H 25 #define PXR_BASE_TF_FUNCTION_REF_H 30 #include <type_traits> 33 PXR_NAMESPACE_OPEN_SCOPE
98 template <
class Ret,
class... Args>
105 : _fn(static_cast<void const *>(std::addressof(fn)))
106 , _invoke(_InvokeFn<Fn>) {}
120 operator=(Fn &fn) noexcept {
133 inline Ret operator()(Args... args)
const {
134 return _invoke(_fn, std::forward<Args>(args)...);
139 static Ret _InvokeFn(
void const *fn, Args...args) {
140 using FnPtr =
typename std::add_pointer<
141 typename std::add_const<Fn>::type>::type;
142 return (*static_cast<FnPtr>(fn))(std::forward<Args>(args)...);
146 Ret (*_invoke)(
void const *, Args...);
157 PXR_NAMESPACE_CLOSE_SCOPE
159 #endif // PXR_BASE_TF_FUNCTION_REF_H void swap(ArAssetInfo &lhs, ArAssetInfo &rhs)
This class provides a non-owning reference to a type-erased callable object with a specified signatur...
void swap(UsdStageLoadRules &l, UsdStageLoadRules &r)
Swap the contents of rules l and r.