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

Side by Side Diff: webrtc/base/template_util.h

Issue 2071003003: Imported Optional from Chromium with some modifications. Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added an empty member to the OptionalStorage union, to make the union always initializable. Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « webrtc/base/optional_unittest.cc ('k') | webrtc/modules/audio_coding/neteq/decoder_database.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 // Borrowed from Chromium's src/base/template_util.h. 11 // Borrowed from Chromium's src/base/template_util.h.
12 12
13 #ifndef WEBRTC_BASE_TEMPLATE_UTIL_H_ 13 #ifndef WEBRTC_BASE_TEMPLATE_UTIL_H_
14 #define WEBRTC_BASE_TEMPLATE_UTIL_H_ 14 #define WEBRTC_BASE_TEMPLATE_UTIL_H_
15 15
16 #include <type_traits> // For is_trivially_destructible
16 #include <stddef.h> // For size_t. 17 #include <stddef.h> // For size_t.
17 18
18 namespace rtc { 19 namespace rtc {
19 20
20 // Template definitions from tr1. 21 // Template definitions from tr1.
21 22
22 template<class T, T v> 23 template<class T, T v>
23 struct integral_constant { 24 struct integral_constant {
24 static const T value = v; 25 static const T value = v;
25 typedef T value_type; 26 typedef T value_type;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 sizeof(internal::YesType)> { 116 sizeof(internal::YesType)> {
116 }; 117 };
117 118
118 template <typename T> 119 template <typename T>
119 struct is_class 120 struct is_class
120 : integral_constant<bool, 121 : integral_constant<bool,
121 sizeof(internal::IsClassHelper::Test<T>(0)) == 122 sizeof(internal::IsClassHelper::Test<T>(0)) ==
122 sizeof(internal::YesType)> { 123 sizeof(internal::YesType)> {
123 }; 124 };
124 125
126 // This hacks around libstdc++ 4.6 missing stuff in type_traits, while we need
127 // to support it.
128 #define CR_GLIBCXX_4_7_0 20120322
129 #define CR_GLIBCXX_4_5_4 20120702
130 #define CR_GLIBCXX_4_6_4 20121127
131 #if defined(__GLIBCXX__) && \
132 (__GLIBCXX__ < CR_GLIBCXX_4_7_0 || __GLIBCXX__ == CR_GLIBCXX_4_5_4 || \
133 __GLIBCXX__ == CR_GLIBCXX_4_6_4)
134 #define CR_USE_FALLBACKS_FOR_OLD_GLIBCXX
135 #endif
136
137 // TODO(crbug.com/554293): Remove this when all platforms have this in the std
138 // namespace.
139 #if defined(CR_USE_FALLBACKS_FOR_OLD_GLIBCXX)
140 template <class T>
141 using is_trivially_destructible = std::has_trivial_destructor<T>;
142 #else
143 template <class T>
144 using is_trivially_destructible = std::is_trivially_destructible<T>;
145 #endif
146
125 } // namespace rtc 147 } // namespace rtc
126 148
127 #endif // WEBRTC_BASE_TEMPLATE_UTIL_H_ 149 #endif // WEBRTC_BASE_TEMPLATE_UTIL_H_
OLDNEW
« no previous file with comments | « webrtc/base/optional_unittest.cc ('k') | webrtc/modules/audio_coding/neteq/decoder_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698