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;
}
To cast(From from) {
    if (CFGetTypeID(from.c_obj()) == To::type_id()) {
        return To(reinterpret_cast<typename To::type>(from.release()));
    }
    return nullptr;
}