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

Side by Side Diff: base/containers/small_map.h

Issue 1467003002: Switch to static_assert in base/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: / Created 5 years, 1 month 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 | « base/bind_internal.h ('k') | base/containers/stack_container.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_CONTAINERS_SMALL_MAP_H_ 5 #ifndef BASE_CONTAINERS_SMALL_MAP_H_
6 #define BASE_CONTAINERS_SMALL_MAP_H_ 6 #define BASE_CONTAINERS_SMALL_MAP_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 typename EqualKey = 180 typename EqualKey =
181 typename internal::select_equal_key< 181 typename internal::select_equal_key<
182 NormalMap, 182 NormalMap,
183 internal::has_key_equal<NormalMap>::value>::equal_key, 183 internal::has_key_equal<NormalMap>::value>::equal_key,
184 typename MapInit = internal::SmallMapDefaultInit<NormalMap> > 184 typename MapInit = internal::SmallMapDefaultInit<NormalMap> >
185 class SmallMap { 185 class SmallMap {
186 // We cannot rely on the compiler to reject array of size 0. In 186 // We cannot rely on the compiler to reject array of size 0. In
187 // particular, gcc 2.95.3 does it but later versions allow 0-length 187 // particular, gcc 2.95.3 does it but later versions allow 0-length
188 // arrays. Therefore, we explicitly reject non-positive kArraySize 188 // arrays. Therefore, we explicitly reject non-positive kArraySize
189 // here. 189 // here.
190 COMPILE_ASSERT(kArraySize > 0, default_initial_size_should_be_positive); 190 static_assert(kArraySize > 0, "default initial size should be positive");
191 191
192 public: 192 public:
193 typedef typename NormalMap::key_type key_type; 193 typedef typename NormalMap::key_type key_type;
194 typedef typename NormalMap::mapped_type data_type; 194 typedef typename NormalMap::mapped_type data_type;
195 typedef typename NormalMap::mapped_type mapped_type; 195 typedef typename NormalMap::mapped_type mapped_type;
196 typedef typename NormalMap::value_type value_type; 196 typedef typename NormalMap::value_type value_type;
197 typedef EqualKey key_equal; 197 typedef EqualKey key_equal;
198 198
199 SmallMap() : size_(0), functor_(MapInit()) {} 199 SmallMap() : size_(0), functor_(MapInit()) {}
200 200
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 typename Functor> 643 typename Functor>
644 inline bool SmallMap<NormalMap, kArraySize, EqualKey, 644 inline bool SmallMap<NormalMap, kArraySize, EqualKey,
645 Functor>::iterator::operator!=( 645 Functor>::iterator::operator!=(
646 const const_iterator& other) const { 646 const const_iterator& other) const {
647 return other != *this; 647 return other != *this;
648 } 648 }
649 649
650 } // namespace base 650 } // namespace base
651 651
652 #endif // BASE_CONTAINERS_SMALL_MAP_H_ 652 #endif // BASE_CONTAINERS_SMALL_MAP_H_
OLDNEW
« no previous file with comments | « base/bind_internal.h ('k') | base/containers/stack_container.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698