1 #ifndef LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_ABSL_TYPES_OPTIONAL_H_ 2 #define LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_ABSL_TYPES_OPTIONAL_H_ 3 4 /// Mock of `absl::optional`. 5 namespace absl { 6 7 // clang-format off 8 template <typename T> struct remove_reference { using type = T; }; 9 template <typename T> struct remove_reference<T&> { using type = T; }; 10 template <typename T> struct remove_reference<T&&> { using type = T; }; 11 // clang-format on 12 13 template <typename T> 14 using remove_reference_t = typename remove_reference<T>::type; 15 16 template <typename T> 17 constexpr T &&forward(remove_reference_t<T> &t) noexcept; 18 19 template <typename T> 20 constexpr T &&forward(remove_reference_t<T> &&t) noexcept; 21 22 template <typename T> 23 constexpr remove_reference_t<T> &&move(T &&x); 24 25 struct nullopt_t { 26 constexpr explicit nullopt_t() {} 27 }; 28 29 constexpr nullopt_t nullopt; 30 31 template <typename T> 32 class optional { 33 public: 34 constexpr optional() noexcept; 35 36 constexpr optional(nullopt_t) noexcept; 37 38 optional(const optional &) = default; 39 40 optional(optional &&) = default; 41 42 const T &operator*() const &; 43 T &operator*() &; 44 const T &&operator*() const &&; 45 T &&operator*() &&; 46 47 const T *operator->() const; 48 T *operator->(); 49 50 const T &value() const &; 51 T &value() &; 52 const T &&value() const &&; 53 T &&value() &&; 54 55 constexpr explicit operator bool() const noexcept; 56 constexpr bool has_value() const noexcept; 57 58 template <typename U> 59 constexpr T value_or(U &&v) const &; 60 template <typename U> 61 T value_or(U &&v) &&; 62 63 template <typename... Args> 64 T &emplace(Args &&...args); 65 66 void reset() noexcept; 67 68 void swap(optional &rhs) noexcept; 69 70 template <typename U> optional &operator=(const U &u); 71 }; 72 73 } // namespace absl 74 75 #endif // LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_ABSL_TYPES_OPTIONAL_H_ 76