mirror of
https://github.com/archlinuxarm/PKGBUILDs.git
synced 2024-11-08 22:45:43 +00:00
104 lines
3.4 KiB
Diff
104 lines
3.4 KiB
Diff
|
From e5fc0341fcb0e1514daa2d347d832d1525142b33 Mon Sep 17 00:00:00 2001
|
||
|
From: Hidehiko Abe <hidehiko@chromium.org>
|
||
|
Date: Fri, 23 Feb 2018 09:50:41 +0000
|
||
|
Subject: [PATCH 03/10] Workaround for g++7 is_trivially_copy_constructible
|
||
|
failure.
|
||
|
|
||
|
cf) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80654
|
||
|
Please see also crbug.com/784732#27 for details.
|
||
|
|
||
|
BUG=784732
|
||
|
TEST=Some with GCC.
|
||
|
|
||
|
Change-Id: I0a6d28d9c26ac9ed026d137e17fddbe86586f1e1
|
||
|
Reviewed-on: https://chromium-review.googlesource.com/927942
|
||
|
Commit-Queue: Hidehiko Abe <hidehiko@chromium.org>
|
||
|
Reviewed-by: danakj <danakj@chromium.org>
|
||
|
Cr-Commit-Position: refs/heads/master@{#538740}
|
||
|
---
|
||
|
base/optional.h | 3 ++-
|
||
|
base/template_util.h | 18 ++++++++++++++++++
|
||
|
base/template_util_unittest.cc | 9 +++++++++
|
||
|
3 files changed, 29 insertions(+), 1 deletion(-)
|
||
|
|
||
|
diff --git a/base/optional.h b/base/optional.h
|
||
|
index f6619a575815..c763acf824ee 100644
|
||
|
--- a/base/optional.h
|
||
|
+++ b/base/optional.h
|
||
|
@@ -9,6 +9,7 @@
|
||
|
#include <utility>
|
||
|
|
||
|
#include "base/logging.h"
|
||
|
+#include "base/template_util.h"
|
||
|
|
||
|
namespace base {
|
||
|
|
||
|
@@ -106,7 +107,7 @@ struct OptionalStorageBase<T, true /* trivially destructible */> {
|
||
|
// compiler generated constexpr {copy,move} constructors). Note that
|
||
|
// placement-new is prohibited in constexpr.
|
||
|
template <typename T,
|
||
|
- bool = std::is_trivially_copy_constructible<T>::value,
|
||
|
+ bool = is_trivially_copy_constructible<T>::value,
|
||
|
bool = std::is_trivially_move_constructible<T>::value>
|
||
|
struct OptionalStorage : OptionalStorageBase<T> {
|
||
|
// This is no trivially {copy,move} constructible case. Other cases are
|
||
|
diff --git a/base/template_util.h b/base/template_util.h
|
||
|
index f76003d8237b..8544aa294597 100644
|
||
|
--- a/base/template_util.h
|
||
|
+++ b/base/template_util.h
|
||
|
@@ -10,6 +10,7 @@
|
||
|
#include <iterator>
|
||
|
#include <type_traits>
|
||
|
#include <utility>
|
||
|
+#include <vector>
|
||
|
|
||
|
#include "build/build_config.h"
|
||
|
|
||
|
@@ -127,6 +128,23 @@ template <class T>
|
||
|
using is_trivially_copyable = std::is_trivially_copyable<T>;
|
||
|
#endif
|
||
|
|
||
|
+#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 7
|
||
|
+// Workaround for g++7 and earlier family.
|
||
|
+// Due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80654, without this
|
||
|
+// Optional<std::vector<T>> where T is non-copyable causes a compile error.
|
||
|
+// As we know it is not trivially copy constructible, explicitly declare so.
|
||
|
+template <typename T>
|
||
|
+struct is_trivially_copy_constructible
|
||
|
+ : std::is_trivially_copy_constructible<T> {};
|
||
|
+
|
||
|
+template <typename... T>
|
||
|
+struct is_trivially_copy_constructible<std::vector<T...>> : std::false_type {};
|
||
|
+#else
|
||
|
+// Otherwise use std::is_trivially_copy_constructible as is.
|
||
|
+template <typename T>
|
||
|
+using is_trivially_copy_constructible = std::is_trivially_copy_constructible<T>;
|
||
|
+#endif
|
||
|
+
|
||
|
} // namespace base
|
||
|
|
||
|
#undef CR_USE_FALLBACKS_FOR_GCC_WITH_LIBCXX
|
||
|
diff --git a/base/template_util_unittest.cc b/base/template_util_unittest.cc
|
||
|
index 12e5d362dd25..2c42445f785d 100644
|
||
|
--- a/base/template_util_unittest.cc
|
||
|
+++ b/base/template_util_unittest.cc
|
||
|
@@ -92,6 +92,15 @@ static_assert(!base::is_trivially_copyable<TrivialCopyButWithDestructor>::value,
|
||
|
"TrivialCopyButWithDestructor should not be detected as "
|
||
|
"trivially copyable");
|
||
|
|
||
|
+class NoCopy {
|
||
|
+ public:
|
||
|
+ NoCopy(const NoCopy&) = delete;
|
||
|
+};
|
||
|
+
|
||
|
+static_assert(
|
||
|
+ !base::is_trivially_copy_constructible<std::vector<NoCopy>>::value,
|
||
|
+ "is_trivially_copy_constructible<std::vector<T>> must be compiled.");
|
||
|
+
|
||
|
} // namespace
|
||
|
|
||
|
} // namespace base
|
||
|
--
|
||
|
2.16.2
|
||
|
|