Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2045)

Unified Diff: base/template_util.h

Issue 2000043002: Make base::Optional trivially destructible when possible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build on Windows. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/optional_unittest.cc ('k') | base/template_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/template_util.h
diff --git a/base/template_util.h b/base/template_util.h
index 98506f029dee2f22a31fba0d2999b8de33cd72d3..1bfc1ac814a23ceb186a9fcf6fa5924281d92783 100644
--- a/base/template_util.h
+++ b/base/template_util.h
@@ -12,6 +12,17 @@
#include "build/build_config.h"
+// This hacks around libstdc++ 4.6 missing stuff in type_traits, while we need
+// to support it.
+#define CR_GLIBCXX_4_7_0 20120322
+#define CR_GLIBCXX_4_5_4 20120702
+#define CR_GLIBCXX_4_6_4 20121127
+#if defined(__GLIBCXX__) && \
+ (__GLIBCXX__ < CR_GLIBCXX_4_7_0 || __GLIBCXX__ == CR_GLIBCXX_4_5_4 || \
+ __GLIBCXX__ == CR_GLIBCXX_4_6_4)
+#define CR_USE_FALLBACKS_FOR_OLD_GLIBCXX
+#endif
+
namespace base {
template <class T> struct is_non_const_reference : std::false_type {};
@@ -93,16 +104,9 @@ struct is_move_assignable
};
// underlying_type produces the integer type backing an enum type.
-// This hacks around libstdc++ 4.6 missing std::underlying_type, while we need
-// to support it.
// TODO(crbug.com/554293): Remove this when all platforms have this in the std
// namespace.
-#define CR_GLIBCXX_4_7_0 20120322
-#define CR_GLIBCXX_4_5_4 20120702
-#define CR_GLIBCXX_4_6_4 20121127
-#if defined(__GLIBCXX__) && \
- (__GLIBCXX__ < CR_GLIBCXX_4_7_0 || __GLIBCXX__ == CR_GLIBCXX_4_5_4 || \
- __GLIBCXX__ == CR_GLIBCXX_4_6_4)
+#if defined(CR_USE_FALLBACKS_FOR_OLD_GLIBCXX)
template <typename T>
struct underlying_type {
using type = __underlying_type(T);
@@ -112,6 +116,18 @@ template <typename T>
using underlying_type = std::underlying_type<T>;
#endif
+// TODO(crbug.com/554293): Remove this when all platforms have this in the std
+// namespace.
+#if defined(CR_USE_FALLBACKS_FOR_OLD_GLIBCXX)
+template <class T>
+using is_trivially_destructible = std::has_trivial_destructor<T>;
+#else
+template <class T>
+using is_trivially_destructible = std::is_trivially_destructible<T>;
+#endif
+
} // namespace base
+#undef CR_USE_FALLBACKS_FOR_OLD_GLIBCXX
+
#endif // BASE_TEMPLATE_UTIL_H_
« no previous file with comments | « base/optional_unittest.cc ('k') | base/template_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698