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

Side by Side Diff: base/basictypes.h

Issue 1347483002: mini_chromium: remove implicit_cast (Closed) Base URL: https://chromium.googlesource.com/chromium/mini_chromium@master
Patch Set: Created 5 years, 3 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright 2006-2008 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 MINI_CHROMIUM_BASE_BASICTYPES_H_ 5 #ifndef MINI_CHROMIUM_BASE_BASICTYPES_H_
6 #define MINI_CHROMIUM_BASE_BASICTYPES_H_ 6 #define MINI_CHROMIUM_BASE_BASICTYPES_H_
7 7
8 #include <string.h> 8 #include <string.h>
9 #include <sys/types.h> 9 #include <sys/types.h>
10 10
(...skipping 26 matching lines...) Expand all
37 37
38 template <typename T, size_t N> 38 template <typename T, size_t N>
39 char (&ArraySizeHelper(const T (&array)[N]))[N]; 39 char (&ArraySizeHelper(const T (&array)[N]))[N];
40 40
41 #define arraysize(array) (sizeof(ArraySizeHelper(array))) 41 #define arraysize(array) (sizeof(ArraySizeHelper(array)))
42 42
43 #define ARRAYSIZE_UNSAFE(a) \ 43 #define ARRAYSIZE_UNSAFE(a) \
44 ((sizeof(a) / sizeof(*(a))) / \ 44 ((sizeof(a) / sizeof(*(a))) / \
45 static_cast<size_t>(!(sizeof(a) % sizeof(*(a))))) 45 static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
46 46
47 template<typename To, typename From>
48 inline To implicit_cast(const From& f) {
49 return f;
50 }
51
52 template <typename Dest, typename Source> 47 template <typename Dest, typename Source>
53 inline Dest bit_cast(const Source& source) { 48 inline Dest bit_cast(const Source& source) {
54 static_assert(sizeof(Dest) == sizeof(Source), "sizes must be equal"); 49 static_assert(sizeof(Dest) == sizeof(Source), "sizes must be equal");
55 50
56 Dest dest; 51 Dest dest;
57 memcpy(&dest, &source, sizeof(dest)); 52 memcpy(&dest, &source, sizeof(dest));
58 return dest; 53 return dest;
59 } 54 }
60 55
61 template<typename T> 56 template<typename T>
62 inline void ignore_result(const T&) { 57 inline void ignore_result(const T&) {
63 } 58 }
64 59
65 #endif // MINI_CHROMIUM_BASE_BASICTYPES_H_ 60 #endif // MINI_CHROMIUM_BASE_BASICTYPES_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698