|
|
template<class T , class... Args> |
| constexpr T * | iceberg::expected_detail::construct_at (T *p, Args &&... args) noexcept(noexcept(::new(static_cast< void * >(p)) T(std::forward< Args >(args)...))) |
| |
|
constexpr bool | iceberg::expected_detail::implicitly_convert_to_bool (bool value) noexcept |
| |
|
template<class E > |
| | iceberg::unexpected (E) -> unexpected< E > |
| |
|
template<class Rhs > |
| constexpr bool | iceberg::expected_detail::expected_source_has_value (const Rhs &rhs) noexcept |
| |
|
template<class Rhs > |
| constexpr decltype(auto) | iceberg::expected_detail::expected_source_value (Rhs &&rhs) noexcept |
| |
|
template<class Rhs > |
| constexpr decltype(auto) | iceberg::expected_detail::expected_source_error (Rhs &&rhs) noexcept |
| |
|
template<class First , class Second , class... Args> |
| constexpr void | iceberg::expected_detail::reinit_expected (First &new_val, Second &old_val, Args &&... args) noexcept(std::is_nothrow_constructible_v< First, Args... >) |
| |
|
template<class T , class E , std::enable_if_t<!std::is_void_v< T > &&std::is_move_constructible_v< T > &&std::is_swappable_v< T > &&std::is_move_constructible_v< E > &&std::is_swappable_v< E > &&(std::is_nothrow_move_constructible_v< T >||std::is_nothrow_move_constructible_v< E >)> * = nullptr> |
| constexpr void | iceberg::swap (expected< T, E > &lhs, expected< T, E > &rhs) noexcept(noexcept(lhs.swap(rhs))) |
| |
|
template<class T , class E , class T2 > |
| constexpr std::enable_if_t< !std::is_void_v< T > &&!expected_detail::is_specialization_v< T2, iceberg::expected > &&expected_detail::is_equality_result_convertible_to_bool_v< T, T2 >, bool > | iceberg::operator== (const T2 &v, const expected< T, E > &x) noexcept(noexcept(x==v)) |
| |
|
template<class T , class E , class T2 > |
| constexpr std::enable_if_t< !std::is_void_v< T > &&!expected_detail::is_specialization_v< T2, iceberg::expected > &&expected_detail::is_equality_result_convertible_to_bool_v< T, T2 >, bool > | iceberg::operator!= (const T2 &v, const expected< T, E > &x) noexcept(noexcept(x==v)) |
| |
|
template<class T , class E , class E2 , std::enable_if_t< expected_detail::is_equality_result_convertible_to_bool_v< E, E2 > > * = nullptr> |
| constexpr bool | iceberg::operator== (const unexpected< E2 > &e, const expected< T, E > &x) noexcept(noexcept(x==e)) |
| |
|
template<class T , class E , class E2 , std::enable_if_t< expected_detail::is_equality_result_convertible_to_bool_v< E, E2 > > * = nullptr> |
| constexpr bool | iceberg::operator!= (const unexpected< E2 > &e, const expected< T, E > &x) noexcept(noexcept(x==e)) |
| |
|
template<class E , std::enable_if_t< std::is_move_constructible_v< E > &&std::is_swappable_v< E > > * = nullptr> |
| constexpr void | iceberg::swap (expected< void, E > &lhs, expected< void, E > &rhs) noexcept(noexcept(lhs.swap(rhs))) |
| |
|
| template<class T , template< class... > class Template> |
| constexpr bool | iceberg::expected_detail::is_specialization_v |
| |
|
template<template< class... > class Template, class... Types> |
| constexpr bool | iceberg::expected_detail::is_specialization_v< Template< Types... >, Template > = true |
| |
|
template<class T , class U > |
| constexpr bool | iceberg::expected_detail::is_void_or_v = is_void_or<T, U>::value |
| |
| template<class T > |
| constexpr bool | iceberg::expected_detail::is_trivially_destructible_or_void_v |
| |
| template<class T > |
| constexpr bool | iceberg::expected_detail::is_trivially_copy_constructible_or_void_v |
| |
| template<class T > |
| constexpr bool | iceberg::expected_detail::is_trivially_move_constructible_or_void_v |
| |
| template<class T > |
| constexpr bool | iceberg::expected_detail::is_trivially_copy_assignable_or_void_v |
| |
| template<class T > |
| constexpr bool | iceberg::expected_detail::is_trivially_move_assignable_or_void_v |
| |
| template<class T > |
| constexpr bool | iceberg::expected_detail::is_nothrow_copy_constructible_or_void_v |
| |
| template<class T > |
| constexpr bool | iceberg::expected_detail::is_nothrow_move_constructible_or_void_v |
| |
| template<class T > |
| constexpr bool | iceberg::expected_detail::is_default_constructible_or_void_v |
| |
| template<class T > |
| constexpr bool | iceberg::expected_detail::is_copy_constructible_or_void_v |
| |
| template<class T > |
| constexpr bool | iceberg::expected_detail::is_move_constructible_or_void_v |
| |
| template<class T > |
| constexpr bool | iceberg::expected_detail::is_copy_assignable_or_void_v |
| |
| template<class T > |
| constexpr bool | iceberg::expected_detail::is_move_assignable_or_void_v |
| |
| template<class From , class To > |
| constexpr bool | iceberg::expected_detail::is_nothrow_convertible_v |
| |
| template<class Lhs , class Rhs > |
| constexpr bool | iceberg::expected_detail::is_equality_result_convertible_to_bool_v |
| |
| template<class Lhs , class Rhs > |
| constexpr bool | iceberg::expected_detail::is_nothrow_equality_result_convertible_to_bool_v |
| |
|
template<class T > |
| constexpr bool | iceberg::expected_detail::is_error_type_valid_v = is_error_type_valid<T>::value |
| |
|
constexpr unexpect_t | iceberg::unexpect {} |
| |
|
constexpr construct_from_expected_t | iceberg::expected_detail::construct_from_expected {} |
| |
|
constexpr construct_with_invoke_result_t | iceberg::expected_detail::construct_with_invoke_result {} |
| |
| template<class T , class E > |
| constexpr bool | iceberg::expected_detail::is_expected_copy_assignable_v |
| |
| template<class T , class E > |
| constexpr bool | iceberg::expected_detail::is_expected_trivially_copy_assignable_v |
| |
| template<class T , class E > |
| constexpr bool | iceberg::expected_detail::is_expected_move_assignable_v |
| |
| template<class T , class E > |
| constexpr bool | iceberg::expected_detail::is_expected_trivially_move_assignable_v |
| |
A C++20 backport of C++23 std::expected, used as the storage type behind iceberg::Result.
Purpose: the library is developed and built as C++23. Compatibility-mode packages additionally support C++20 consumers. iceberg::Result<T> (see iceberg/result.h) uses the same iceberg::expected type in both package modes rather than selecting a storage type per translation unit. The API mirrors std::expected (including the monadic and_then, or_else, transform and transform_error), so code can be written as if against the standard type.
Upstream: https://github.com/zeus-cpp/expected (MIT), include/zeus/expected.hpp at tag v1.4.0 (f9dde3b062f1b3a5d1a9f2888e4b6f6d2303557b).
Local changes (search for "iceberg:" for the non-mechanical ones):
- Namespace
zeus and its versioned inline ABI namespace replaced by plain iceberg, so symbol names stay stable across upstream updates; macros renamed from ZEUS_EXPECTED_* to ICEBERG_EXPECTED_*, and the upstream version macros removed.
- Public classes annotated with
ICEBERG_EXPORT, except the primary expected template, which uses ICEBERG_TEMPLATE_CLASS_EXPORT (empty on MSVC, where exporting a class template breaks the Windows build).
[[nodiscard]] added to unexpected and expected.
- The default constructor no longer requires
T to be default constructible, so expected<T, E> can hold types with no (or a private) default constructor, which MSVC otherwise tried to instantiate.
- The default package retains construction from
std::unexpected<G> when available. Compatibility packages omit those constructors in all language modes so the class definition remains the same for library and consumer.
- Reformatted with clang-format.
History:
- apache/iceberg-cpp#40 first vendored zeus-cpp/expected (v1.2.0) while the project targeted C++20.
- apache/iceberg-cpp#139 raised the project to C++23 and removed the header in favor of
std::expected, which made C++23 a requirement for users of the public headers too.
- apache/iceberg-cpp#936 vendored it again, updated to v1.4.0, so the public headers work in C++20 again.
Once C++23 can be required of all consumers, this header can be dropped and iceberg::Result aliased back to std::expected.