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
}
template <class Ex, typename... As>
}
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>
: 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_) {}
: buff_{in_place_type<Ex>, std::forward<As>(as)...},
vptr_(&InPlace<Ex>::ops_) {}
Ex const& as() const noexcept;
};
Ex const& as() const noexcept;
};
- enum class Placement { kInSitu, kOnHeap };
+ struct InSituTag {};
+ struct OnHeapTag {};
+
- using PlacementOf = std::integral_constant<
- Placement,
+ using PlacementOf = _t<std::conditional<
sizeof(T) <= sizeof(Buffer::Storage) &&
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);
static std::exception const* as_exception_or_null_(std::exception const& ex);
static std::exception const* as_exception_or_null_(AnyException);