OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 namespace WTF { | 5 namespace WTF { |
6 | 6 |
7 template <typename To, typename From> | 7 template <typename To, typename From> |
8 bool IsInBounds(From value) { | 8 bool IsInBounds(From value) { |
9 return true; | 9 return true; |
10 } | 10 } |
(...skipping 18 matching lines...) Expand all Loading... |
29 } | 29 } |
30 | 30 |
31 bool HasOverflowed() const { return false; } | 31 bool HasOverflowed() const { return false; } |
32 void Overflowed() {} | 32 void Overflowed() {} |
33 | 33 |
34 private: | 34 private: |
35 T value_; | 35 T value_; |
36 }; | 36 }; |
37 | 37 |
38 template <typename To, typename From> | 38 template <typename To, typename From> |
39 To Bitwise_cast(From from) { | 39 To bitwise_cast(From from) { |
40 static_assert(sizeof(To) == sizeof(From), "msg"); | 40 static_assert(sizeof(To) == sizeof(From), "msg"); |
41 return reinterpret_cast<To>(from); | 41 return reinterpret_cast<To>(from); |
42 } | 42 } |
43 | 43 |
44 } // namespace WTF | 44 } // namespace WTF |
45 | 45 |
46 namespace mojo { | 46 namespace mojo { |
47 | 47 |
48 template <typename U> | 48 template <typename U> |
49 struct ArrayTraits; | 49 struct ArrayTraits; |
50 | 50 |
51 template <typename U> | 51 template <typename U> |
52 struct ArrayTraits<WTF::Checked<U, int>> { | 52 struct ArrayTraits<WTF::Checked<U, int>> { |
53 static bool HasOverflowed(WTF::Checked<U, int>& input) { | 53 static bool HasOverflowed(WTF::Checked<U, int>& input) { |
54 // |hasOverflowed| below should be rewritten to |HasOverflowed| | 54 // |hasOverflowed| below should be rewritten to |HasOverflowed| |
55 // (because this is a method of WTF::Checked; it doesn't matter | 55 // (because this is a method of WTF::Checked; it doesn't matter |
56 // that we are not in WTF namespace *here*). | 56 // that we are not in WTF namespace *here*). |
57 return input.HasOverflowed(); | 57 return input.HasOverflowed(); |
58 } | 58 } |
59 }; | 59 }; |
60 | 60 |
61 } // namespace mojo | 61 } // namespace mojo |
62 | 62 |
63 using WTF::Bitwise_cast; | 63 using WTF::bitwise_cast; |
64 using WTF::SafeCast; | 64 using WTF::SafeCast; |
OLD | NEW |