Skip to content

Commit 6207f08

Browse files
Unify the two copies of template_util.h
This patch basically deletes webrtc/base/template_util.h (which is the more outdated copy, although there are only cosmetical differences) and moves webrtc/system_wrappers/source/template_util.h to take its place. The reunified header uses the rtc namespace like the old webrtc/base/template_util.h, rather than the webrtc namespace like webrtc/system_wrappers/source/template_util.h. [email protected], [email protected] Review URL: https://webrtc-codereview.appspot.com/38579004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@8050 4adac7df-926f-26a2-2b94-8c16560cd09d
1 parent 236920f commit 6207f08

File tree

5 files changed

+15
-124
lines changed

5 files changed

+15
-124
lines changed

webrtc/base/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ static_library("rtc_base_approved") {
120120
"stringencode.h",
121121
"stringutils.cc",
122122
"stringutils.h",
123+
"template_util.h",
123124
"thread_annotations.h",
124125
"timeutils.cc",
125126
"timeutils.h",

webrtc/base/base.gyp

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
'stringencode.h',
5656
'stringutils.cc',
5757
'stringutils.h',
58+
'template_util.h',
5859
'thread_annotations.h',
5960
'timeutils.cc',
6061
'timeutils.h',

webrtc/base/template_util.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011 The WebRTC Project Authors. All rights reserved.
2+
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
33
*
44
* Use of this source code is governed by a BSD-style license
55
* that can be found in the LICENSE file in the root of the source
@@ -8,14 +8,16 @@
88
* be found in the AUTHORS file in the root of the source tree.
99
*/
1010

11+
// Borrowed from Chromium's src/base/template_util.h.
12+
1113
#ifndef WEBRTC_BASE_TEMPLATE_UTIL_H_
1214
#define WEBRTC_BASE_TEMPLATE_UTIL_H_
1315

1416
#include <stddef.h> // For size_t.
1517

1618
namespace rtc {
1719

18-
// template definitions from tr1
20+
// Template definitions from tr1.
1921

2022
template<class T, T v>
2123
struct integral_constant {
@@ -33,7 +35,7 @@ template <class T> struct is_pointer : false_type {};
3335
template <class T> struct is_pointer<T*> : true_type {};
3436

3537
template <class T, class U> struct is_same : public false_type {};
36-
template <class T> struct is_same<T,T> : true_type {};
38+
template <class T> struct is_same<T, T> : true_type {};
3739

3840
template<class> struct is_array : public false_type {};
3941
template<class T, size_t n> struct is_array<T[n]> : public true_type {};

webrtc/system_wrappers/interface/scoped_ptr.h

+8-7
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
#include "webrtc/base/compile_assert.h"
108108
#include "webrtc/base/constructormagic.h"
109109
#include "webrtc/base/move.h"
110-
#include "webrtc/system_wrappers/interface/template_util.h"
110+
#include "webrtc/base/template_util.h"
111111
#include "webrtc/typedefs.h"
112112

113113
namespace webrtc {
@@ -133,7 +133,7 @@ struct DefaultDeleter {
133133
// cannot convert to T*.
134134
enum { T_must_be_complete = sizeof(T) };
135135
enum { U_must_be_complete = sizeof(U) };
136-
COMPILE_ASSERT((webrtc::is_convertible<U*, T*>::value),
136+
COMPILE_ASSERT((rtc::is_convertible<U*, T*>::value),
137137
U_ptr_must_implicitly_convert_to_T_ptr);
138138
}
139139
inline void operator()(T* ptr) const {
@@ -183,12 +183,13 @@ namespace internal {
183183
template <typename T>
184184
struct ShouldAbortOnSelfReset {
185185
template <typename U>
186-
static NoType Test(const typename U::AllowSelfReset*);
186+
static rtc::internal::NoType Test(const typename U::AllowSelfReset*);
187187

188188
template <typename U>
189-
static YesType Test(...);
189+
static rtc::internal::YesType Test(...);
190190

191-
static const bool value = sizeof(Test<T>(0)) == sizeof(YesType);
191+
static const bool value =
192+
sizeof(Test<T>(0)) == sizeof(rtc::internal::YesType);
192193
};
193194

194195
// Minimal implementation of the core logic of scoped_ptr, suitable for
@@ -350,7 +351,7 @@ class scoped_ptr {
350351
template <typename U, typename V>
351352
scoped_ptr(scoped_ptr<U, V>&& other)
352353
: impl_(&other.impl_) {
353-
COMPILE_ASSERT(!webrtc::is_array<U>::value, U_cannot_be_an_array);
354+
COMPILE_ASSERT(!rtc::is_array<U>::value, U_cannot_be_an_array);
354355
}
355356

356357
// operator=. Allows assignment from a scoped_ptr rvalue for a convertible
@@ -365,7 +366,7 @@ class scoped_ptr {
365366
// scoped_ptr.
366367
template <typename U, typename V>
367368
scoped_ptr& operator=(scoped_ptr<U, V>&& rhs) {
368-
COMPILE_ASSERT(!webrtc::is_array<U>::value, U_cannot_be_an_array);
369+
COMPILE_ASSERT(!rtc::is_array<U>::value, U_cannot_be_an_array);
369370
impl_.TakeState(&rhs.impl_);
370371
return *this;
371372
}

webrtc/system_wrappers/interface/template_util.h

-114
This file was deleted.

0 commit comments

Comments
 (0)