Loading base/include/android-base/expected.h +12 −0 Original line number Diff line number Diff line Loading @@ -111,6 +111,7 @@ class _NODISCARD_ expected { !(!std::is_convertible_v<const U&, T> || !std::is_convertible_v<const G&, E>) /* non-explicit */ )> // NOLINTNEXTLINE(google-explicit-constructor) constexpr expected(const expected<U, G>& rhs) { if (rhs.has_value()) var_ = rhs.value(); else var_ = unexpected(rhs.error()); Loading Loading @@ -149,6 +150,7 @@ class _NODISCARD_ expected { !(!std::is_convertible_v<const U&, T> || !std::is_convertible_v<const G&, E>) /* non-explicit */ )> // NOLINTNEXTLINE(google-explicit-constructor) constexpr expected(expected<U, G>&& rhs) { if (rhs.has_value()) var_ = std::move(rhs.value()); else var_ = unexpected(std::move(rhs.error())); Loading Loading @@ -180,6 +182,7 @@ class _NODISCARD_ expected { !std::is_same_v<unexpected<E>, std::remove_cv_t<std::remove_reference_t<U>>> && std::is_convertible_v<U&&, T> /* non-explicit */ )> // NOLINTNEXTLINE(google-explicit-constructor) constexpr expected(U&& v) : var_(std::in_place_index<0>, std::forward<U>(v)) {} template <class U = T _ENABLE_IF( Loading @@ -195,6 +198,7 @@ class _NODISCARD_ expected { std::is_constructible_v<E, const G&> && std::is_convertible_v<const G&, E> /* non-explicit */ )> // NOLINTNEXTLINE(google-explicit-constructor) constexpr expected(const unexpected<G>& e) : var_(std::in_place_index<1>, e.value()) {} Loading @@ -209,6 +213,7 @@ class _NODISCARD_ expected { std::is_constructible_v<E, G&&> && std::is_convertible_v<G&&, E> /* non-explicit */ )> // NOLINTNEXTLINE(google-explicit-constructor) constexpr expected(unexpected<G>&& e) : var_(std::in_place_index<1>, std::move(e.value())) {} Loading Loading @@ -457,6 +462,7 @@ class _NODISCARD_ expected<void, E> { std::is_void_v<U> && std::is_convertible_v<const G&, E> /* non-explicit */ )> // NOLINTNEXTLINE(google-explicit-constructor) constexpr expected(const expected<U, G>& rhs) { if (!rhs.has_value()) var_ = unexpected(rhs.error()); } Loading @@ -473,6 +479,7 @@ class _NODISCARD_ expected<void, E> { std::is_void_v<U> && std::is_convertible_v<const G&&, E> /* non-explicit */ )> // NOLINTNEXTLINE(google-explicit-constructor) constexpr expected(expected<U, G>&& rhs) { if (!rhs.has_value()) var_ = unexpected(std::move(rhs.error())); } Loading @@ -489,6 +496,7 @@ class _NODISCARD_ expected<void, E> { std::is_constructible_v<E, const G&> && std::is_convertible_v<const G&, E> /* non-explicit */ )> // NOLINTNEXTLINE(google-explicit-constructor) constexpr expected(const unexpected<G>& e) : var_(std::in_place_index<1>, e.value()) {} Loading @@ -503,6 +511,7 @@ class _NODISCARD_ expected<void, E> { std::is_constructible_v<E, G&&> && std::is_convertible_v<G&&, E> /* non-explicit */ )> // NOLINTNEXTLINE(google-explicit-constructor) constexpr expected(unexpected<G>&& e) : var_(std::in_place_index<1>, std::move(e.value())) {} Loading Loading @@ -640,6 +649,7 @@ class unexpected { std::is_constructible_v<E, Err> && !std::is_same_v<std::remove_cv_t<std::remove_reference_t<E>>, std::in_place_t> && !std::is_same_v<std::remove_cv_t<std::remove_reference_t<E>>, unexpected>)> // NOLINTNEXTLINE(google-explicit-constructor) constexpr unexpected(Err&& e) : val_(std::forward<Err>(e)) {} template<class U, class... Args _ENABLE_IF( Loading @@ -660,6 +670,7 @@ class unexpected { !std::is_convertible_v<const unexpected<Err>, E> && std::is_convertible_v<Err, E> /* non-explicit */ )> // NOLINTNEXTLINE(google-explicit-constructor) constexpr unexpected(const unexpected<Err>& rhs) : val_(rhs.value()) {} Loading Loading @@ -690,6 +701,7 @@ class unexpected { !std::is_convertible_v<const unexpected<Err>, E> && std::is_convertible_v<Err, E> /* non-explicit */ )> // NOLINTNEXTLINE(google-explicit-constructor) constexpr unexpected(unexpected<Err>&& rhs) : val_(std::move(rhs.value())) {} Loading base/include/android-base/result.h +3 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,7 @@ struct ResultError { ResultError(T&& message, int code) : message_(std::forward<T>(message)), code_(code) {} template <typename T> // NOLINTNEXTLINE(google-explicit-constructor) operator android::base::expected<T, ResultError>() { return android::base::unexpected(ResultError(message_, code_)); } Loading Loading @@ -118,9 +119,11 @@ inline std::ostream& operator<<(std::ostream& os, const ResultError& t) { class Error { public: Error() : errno_(0), append_errno_(false) {} // NOLINTNEXTLINE(google-explicit-constructor) Error(int errno_to_append) : errno_(errno_to_append), append_errno_(true) {} template <typename T> // NOLINTNEXTLINE(google-explicit-constructor) operator android::base::expected<T, ResultError>() { return android::base::unexpected(ResultError(str(), errno_)); } Loading Loading
base/include/android-base/expected.h +12 −0 Original line number Diff line number Diff line Loading @@ -111,6 +111,7 @@ class _NODISCARD_ expected { !(!std::is_convertible_v<const U&, T> || !std::is_convertible_v<const G&, E>) /* non-explicit */ )> // NOLINTNEXTLINE(google-explicit-constructor) constexpr expected(const expected<U, G>& rhs) { if (rhs.has_value()) var_ = rhs.value(); else var_ = unexpected(rhs.error()); Loading Loading @@ -149,6 +150,7 @@ class _NODISCARD_ expected { !(!std::is_convertible_v<const U&, T> || !std::is_convertible_v<const G&, E>) /* non-explicit */ )> // NOLINTNEXTLINE(google-explicit-constructor) constexpr expected(expected<U, G>&& rhs) { if (rhs.has_value()) var_ = std::move(rhs.value()); else var_ = unexpected(std::move(rhs.error())); Loading Loading @@ -180,6 +182,7 @@ class _NODISCARD_ expected { !std::is_same_v<unexpected<E>, std::remove_cv_t<std::remove_reference_t<U>>> && std::is_convertible_v<U&&, T> /* non-explicit */ )> // NOLINTNEXTLINE(google-explicit-constructor) constexpr expected(U&& v) : var_(std::in_place_index<0>, std::forward<U>(v)) {} template <class U = T _ENABLE_IF( Loading @@ -195,6 +198,7 @@ class _NODISCARD_ expected { std::is_constructible_v<E, const G&> && std::is_convertible_v<const G&, E> /* non-explicit */ )> // NOLINTNEXTLINE(google-explicit-constructor) constexpr expected(const unexpected<G>& e) : var_(std::in_place_index<1>, e.value()) {} Loading @@ -209,6 +213,7 @@ class _NODISCARD_ expected { std::is_constructible_v<E, G&&> && std::is_convertible_v<G&&, E> /* non-explicit */ )> // NOLINTNEXTLINE(google-explicit-constructor) constexpr expected(unexpected<G>&& e) : var_(std::in_place_index<1>, std::move(e.value())) {} Loading Loading @@ -457,6 +462,7 @@ class _NODISCARD_ expected<void, E> { std::is_void_v<U> && std::is_convertible_v<const G&, E> /* non-explicit */ )> // NOLINTNEXTLINE(google-explicit-constructor) constexpr expected(const expected<U, G>& rhs) { if (!rhs.has_value()) var_ = unexpected(rhs.error()); } Loading @@ -473,6 +479,7 @@ class _NODISCARD_ expected<void, E> { std::is_void_v<U> && std::is_convertible_v<const G&&, E> /* non-explicit */ )> // NOLINTNEXTLINE(google-explicit-constructor) constexpr expected(expected<U, G>&& rhs) { if (!rhs.has_value()) var_ = unexpected(std::move(rhs.error())); } Loading @@ -489,6 +496,7 @@ class _NODISCARD_ expected<void, E> { std::is_constructible_v<E, const G&> && std::is_convertible_v<const G&, E> /* non-explicit */ )> // NOLINTNEXTLINE(google-explicit-constructor) constexpr expected(const unexpected<G>& e) : var_(std::in_place_index<1>, e.value()) {} Loading @@ -503,6 +511,7 @@ class _NODISCARD_ expected<void, E> { std::is_constructible_v<E, G&&> && std::is_convertible_v<G&&, E> /* non-explicit */ )> // NOLINTNEXTLINE(google-explicit-constructor) constexpr expected(unexpected<G>&& e) : var_(std::in_place_index<1>, std::move(e.value())) {} Loading Loading @@ -640,6 +649,7 @@ class unexpected { std::is_constructible_v<E, Err> && !std::is_same_v<std::remove_cv_t<std::remove_reference_t<E>>, std::in_place_t> && !std::is_same_v<std::remove_cv_t<std::remove_reference_t<E>>, unexpected>)> // NOLINTNEXTLINE(google-explicit-constructor) constexpr unexpected(Err&& e) : val_(std::forward<Err>(e)) {} template<class U, class... Args _ENABLE_IF( Loading @@ -660,6 +670,7 @@ class unexpected { !std::is_convertible_v<const unexpected<Err>, E> && std::is_convertible_v<Err, E> /* non-explicit */ )> // NOLINTNEXTLINE(google-explicit-constructor) constexpr unexpected(const unexpected<Err>& rhs) : val_(rhs.value()) {} Loading Loading @@ -690,6 +701,7 @@ class unexpected { !std::is_convertible_v<const unexpected<Err>, E> && std::is_convertible_v<Err, E> /* non-explicit */ )> // NOLINTNEXTLINE(google-explicit-constructor) constexpr unexpected(unexpected<Err>&& rhs) : val_(std::move(rhs.value())) {} Loading
base/include/android-base/result.h +3 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,7 @@ struct ResultError { ResultError(T&& message, int code) : message_(std::forward<T>(message)), code_(code) {} template <typename T> // NOLINTNEXTLINE(google-explicit-constructor) operator android::base::expected<T, ResultError>() { return android::base::unexpected(ResultError(message_, code_)); } Loading Loading @@ -118,9 +119,11 @@ inline std::ostream& operator<<(std::ostream& os, const ResultError& t) { class Error { public: Error() : errno_(0), append_errno_(false) {} // NOLINTNEXTLINE(google-explicit-constructor) Error(int errno_to_append) : errno_(errno_to_append), append_errno_(true) {} template <typename T> // NOLINTNEXTLINE(google-explicit-constructor) operator android::base::expected<T, ResultError>() { return android::base::unexpected(ResultError(str(), errno_)); } Loading