Home | History | Annotate | Download | only in stubs

Lines Matching refs:To

16 // contributors may be used to endorse or promote products derived from
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
41 // for upcasting in the type hierarchy (i.e. casting a pointer to Foo
42 // to a pointer to SuperclassOfFoo or casting a pointer to Foo to
43 // a const pointer to Foo).
47 // argument type convertable to a target type.
57 template<typename To, typename From>
58 inline To implicit_cast(From const &f) {
62 // When you upcast (that is, cast a pointer from type Foo to type
63 // SuperclassOfFoo), it's fine to use implicit_cast<>, since upcasts
65 // type Foo to type SubclassOfFoo), static_cast<> isn't safe, because
69 // use dynamic_cast<> to double-check the downcast is legal (we die
71 // instead. Thus, it's important to test in debug mode to make sure
74 // In particular, you SHOULDN'T be using dynamic_cast<> in order to
78 // You should design the code some other way not to need this.
80 template<typename To, typename From> // use like this: down_cast<T*>(foo);
81 inline To down_cast(From* f) { // so we only accept pointers
82 // Ensures that To is a sub-type of From *. This test is here only
87 implicit_cast<From*, To>(0);
91 assert(f == NULL || dynamic_cast<To>(f) != NULL); // RTTI: debug mode only!
93 return static_cast<To>(f);
96 template<typename To, typename From> // use like this: down_cast<T&>(foo);
97 inline To down_cast(From& f) {
98 typedef typename remove_reference<To>::type* ToAsPointer;
99 // Ensures that To is a sub-type of From *. This test is here only
114 template<typename To, typename From>
115 inline To bit_cast(const From& from) {
116 GOOGLE_COMPILE_ASSERT(sizeof(From) == sizeof(To),
118 To dest;
126 // but we don't want to stick "internal::" in front of them everywhere.