7#ifndef PXR_BASE_TF_TRY_INVOKE_H
8#define PXR_BASE_TF_TRY_INVOKE_H
28 if constexpr (std::is_void_v<Ret>) {
31 return std::optional<Ret>{};
66template <
class Ret,
class Fn,
class... Args>
70 if constexpr (std::is_invocable_v<Fn, Args...>) {
71 if constexpr (std::is_void_v<Ret>) {
72 std::invoke(std::forward<Fn>(fn), std::forward<Args>(args)...);
75 return std::optional<Ret>(
76 std::invoke(std::forward<Fn>(fn), std::forward<Args>(args)...));
79 return TfNotInvoked<Ret>();
constexpr auto TfNotInvoked()
Return the result type of TfTryInvoke<Ret> in the case where the function was not invoked – false if ...
auto TfTryInvoke(Fn &&fn, Args &&...args)
Invoke fn with args if fn is invocable with those arguments and return a result that indicates both w...