Home | History | Annotate | Download | only in Support

Lines Matching refs:From

34 template<typename From> struct simplify_type {
35 using SimpleType = From; // The real type this represents...
38 static SimpleType &getSimplifiedValue(From &Val) { return Val; }
41 template<typename From> struct simplify_type<const From> {
42 using NonConstSimpleType = typename simplify_type<From>::SimpleType;
48 static RetType getSimplifiedValue(const From& Val) {
49 return simplify_type<From>::getSimplifiedValue(const_cast<From&>(Val));
53 // The core of the implementation of isa<X> is here; To and From should be
55 // implementation of isa<> without rewriting it from scratch.
56 template <typename To, typename From, typename Enabler = void>
58 static inline bool doit(const From &Val) {
64 template <typename To, typename From>
66 To, From, typename std::enable_if<std::is_base_of<To, From>::value>::type> {
67 static inline bool doit(const From &) { return true; }
70 template <typename To, typename From> struct isa_impl_cl {
71 static inline bool doit(const From &Val) {
72 return isa_impl<To, From>::doit(Val);
76 template <typename To, typename From> struct isa_impl_cl<To, const From> {
77 static inline bool doit(const From &Val) {
78 return isa_impl<To, From>::doit(Val);
82 template <typename To, typename From>
83 struct isa_impl_cl<To, const std::unique_ptr<From>> {
84 static inline bool doit(const std::unique_ptr<From> &Val) {
86 return isa_impl_cl<To, From>::doit(*Val);
90 template <typename To, typename From> struct isa_impl_cl<To, From*> {
91 static inline bool doit(const From *Val) {
93 return isa_impl<To, From>::doit(*Val);
97 template <typename To, typename From> struct isa_impl_cl<To, From*const> {
98 static inline bool doit(const From *Val) {
100 return isa_impl<To, From>::doit(*Val);
104 template <typename To, typename From> struct isa_impl_cl<To, const From*> {
105 static inline bool doit(const From *Val) {
107 return isa_impl<To, From>::doit(*Val);
111 template <typename To, typename From> struct isa_impl_cl<To, const From*const> {
112 static inline bool doit(const From *Val) {
114 return isa_impl<To, From>::doit(*Val);
118 template<typename To, typename From, typename SimpleFrom>
120 // When From != SimplifiedType, we can simplify the type some more by using
122 static bool doit(const From &Val) {
125 simplify_type<const From>::getSimplifiedValue(Val));
131 // When From == SimpleType, we are as simple as we are going to get.
151 template<class To, class From> struct cast_retty;
154 // type of To and a source type of From.
155 template<class To, class From> struct cast_retty_impl {
158 template<class To, class From> struct cast_retty_impl<To, const From> {
162 template<class To, class From> struct cast_retty_impl<To, From*> {
166 template<class To, class From> struct cast_retty_impl<To, const From*> {
170 template<class To, class From> struct cast_retty_impl<To, const From*const> {
174 template <class To, class From>
175 struct cast_retty_impl<To, std::unique_ptr<From>> {
177 using PointerType = typename cast_retty_impl<To, From *>::ret_type;
184 template<class To, class From, class SimpleFrom>
186 // When the simplified type and the from type are not the same, use the type
194 // When the simplified type is equal to the from type, use it directly.
198 template<class To, class From>
201 To, From, typename simplify_type<From>::SimpleType>::ret_type;
207 template<class To, class From, class SimpleFrom> struct cast_convert_val {
209 static typename cast_retty<To, From>::ret_type doit(From &Val) {
212 simplify_type<From>::getSimplifiedValue(Val));
364 // cast is successful, From refers to nullptr on exit and the casted value
366 // and From is unchanged.