about summary refs log tree commit diff
path: root/absl/types
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2019-04-09T15·22-0700
committerShaindel Schwartz <shaindel@google.com>2019-04-09T17·34-0400
commitdbae8764fbd429bf7d7745e24bcf73962177a7c0 (patch)
tree9e0b90d17192c02952632d619616f00ec4f68580 /absl/types
parent044da8a29c923506af0f0b46bc46f43c1e1300b5 (diff)
Export of internal Abseil changes.
--
3f04cd3c25a99df91ff913977b8c5b343532db5d by Abseil Team <absl-team@google.com>:

Stricter memory order constraints for CycleClock callback.

PiperOrigin-RevId: 242670115

--
216db48375306490f1722a11aaf33080939d9f2f by Abseil Team <absl-team@google.com>:

internal/optional.h: move macro from types/optional.h

ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS is only used within this file.
additionally check the macro with #ifdef rather than #if, fixes -Wundef
warning:
'ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS' is not defined, evaluates to 0
PiperOrigin-RevId: 242548205

--
fbe22e7d8dc5c0b3d43ac26297e97ddbaeab3d39 by Samuel Benzaquen <sbenza@google.com>:

Implement %f natively for any input.
It evaluates the input at runtime and allocates stack space accordingly.

This removes a potential fallback into snprintf, improves performance, and removes all memory allocations in this formatting path.

PiperOrigin-RevId: 242531736

--
1458f9ba2a79ef0534e46527cd34770dee54164d by Greg Falcon <gfalcon@google.com>:

Add explicit check for NVCC in compressed_tuple.h.

NVCC claims to be MSVC, but does not implement this MSVC attribute.

PiperOrigin-RevId: 242513453
GitOrigin-RevId: 3f04cd3c25a99df91ff913977b8c5b343532db5d
Change-Id: I0742e8619c5248c7607961113e406486bc0e279b
Diffstat (limited to 'absl/types')
-rw-r--r--absl/types/internal/optional.h36
-rw-r--r--absl/types/optional.h29
2 files changed, 33 insertions, 32 deletions
diff --git a/absl/types/internal/optional.h b/absl/types/internal/optional.h
index 562c84ef5af7..8acbda20d559 100644
--- a/absl/types/internal/optional.h
+++ b/absl/types/internal/optional.h
@@ -25,6 +25,34 @@
 #include "absl/meta/type_traits.h"
 #include "absl/utility/utility.h"
 
+// ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS
+//
+// Inheriting constructors is supported in GCC 4.8+, Clang 3.3+ and MSVC 2015.
+// __cpp_inheriting_constructors is a predefined macro and a recommended way to
+// check for this language feature, but GCC doesn't support it until 5.0 and
+// Clang doesn't support it until 3.6.
+// Also, MSVC 2015 has a bug: it doesn't inherit the constexpr template
+// constructor. For example, the following code won't work on MSVC 2015 Update3:
+// struct Base {
+//   int t;
+//   template <typename T>
+//   constexpr Base(T t_) : t(t_) {}
+// };
+// struct Foo : Base {
+//   using Base::Base;
+// }
+// constexpr Foo foo(0);  // doesn't work on MSVC 2015
+#if defined(__clang__)
+#if __has_feature(cxx_inheriting_constructors)
+#define ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS 1
+#endif
+#elif (defined(__GNUC__) &&                                       \
+       (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 8)) || \
+    (__cpp_inheriting_constructors >= 200802) ||                  \
+    (defined(_MSC_VER) && _MSC_VER >= 1910)
+#define ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS 1
+#endif
+
 namespace absl {
 
 // Forward declaration
@@ -108,7 +136,7 @@ template <typename T>
 class optional_data_base : public optional_data_dtor_base<T> {
  protected:
   using base = optional_data_dtor_base<T>;
-#if ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS
+#ifdef ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS
   using base::base;
 #else
   optional_data_base() = default;
@@ -151,7 +179,7 @@ class optional_data;
 template <typename T>
 class optional_data<T, true> : public optional_data_base<T> {
  protected:
-#if ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS
+#ifdef ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS
   using optional_data_base<T>::optional_data_base;
 #else
   optional_data() = default;
@@ -165,7 +193,7 @@ class optional_data<T, true> : public optional_data_base<T> {
 template <typename T>
 class optional_data<T, false> : public optional_data_base<T> {
  protected:
-#if ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS
+#ifdef ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS
   using optional_data_base<T>::optional_data_base;
 #else
   template <typename... Args>
@@ -361,4 +389,6 @@ struct optional_hash_base<T, decltype(std::hash<absl::remove_const_t<T> >()(
 }  // namespace optional_internal
 }  // namespace absl
 
+#undef ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS
+
 #endif  // ABSL_TYPES_INTERNAL_OPTIONAL_H_
diff --git a/absl/types/optional.h b/absl/types/optional.h
index 17f789847386..579833196424 100644
--- a/absl/types/optional.h
+++ b/absl/types/optional.h
@@ -64,34 +64,6 @@ using std::nullopt;
 #include "absl/types/bad_optional_access.h"
 #include "absl/types/internal/optional.h"
 
-// ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS
-//
-// Inheriting constructors is supported in GCC 4.8+, Clang 3.3+ and MSVC 2015.
-// __cpp_inheriting_constructors is a predefined macro and a recommended way to
-// check for this language feature, but GCC doesn't support it until 5.0 and
-// Clang doesn't support it until 3.6.
-// Also, MSVC 2015 has a bug: it doesn't inherit the constexpr template
-// constructor. For example, the following code won't work on MSVC 2015 Update3:
-// struct Base {
-//   int t;
-//   template <typename T>
-//   constexpr Base(T t_) : t(t_) {}
-// };
-// struct Foo : Base {
-//   using Base::Base;
-// }
-// constexpr Foo foo(0);  // doesn't work on MSVC 2015
-#if defined(__clang__)
-#if __has_feature(cxx_inheriting_constructors)
-#define ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS 1
-#endif
-#elif (defined(__GNUC__) &&                                       \
-       (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 8)) || \
-    (__cpp_inheriting_constructors >= 200802) ||                  \
-    (defined(_MSC_VER) && _MSC_VER >= 1910)
-#define ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS 1
-#endif
-
 namespace absl {
 
 // nullopt_t
@@ -791,7 +763,6 @@ struct hash<absl::optional<T> >
 
 }  // namespace std
 
-#undef ABSL_OPTIONAL_USE_INHERITING_CONSTRUCTORS
 #undef ABSL_MSVC_CONSTEXPR_BUG_IN_UNION_LIKE_CLASS
 
 #endif  // ABSL_HAVE_STD_OPTIONAL