| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 
|  | 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 #ifndef CRASHPAD_UTIL_MISC_IMPLICIT_CAST_H_ | 
|  | 16 #define CRASHPAD_UTIL_MISC_IMPLICIT_CAST_H_ | 
|  | 17 | 
|  | 18 namespace crashpad { | 
|  | 19 | 
|  | 20 // Use implicit_cast as a safe version of static_cast or const_cast | 
|  | 21 // for upcasting in the type hierarchy (i.e. casting a pointer to Foo | 
|  | 22 // to a pointer to SuperclassOfFoo or casting a pointer to Foo to | 
|  | 23 // a const pointer to Foo). | 
|  | 24 // When you use implicit_cast, the compiler checks that the cast is safe. | 
|  | 25 // Such explicit implicit_casts are necessary in surprisingly many | 
|  | 26 // situations where C++ demands an exact type match instead of an | 
|  | 27 // argument type convertible to a target type. | 
|  | 28 // | 
|  | 29 // The From type can be inferred, so the preferred syntax for using | 
|  | 30 // implicit_cast is the same as for static_cast etc.: | 
|  | 31 // | 
|  | 32 //   implicit_cast<ToType>(expr) | 
|  | 33 // | 
|  | 34 // implicit_cast would have been part of the C++ standard library, | 
|  | 35 // but the proposal was submitted too late.  It will probably make | 
|  | 36 // its way into the language in the future. | 
|  | 37 template<typename To, typename From> | 
|  | 38 inline To implicit_cast(From const &f) { | 
|  | 39   return f; | 
|  | 40 } | 
|  | 41 | 
|  | 42 }  // namespace crashpad | 
|  | 43 | 
|  | 44 #endif  // CRASHPAD_UTIL_MISC_IMPLICIT_CAST_H_ | 
| OLD | NEW | 
|---|