about summary refs log tree commit diff
path: root/absl/types/optional.h
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2019-03-20T16·34-0700
committerDerek Mauro <dmauro@google.com>2019-03-20T19·38-0400
commite75672f6afc7e8f23ee7b532e86d1b3b9be3984e (patch)
tree38bcb6aa1dc3d2390f346aa1a21c4f28229ec78f /absl/types/optional.h
parentbf29470384a101b307873b26d358433138c857fc (diff)
Export of internal Abseil changes.
--
61a5128b3b3db9db7df219b7ef737b78f7743e54 by Abseil Team <absl-team@google.com>:

Internal change

PiperOrigin-RevId: 239413069

--
fd47ba5c2243523cc579239a220254cbc47376af by Jon Cohen <cohenjon@google.com>:

Internal change.

PiperOrigin-RevId: 239404848

--
bece0ae2b391351feb27547a4693f4e654b1b4ab by Eric Fiselier <ericwf@google.com>:

Unconditionally include memory.h in optional.

PiperOrigin-RevId: 239298731
GitOrigin-RevId: 61a5128b3b3db9db7df219b7ef737b78f7743e54
Change-Id: I09c1268154f1c8ea2b653d3e907f709e09025817
Diffstat (limited to 'absl/types/optional.h')
-rw-r--r--absl/types/optional.h37
1 files changed, 19 insertions, 18 deletions
diff --git a/absl/types/optional.h b/absl/types/optional.h
index 58906aa467ff..f0ae9a173c22 100644
--- a/absl/types/optional.h
+++ b/absl/types/optional.h
@@ -36,6 +36,7 @@
 #define ABSL_TYPES_OPTIONAL_H_
 
 #include "absl/base/config.h"
+#include "absl/memory/memory.h"
 #include "absl/utility/utility.h"
 
 #ifdef ABSL_HAVE_STD_OPTIONAL
@@ -60,7 +61,6 @@ using std::nullopt;
 #include <utility>
 
 #include "absl/base/attributes.h"
-#include "absl/memory/memory.h"
 #include "absl/meta/type_traits.h"
 #include "absl/types/bad_optional_access.h"
 
@@ -400,23 +400,24 @@ class optional_assign_base<copy_traits::non_movable> {
 };
 
 template <typename T>
-constexpr copy_traits get_ctor_copy_traits() {
-  return std::is_copy_constructible<T>::value
-             ? copy_traits::copyable
-             : std::is_move_constructible<T>::value ? copy_traits::movable
-                                                    : copy_traits::non_movable;
-}
+struct ctor_copy_traits {
+  static constexpr copy_traits traits =
+      std::is_copy_constructible<T>::value
+          ? copy_traits::copyable
+          : std::is_move_constructible<T>::value ? copy_traits::movable
+                                                 : copy_traits::non_movable;
+};
 
 template <typename T>
-constexpr copy_traits get_assign_copy_traits() {
-  return absl::is_copy_assignable<T>::value &&
-                 std::is_copy_constructible<T>::value
-             ? copy_traits::copyable
-             : absl::is_move_assignable<T>::value &&
-                       std::is_move_constructible<T>::value
-                   ? copy_traits::movable
-                   : copy_traits::non_movable;
-}
+struct assign_copy_traits {
+  static constexpr copy_traits traits =
+      absl::is_copy_assignable<T>::value && std::is_copy_constructible<T>::value
+          ? copy_traits::copyable
+          : absl::is_move_assignable<T>::value &&
+                    std::is_move_constructible<T>::value
+                ? copy_traits::movable
+                : copy_traits::non_movable;
+};
 
 // Whether T is constructible or convertible from optional<U>.
 template <typename T, typename U>
@@ -482,9 +483,9 @@ struct optional_hash_base<T, decltype(std::hash<absl::remove_const_t<T> >()(
 template <typename T>
 class optional : private optional_internal::optional_data<T>,
                  private optional_internal::optional_ctor_base<
-                     optional_internal::get_ctor_copy_traits<T>()>,
+                     optional_internal::ctor_copy_traits<T>::traits>,
                  private optional_internal::optional_assign_base<
-                     optional_internal::get_assign_copy_traits<T>()> {
+                     optional_internal::assign_copy_traits<T>::traits> {
   using data_base = optional_internal::optional_data<T>;
 
  public: