32 #include <glog/logging.h> 38 #if !FOLLY_X64 && !FOLLY_AARCH64 && !FOLLY_PPC64 39 #error "DiscriminatedPtr is x64, arm64 and ppc64 specific code." 56 template <
typename... Types>
75 set(
ptr, typeIndex<T>());
84 set(
ptr, typeIndex<T>());
95 void* p =
LIKELY(hasType<T>()) ?
ptr() :
nullptr;
96 return static_cast<T*
>(p);
101 const void* p =
LIKELY(hasType<T>()) ?
ptr() :
nullptr;
102 return static_cast<const T*
>(p);
111 template <
typename T>
114 throw std::invalid_argument(
"Invalid type");
116 return static_cast<T*
>(
ptr());
119 template <
typename T>
120 const T*
get()
const {
122 throw std::invalid_argument(
"Invalid type");
124 return static_cast<const T*
>(
ptr());
139 template <
typename T>
141 return index() == typeIndex<T>();
154 template <
typename T>
173 template <
typename V>
177 throw std::invalid_argument(
"Empty DiscriminatedPtr");
180 n, std::forward<V>(visitor),
ptr());
183 template <
typename V>
188 throw std::invalid_argument(
"Empty DiscriminatedPtr");
191 n, std::forward<V>(visitor),
ptr());
198 template <
typename T>
207 return reinterpret_cast<void*
>(
data_ & ((1ULL << 48) - 1));
211 uintptr_t ip =
reinterpret_cast<uintptr_t
>(p);
213 ip |=
static_cast<uintptr_t
>(
v) << 48;
226 template <
typename Visitor,
typename...
Args>
230 return variant.apply(std::forward<Visitor>(visitor));
233 template <
typename Visitor,
typename...
Args>
237 return variant.apply(std::forward<Visitor>(visitor));
240 template <
typename Visitor,
typename...
Args>
244 return variant.apply(std::forward<Visitor>(visitor));
dptr_detail::VisitorResult< V, Types... >::type apply(V &&visitor)
const T * get_nothrow() const noexcept
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
dptr_detail::ConstVisitorResult< V, Types... >::type apply(V &&visitor) const
uint16_t typeIndex() const
T * get_nothrow() noexcept
decltype(auto) apply_visitor(Visitor &&visitor, const DiscriminatedPtr< Args... > &variant)
DiscriminatedPtr & operator=(T *ptr)