OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Crashpad Authors. All rights reserved. | |
scottmg
2015/09/11 23:57:34
Needs to be added to util/util.gyp.
danakj
2015/09/12 00:10:58
Done.
| |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 | |
15 namespace crashpad { | |
scottmg
2015/09/11 23:57:34
This file needs header guards.
danakj
2015/09/12 00:10:58
Oops. Done.
| |
16 | |
17 // Use implicit_cast as a safe version of static_cast or const_cast | |
18 // for upcasting in the type hierarchy (i.e. casting a pointer to Foo | |
19 // to a pointer to SuperclassOfFoo or casting a pointer to Foo to | |
20 // a const pointer to Foo). | |
21 // When you use implicit_cast, the compiler checks that the cast is safe. | |
22 // Such explicit implicit_casts are necessary in surprisingly many | |
23 // situations where C++ demands an exact type match instead of an | |
24 // argument type convertible to a target type. | |
25 // | |
26 // The From type can be inferred, so the preferred syntax for using | |
27 // implicit_cast is the same as for static_cast etc.: | |
28 // | |
29 // implicit_cast<ToType>(expr) | |
30 // | |
31 // implicit_cast would have been part of the C++ standard library, | |
32 // but the proposal was submitted too late. It will probably make | |
33 // its way into the language in the future. | |
34 template<typename To, typename From> | |
35 inline To implicit_cast(From const &f) { | |
36 return f; | |
37 } | |
38 | |
39 } // namespace crashpad | |
OLD | NEW |