Beispiel #1
0
bool move(To& to, From& from) {
    if (CFGetTypeID(from.c_obj()) == To::type_id()) {
        to.reset(reinterpret_cast<typename To::type>(from.release()));
        return true;
    }
    return false;
}
Beispiel #2
0
 // Pass by reference for lvalue of 'move_ptr'.
 // Also note 'auto_ptr' isn't copy-initializable from one which has
 // a different 'element_type'. See http://tinyurl.com/yo8a7w (defect report #84).
 template< class To, class From > inline
 To move_to(From& from)
 {
     return To(from.release());
 }
To cast(From from) {
    if (CFGetTypeID(from.c_obj()) == To::type_id()) {
        return To(reinterpret_cast<typename To::type>(from.release()));
    }
    return nullptr;
}