operator* and operator-> for uresult

This commit is contained in:
BlackMATov
2023-02-18 02:51:12 +07:00
parent d6ba3d8ce4
commit 46ff71ea79
4 changed files with 111 additions and 21 deletions

View File

@@ -123,10 +123,18 @@ namespace meta_hpp
[[nodiscard]] bool has_value() const noexcept;
[[nodiscard]] explicit operator bool() const noexcept;
[[nodiscard]] uvalue& get_value() &;
[[nodiscard]] uvalue&& get_value() &&;
[[nodiscard]] const uvalue& get_value() const&;
[[nodiscard]] const uvalue&& get_value() const&&;
[[nodiscard]] uvalue* operator->() noexcept;
[[nodiscard]] const uvalue* operator->() const noexcept;
[[nodiscard]] uvalue& operator*() & noexcept;
[[nodiscard]] uvalue&& operator*() && noexcept;
[[nodiscard]] const uvalue& operator*() const& noexcept;
[[nodiscard]] const uvalue&& operator*() const&& noexcept;
[[nodiscard]] uvalue& get_value() & noexcept;
[[nodiscard]] uvalue&& get_value() && noexcept;
[[nodiscard]] const uvalue& get_value() const& noexcept;
[[nodiscard]] const uvalue&& get_value() const&& noexcept;
[[nodiscard]] error_code get_error() const noexcept;

View File

@@ -120,19 +120,44 @@ namespace meta_hpp
return has_value();
}
inline uvalue& uresult::get_value() & {
inline uvalue* uresult::operator->() noexcept {
return std::addressof(value_);
}
inline const uvalue* uresult::operator->() const noexcept {
return std::addressof(value_);
}
inline uvalue& uresult::operator*() & noexcept {
return value_;
}
inline uvalue&& uresult::get_value() && {
inline uvalue&& uresult::operator*() && noexcept {
return std::move(value_);
}
inline const uvalue& uresult::get_value() const& {
inline const uvalue& uresult::operator*() const& noexcept {
return value_;
}
inline const uvalue&& uresult::get_value() const&& {
inline const uvalue&& uresult::operator*() const&& noexcept {
// NOLINTNEXTLINE(*-move-const-arg)
return std::move(value_);
}
inline uvalue& uresult::get_value() & noexcept {
return value_;
}
inline uvalue&& uresult::get_value() && noexcept {
return std::move(value_);
}
inline const uvalue& uresult::get_value() const& noexcept {
return value_;
}
inline const uvalue&& uresult::get_value() const&& noexcept {
// NOLINTNEXTLINE(*-move-const-arg)
return std::move(value_);
}