MCPcopy Create free account
hub / github.com/bytecodealliance/wit-bindgen / unexpected

Class unexpected

crates/cpp/test_headers/expected.hpp:142–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140#endif
141
142template <class E> class unexpected {
143public:
144 static_assert(!std::is_same<E, void>::value, "E must not be void");
145
146 unexpected() = delete;
147 constexpr explicit unexpected(const E &e) : m_val(e) {}
148
149 constexpr explicit unexpected(E &&e) : m_val(std::move(e)) {}
150
151 template <class... Args, typename std::enable_if<std::is_constructible<
152 E, Args &&...>::value>::type * = nullptr>
153 constexpr explicit unexpected(Args &&...args)
154 : m_val(std::forward<Args>(args)...) {}
155 template <
156 class U, class... Args,
157 typename std::enable_if<std::is_constructible<
158 E, std::initializer_list<U> &, Args &&...>::value>::type * = nullptr>
159 constexpr explicit unexpected(std::initializer_list<U> l, Args &&...args)
160 : m_val(l, std::forward<Args>(args)...) {}
161
162 constexpr const E &value() const & { return m_val; }
163 TL_EXPECTED_11_CONSTEXPR E &value() & { return m_val; }
164 TL_EXPECTED_11_CONSTEXPR E &&value() && { return std::move(m_val); }
165 constexpr const E &&value() const && { return std::move(m_val); }
166
167private:
168 E m_val;
169};
170
171#ifdef __cpp_deduction_guides
172template <class E> unexpected(E) -> unexpected<E>;

Callers 12

RoundtripResultMethod · 0.85
RunMethod · 0.85
EnumErrorMethod · 0.85
RecordErrorMethod · 0.85
VariantErrorMethod · 0.85
RunMethod · 0.85
StringErrorMethod · 0.85
EnumErrorMethod · 0.85
RecordErrorMethod · 0.85
VariantErrorMethod · 0.85
EmptyErrorMethod · 0.85
DoubleErrorMethod · 0.85

Calls

no outgoing calls

Tested by 1

RoundtripResultMethod · 0.68