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

Side by Side Diff: Source/wtf/StdLibExtras.h

Issue 802203004: replace COMPILE_ASSERT with static assert in wtf/ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: final fixups Created 6 years 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 | « Source/wtf/SizeLimits.cpp ('k') | Source/wtf/StringHasher.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 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 #endif 105 #endif
106 106
107 namespace WTF { 107 namespace WTF {
108 108
109 /* 109 /*
110 * C++'s idea of a reinterpret_cast lacks sufficient cojones. 110 * C++'s idea of a reinterpret_cast lacks sufficient cojones.
111 */ 111 */
112 template<typename TO, typename FROM> 112 template<typename TO, typename FROM>
113 inline TO bitwise_cast(FROM from) 113 inline TO bitwise_cast(FROM from)
114 { 114 {
115 COMPILE_ASSERT(sizeof(TO) == sizeof(FROM), WTF_bitwise_cast_sizeof_casted_ty pes_is_equal); 115 static_assert(sizeof(TO) == sizeof(FROM), "WTF::bitwise_cast sizeof casted t ypes should be equal");
116 union { 116 union {
117 FROM from; 117 FROM from;
118 TO to; 118 TO to;
119 } u; 119 } u;
120 u.from = from; 120 u.from = from;
121 return u.to; 121 return u.to;
122 } 122 }
123 123
124 template<typename To, typename From> 124 template<typename To, typename From>
125 inline To safeCast(From value) 125 inline To safeCast(From value)
(...skipping 17 matching lines...) Expand all
143 inline void* operator new(size_t, NotNullTag, void* location) 143 inline void* operator new(size_t, NotNullTag, void* location)
144 { 144 {
145 ASSERT(location); 145 ASSERT(location);
146 return location; 146 return location;
147 } 147 }
148 148
149 using WTF::bitwise_cast; 149 using WTF::bitwise_cast;
150 using WTF::safeCast; 150 using WTF::safeCast;
151 151
152 #endif // WTF_StdLibExtras_h 152 #endif // WTF_StdLibExtras_h
OLDNEW
« no previous file with comments | « Source/wtf/SizeLimits.cpp ('k') | Source/wtf/StringHasher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698