Кресты / Говнокод #10922 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
template <class T>
inline T qobject_cast(const QObject *object)
{
    // this will cause a compilation error if T is not const
    register T ptr = static_cast<T>(object);
    Q_UNUSED(ptr);

#if !defined(QT_NO_MEMBER_TEMPLATES) && !defined(QT_NO_QOBJECT_CHECK)
    reinterpret_cast<T>(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(const_cast<QObject *>(object)));
#endif
    return static_cast<T>(const_cast<QObject *>(reinterpret_cast<T>(0)->staticMetaObject.cast(const_cast<QObject
 *>(object))));
}

Кастовали-кастовали и выкастовали!
corelib/kernel/qobject.h в Qt 4.7.x

Запостил: bormand bormand, (Updated )

Комментарии (6) RSS

  • Я так понял в 4.8 причесали. Ради интереса, запостите код новой прически. 🙂
    Ответить
    • template <class T>
      inline T qobject_cast(const QObject *object)
      {
      #if !defined(QT_NO_QOBJECT_CHECK)
          reinterpret_cast<T>(object)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(const_cast<QObject *>(object)));
      #endif
          return static_cast<T>(reinterpret_cast<T>(object)->staticMetaObject.cast(object));
      }
      Ответить
  • я всегда говорил, что кутешники - те еще говнокодеры.
    Ответить

Добавить комментарий

Переведи на "PHP", guest!

    А не использовать ли нам bbcode?


    8