xref: /aosp_15_r20/external/pytorch/torch/csrc/api/include/torch/arg.h (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1 #pragma once
2 
3 #include <utility>
4 
5 #define TORCH_ARG(T, name)                                                \
6  public:                                                                  \
7   inline auto name(const T& new_##name) -> decltype(*this) { /* NOLINT */ \
8     this->name##_ = new_##name;                                           \
9     return *this;                                                         \
10   }                                                                       \
11   inline auto name(T&& new_##name) -> decltype(*this) { /* NOLINT */      \
12     this->name##_ = std::move(new_##name);                                \
13     return *this;                                                         \
14   }                                                                       \
15   inline const T& name() const noexcept { /* NOLINT */                    \
16     return this->name##_;                                                 \
17   }                                                                       \
18   inline T& name() noexcept { /* NOLINT */                                \
19     return this->name##_;                                                 \
20   }                                                                       \
21                                                                           \
22  private:                                                                 \
23   T name##_ /* NOLINT */
24