15 #ifndef ABSL_TYPES_INTERNAL_OPTIONAL_H_ 16 #define ABSL_TYPES_INTERNAL_OPTIONAL_H_ 20 #include <type_traits> 45 #if defined(__clang__) 46 #if __has_feature(cxx_inheriting_constructors) 47 #define ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS 1 49 #elif (defined(__GNUC__) && \ 50 (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 8)) || \ 51 (__cpp_inheriting_constructors >= 200802) || \ 52 (defined(_MSC_VER) && _MSC_VER >= 1910) 53 #define ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS 1 62 namespace optional_internal {
66 explicit init_t() =
default;
101 template <
typename... Args>
109 template <
typename T>
130 template <
typename... Args>
135 template <
typename T>
139 #ifdef ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS 144 template <
typename... Args>
149 template <
typename... Args>
152 ::new (static_cast<void*>(&this->dummy_)) T(std::forward<Args>(args)...);
153 this->engaged_ =
true;
156 template <
typename U>
158 if (this->engaged_) {
159 this->
data_ = std::forward<U>(u);
172 template <
typename T,
179 template <
typename T>
182 #ifdef ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS 187 template <
typename... Args>
193 template <
typename T>
196 #ifdef ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS 199 template <
typename... Args>
214 std::is_nothrow_move_constructible<T>::
value)
223 this->assign(rhs.data_);
231 std::is_nothrow_move_assignable<T>::
value&&
232 std::is_nothrow_move_constructible<T>::
value) {
247 template <copy_traits>
281 template <copy_traits>
314 template <
typename T>
323 template <
typename T>
335 template <
typename T,
typename U>
337 : std::integral_constant<
338 bool, std::is_constructible<T, optional<U>&>::value ||
339 std::is_constructible<T, optional<U>&&>::value ||
340 std::is_constructible<T, const optional<U>&>::value ||
341 std::is_constructible<T, const optional<U>&&>::value ||
342 std::is_convertible<optional<U>&, T>::value ||
343 std::is_convertible<optional<U>&&, T>::value ||
344 std::is_convertible<const optional<U>&, T>::value ||
345 std::is_convertible<const optional<U>&&, T>::value> {};
348 template <
typename T,
typename U>
350 : std::integral_constant<
351 bool, is_constructible_convertible_from_optional<T, U>::value ||
352 std::is_assignable<T&, optional<U>&>::value ||
353 std::is_assignable<T&, optional<U>&&>::value ||
354 std::is_assignable<T&, const optional<U>&>::value ||
355 std::is_assignable<T&, const optional<U>&&>::value> {};
365 template <
typename T,
typename =
size_t>
374 template <
typename T>
376 std::declval<absl::remove_const_t<T> >()))> {
378 using result_type = size_t;
380 absl::type_traits_internal::AssertHashEnabled<absl::remove_const_t<T>>();
382 return std::hash<absl::remove_const_t<T> >()(*opt);
384 return static_cast<size_t>(0x297814aaad196e6dULL);
392 #undef ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS 394 #endif // ABSL_TYPES_INTERNAL_OPTIONAL_H_
optional_data(optional_data &&rhs) noexcept(absl::default_allocator_is_nothrow::value||std::is_nothrow_move_constructible< T >::value)
constexpr T && forward(absl::remove_reference_t< T > &t) noexcept
constexpr optional_data(in_place_t t, Args &&...args)
constexpr optional_data_dtor_base(in_place_t, Args &&...args)
constexpr optional_data(in_place_t t, Args &&...args)
constexpr optional_data_dtor_base(in_place_t, Args &&...args)
constexpr optional_data_dtor_base() noexcept
bool convertible_to_bool(bool)
static char data[kDataSize]
hash_default_hash< typename T::first_type > hash
static std::function< void(void *, Slot *, Slot)> construct
constexpr optional_data_dtor_base() noexcept
~optional_data_dtor_base()
optional_data & operator=(const optional_data &rhs)
optional_data(const optional_data &rhs)
optional_data & operator=(optional_data &&rhs) noexcept(std::is_nothrow_move_assignable< T >::value &&std::is_nothrow_move_constructible< T >::value)
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
constexpr optional_data_base(in_place_t t, Args &&...args)
void construct(Args &&...args)