/usr/include/measurement_kit/common/maybe.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 | // 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_MAYBE_HPP
#define MEASUREMENT_KIT_COMMON_MAYBE_HPP
#include <stdexcept>
#include <type_traits>
namespace mk {
template <typename T> class Maybe {
public:
Maybe() {}
Maybe(T &&t) : value_{std::move(t)}, valid_{true} {}
#define IMPL \
if (!valid_) { \
throw std::runtime_error("Maybe is empty"); \
} \
return value_
T &operator*() { IMPL; }
const T &operator*() const { IMPL; }
#undef IMPL
operator bool() const { return valid_; }
private:
T value_ = {};
bool valid_ = false;
};
} // namespace mk
#endif
|