@@ -223,6 +223,36 @@ struct disjunction<> : std::false_type {};
223223template <typename T>
224224struct negation : std::integral_constant<bool , !T::value> {};
225225
226+ #if defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__) && !defined(_MSC_VER) && !defined(__INTEL_COMPILER)
227+ #define PHMAP_OLD_GCC 1
228+ #else
229+ #define PHMAP_OLD_GCC 0
230+ #endif
231+
232+ #if PHMAP_OLD_GCC
233+ template <typename T>
234+ struct is_trivially_copy_constructible
235+ : std::integral_constant<bool ,
236+ __has_trivial_copy (typename std::remove_reference<T>::type) &&
237+ std::is_copy_constructible<T>::value &&
238+ std::is_trivially_destructible<T>::value> {};
239+
240+ template <typename T>
241+ struct is_trivially_copy_assignable :
242+ std::integral_constant<bool ,
243+ __has_trivial_assign (typename std::remove_reference<T>::type) &&
244+ phmap::is_copy_assignable<T>::value> {};
245+
246+ template <typename T>
247+ struct is_trivially_copyable :
248+ std::integral_constant<bool , __has_trivial_copy(typename std::remove_reference<T>::type)> {};
249+
250+ #else
251+ template <typename T> using is_trivially_copy_constructible = std::is_trivially_copy_constructible<T>;
252+ template <typename T> using is_trivially_copy_assignable = std::is_trivially_copy_assignable<T>;
253+ template <typename T> using is_trivially_copyable = std::is_trivially_copyable<T>;
254+ #endif
255+
226256// -----------------------------------------------------------------------------
227257// C++14 "_t" trait aliases
228258// -----------------------------------------------------------------------------
@@ -1788,8 +1818,8 @@ class optional_data_base : public optional_data_dtor_base<T>
17881818// supported now, so we use is_trivially_* traits instead.
17891819template <typename T,
17901820 bool unused =
1791- std ::is_trivially_copy_constructible<T>::value &&
1792- std ::is_trivially_copy_assignable<typename std::remove_cv<T>::type>::value &&
1821+ phmap ::is_trivially_copy_constructible<T>::value &&
1822+ phmap ::is_trivially_copy_assignable<typename std::remove_cv<T>::type>::value &&
17931823 std::is_trivially_destructible<T>::value>
17941824class optional_data ;
17951825
@@ -2021,6 +2051,11 @@ struct optional_hash_base<T, decltype(std::hash<phmap::remove_const_t<T> >()(
20212051// -----------------------------------------------------------------------------
20222052// phmap::optional class definition
20232053// -----------------------------------------------------------------------------
2054+ #if PHMAP_OLD_GCC
2055+ #define PHMAP_OPTIONAL_NOEXCEPT
2056+ #else
2057+ #define PHMAP_OPTIONAL_NOEXCEPT noexcept
2058+ #endif
20242059
20252060template <typename T>
20262061class optional : private optional_internal ::optional_data<T>,
@@ -2047,7 +2082,7 @@ class optional : private optional_internal::optional_data<T>,
20472082 optional (const optional& src) = default ;
20482083
20492084 // Move constructor, standard semantics
2050- optional (optional&& src) noexcept = default ;
2085+ optional (optional&& src) PHMAP_OPTIONAL_NOEXCEPT = default ;
20512086
20522087 // Constructs a non-empty `optional` direct-initialized value of type `T` from
20532088 // the arguments `std::forward<Args>(args)...` within the `optional`.
@@ -2187,7 +2222,7 @@ class optional : private optional_internal::optional_data<T>,
21872222 optional& operator =(const optional& src) = default ;
21882223
21892224 // Move assignment operator, standard semantics
2190- optional& operator =(optional&& src) noexcept = default ;
2225+ optional& operator =(optional&& src) PHMAP_OPTIONAL_NOEXCEPT = default ;
21912226
21922227 // Value assignment operators
21932228 template <
0 commit comments