Commit a335700f authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Use simpler tags for ctor dispatch in exception_wrapper

Summary:
[Folly] Use simpler tags for ctor dispatch in `exception_wrapper`.

The tags do not need to be `std::integral_constant`, but can just be arbitrary empty types.

Also format the usage sites of the tags.

Reviewed By: ericniebler

Differential Revision: D6506417

fbshipit-source-id: 377359086d94fc1a8bf8eebf6f8b058ff544829f
parent fd0b3090
......@@ -281,12 +281,18 @@ inline exception_wrapper exception_wrapper::SharedPtr::get_exception_ptr_(
}
template <class Ex, typename... As>
inline exception_wrapper::exception_wrapper(OnHeapTag, in_place_type_t<Ex>, As&&... as)
inline exception_wrapper::exception_wrapper(
OnHeapTag,
in_place_type_t<Ex>,
As&&... as)
: sptr_{std::make_shared<SharedPtr::Impl<Ex>>(std::forward<As>(as)...)},
vptr_(&SharedPtr::ops_) {}
template <class Ex, typename... As>
inline exception_wrapper::exception_wrapper(InSituTag, in_place_type_t<Ex>, As&&... as)
inline exception_wrapper::exception_wrapper(
InSituTag,
in_place_type_t<Ex>,
As&&... as)
: buff_{in_place_type<Ex>, std::forward<As>(as)...},
vptr_(&InPlace<Ex>::ops_) {}
......
......@@ -235,18 +235,16 @@ class exception_wrapper final {
Ex const& as() const noexcept;
};
enum class Placement { kInSitu, kOnHeap };
struct InSituTag {};
struct OnHeapTag {};
template <class T>
using PlacementOf = std::integral_constant<
Placement,
using PlacementOf = _t<std::conditional<
sizeof(T) <= sizeof(Buffer::Storage) &&
alignof(T) <= alignof(Buffer::Storage) &&
noexcept(T(std::declval<T&&>()))
? Placement::kInSitu
: Placement::kOnHeap>;
using InSituTag = std::integral_constant<Placement, Placement::kInSitu>;
using OnHeapTag = std::integral_constant<Placement, Placement::kOnHeap>;
alignof(T) <= alignof(Buffer::Storage) &&
noexcept(T(std::declval<T&&>())),
InSituTag,
OnHeapTag>>;
static std::exception const* as_exception_or_null_(std::exception const& ex);
static std::exception const* as_exception_or_null_(AnyException);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment