MCPcopy Create free account
hub / github.com/ashvardanian/less_slow.cpp / expected

Class expected

less_slow.cpp:6166–6181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6164
6165template <typename value_type_>
6166class expected {
6167 std::variant<value_type_, std::error_code> value_;
6168
6169 public:
6170 expected(value_type_ const &value) noexcept : value_(value) {}
6171 expected(std::error_code const &error) noexcept : value_(error) {}
6172
6173 explicit operator bool() const noexcept { return std::holds_alternative<value_type_>(value_); }
6174 value_type_ const &value() const noexcept { return std::get<value_type_>(value_); }
6175 std::error_code const &error() const noexcept { return std::get<std::error_code>(value_); }
6176 template <typename function_type_>
6177 auto and_then(function_type_ &&f) const noexcept {
6178 if (std::holds_alternative<value_type_>(value_)) return f(std::get<value_type_>(value_));
6179 return *this;
6180 }
6181};
6182
6183static expected<std::string> read_integer_from_file_or_variants( //
6184 [[maybe_unused]] std::string const &filename, std::size_t iteration_index) noexcept {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected