Skip to content

Commit bd1f288

Browse files
yfeldblumfacebook-github-bot
authored andcommitted
exception_wrapper::exception_ptr accesor
Summary: Add accessor family `exception_wrapper::exception_ptr` which returns a reference to the contained `std::exception_ptr`. Follows `std::get`, `std::optional::value`, `std::expected::value`, `std::expected::error`. Reviewed By: dmm-fb, snarkmaster Differential Revision: D74182146 fbshipit-source-id: 64b4140996679196ad66154d2e4a5395e6483a81
1 parent 450317b commit bd1f288

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

folly/ExceptionWrapper-inl.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,20 @@ inline std::exception_ptr exception_wrapper::to_exception_ptr()
153153
return ptr_;
154154
}
155155

156-
inline std::exception_ptr const& exception_wrapper::exception_ptr_ref()
157-
const noexcept {
156+
inline std::exception_ptr& exception_wrapper::exception_ptr() & noexcept {
158157
return ptr_;
159158
}
159+
inline std::exception_ptr const& exception_wrapper::exception_ptr()
160+
const& noexcept {
161+
return ptr_;
162+
}
163+
inline std::exception_ptr&& exception_wrapper::exception_ptr() && noexcept {
164+
return std::move(ptr_);
165+
}
166+
inline std::exception_ptr const&& exception_wrapper::exception_ptr()
167+
const&& noexcept {
168+
return std::move(ptr_);
169+
}
160170

161171
inline std::type_info const* exception_wrapper::type() const noexcept {
162172
return exception_ptr_get_type(ptr_);

folly/ExceptionWrapper.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,11 @@ class exception_wrapper final {
228228
std::exception_ptr to_exception_ptr() const& noexcept;
229229
// NB: Can add this back, if a good use-case arises.
230230
std::exception_ptr to_exception_ptr() && = delete;
231-
std::exception_ptr const& exception_ptr_ref() const noexcept;
231+
232+
std::exception_ptr& exception_ptr() & noexcept;
233+
std::exception_ptr const& exception_ptr() const& noexcept;
234+
std::exception_ptr&& exception_ptr() && noexcept;
235+
std::exception_ptr const&& exception_ptr() const&& noexcept;
232236

233237
//! \return `true` if the wrappers point to the same exception object
234238
friend inline bool operator==(

folly/result/result.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class non_value_result {
227227

228228
friend inline bool operator==(
229229
const non_value_result& lhs, const non_value_result& rhs) {
230-
return lhs.ew_.exception_ptr_ref() == rhs.ew_.exception_ptr_ref();
230+
return lhs.ew_ == rhs.ew_;
231231
}
232232

233233
// DO NOT USE these "legacy" functions outside of `folly` internals. Instead:

0 commit comments

Comments
 (0)