#include "macros.hh" namespace error { struct Error { DEFINE_INTERFACE(Error); constexpr Error() noexcept = default; constexpr operator std::string_view() const noexcept { return message(); } constexpr virtual std::string_view message() const noexcept =0; constexpr virtual Error const* inner() const noexcept { return nullptr; } // TODO: `borrow::Borrow (using std::pointer_traits<>) PtrType = T*>` (borrow.hh): essentially specialised `std::variant` constexpr virtual borrow::Borrow report() const& { return borrow::Borrow{ nullptr }; } // constexpr virtual borrow::Borrow report() & { return borrow::Borrow{ nullptr }; } constexpr virtual borrow::Borrow report() & { return borrow::Borrow{ nullptr }; } constexpr virtual borrow::Borrow:into_owned_t report() && { return borrow::Borrow{ nullptr }.into_owned(); } // <- Will initialise with `into_owned() &&` member function, which `std::move()`s the value from the pointer instead of just copying the pointer. XXX: How do we actually want this borrowing interface to behave, huh? }; }