This patch aimed to enhance isa utility by making it more generic and reducing code duplication in its implementation in the same time. It extends isa<T>(value) so that isa works with any dereferenceable and implicitly convertible to bool values (i.e. fancy pointer-like types). It supposed to be a part of the following changes that I propose:
Generalize semantics of isa, cast, dyn_cast to any pointer-like types (i.e. dereferenceable and implicitly convertible to bool) so that:
- for each fancy_pointer<T> t: isa<G>(t) returns true iff current implementation of isa<G>(nonfancy_t) returns true where decltype(nonfancy_t) is T*
- all old cast operations should return a raw pointer of type typename std::pointer_traits<fancy_pointer<T>>::element_type * and do not perform ownership transfer.
- move_[dyn_]cast should do what unique_dyn_cast [ab480f45cd23c08cb9aa3f427aad072df249135f] is currently doing in a more generic manner: it move constructs an object of type typename std::pointer_traits<fancy_pointer<T>>::rebind<G>
N.B. the reference to std::pointer_traits is a conception that was used to explain the behaviour - not necessary the way it would be implemented.
Does this change then mean that one could cast<T> from Optional<Derived> to Optional<Base>? Because that'd be problematic, owing to Optional being a value-type. (it'd slice the object)