/usr/include/measurement_kit/common/error_or.hpp is in libmeasurement-kit-dev 0.7.1-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | // Part of measurement-kit <https://measurement-kit.github.io/>.
// Measurement-kit is free software. See AUTHORS and LICENSE for more
// information on the copying conditions.
#ifndef MEASUREMENT_KIT_COMMON_ERROR_OR_HPP
#define MEASUREMENT_KIT_COMMON_ERROR_OR_HPP
#include <measurement_kit/common/error.hpp>
namespace mk {
template <typename T> class ErrorOr {
public:
ErrorOr() : error_(NotInitializedError()) {}
ErrorOr(T value) : value_(value) {}
ErrorOr(Error error) : error_(error) {}
ErrorOr(Error error, T value) : error_(error), value_(value) {}
operator bool() const { return error_ == NoError(); }
#define XX \
if (error_ != 0) { \
throw error_; \
} \
return value_;
const T &as_value() const { XX }
T &as_value() { XX }
#undef XX
Error as_error() const { return error_; }
const T &operator*() const { return as_value(); }
T &operator*() { return as_value(); }
#define XX \
if (error_ != 0) { \
throw error_; \
} \
return &value_;
const T *operator->() const { XX }
T *operator->() { XX }
#undef XX
private:
Error error_;
T value_;
};
} // namespace mk
#endif
|