- 1
TTime childStartTime(TDateTime(2006, EJanuary, 8, 14, 0, 0, 0)); // January 9th 2pm
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−30
TTime childStartTime(TDateTime(2006, EJanuary, 8, 14, 0, 0, 0)); // January 9th 2pm
Из примера calexample в symbian sdk.
−35
// For the probably_koi8_locales we have to look. the standard says
// these are 8859-5, but almost all Russian users use KOI8-R and
// incorrectly set $LANG to ru_RU. We'll check tolower() to see what
// it thinks ru_RU means.
// If you read the history, it seems that many Russians blame ISO and
// Perestroika for the confusion.
...
static QTextCodec * ru_RU_hack(const char * i) {
QTextCodec * ru_RU_codec = 0;
#if !defined(QT_NO_SETLOCALE)
QByteArray origlocale(setlocale(LC_CTYPE, i));
#else
QByteArray origlocale(i);
#endif
// unicode koi8r latin5 name
// 0x044E 0xC0 0xEE CYRILLIC SMALL LETTER YU
// 0x042E 0xE0 0xCE CYRILLIC CAPITAL LETTER YU
int latin5 = tolower(0xCE);
int koi8r = tolower(0xE0);
if (koi8r == 0xC0 && latin5 != 0xEE) {
ru_RU_codec = QTextCodec::codecForName("KOI8-R");
} else if (koi8r != 0xC0 && latin5 == 0xEE) {
ru_RU_codec = QTextCodec::codecForName("ISO 8859-5");
} else {
// something else again... let's assume... *throws dice*
ru_RU_codec = QTextCodec::codecForName("KOI8-R");
qWarning("QTextCodec: Using KOI8-R, probe failed (%02x %02x %s)",
koi8r, latin5, i);
}
#if !defined(QT_NO_SETLOCALE)
setlocale(LC_CTYPE, origlocale);
#endif
return ru_RU_codec;
}
Снова Qt. На этот раз src/corelib/codecs/qtextcodec.cpp и борьба бобра с ослом русских с буржуинскими стандартами ISO.
−55
void f(int...)
{
};
Компилится.
http://ideone.com/yPgoq
−37
static QPainterPath::ElementType qpaintengineex_line_types_16[] = {
QPainterPath::MoveToElement, QPainterPath::LineToElement,
QPainterPath::MoveToElement, QPainterPath::LineToElement,
QPainterPath::MoveToElement, QPainterPath::LineToElement,
... еще 12 строк ...
QPainterPath::MoveToElement, QPainterPath::LineToElement
};
static QPainterPath::ElementType qpaintengineex_rect4_types_32[] = {
QPainterPath::MoveToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, // 1
QPainterPath::MoveToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, // 2
... еще 29 строк ...
QPainterPath::MoveToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, // 31
QPainterPath::MoveToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, // 32
};
Qt 4.x.x, src/gui/painting/qpaintengineex.cpp
Как я понял, используется для ускорения функций drawLines и clip (дабы не выделять память и не заполнять path каждый раз).
−51
void a()
{
}
void b()
{
return a();
}
Компилится.
http://ideone.com/8eP1w
−16
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
−33
bool operator()(int x,int y)
{return x<y;}
Вторая часть) реально интересуются люди
"надо два объекта моего класса сравнить, так?"
ну, вообще жесть
−25
bool operator<(const A *obj){
if (obj->n < this->n)
return true;
else if (this->n < obj->n)
return false;
};
Перегрузка оператора сравнения
−27
class Screen
{
private:
unsigned char *data; // do not move
size_t size; // do not move
−42
#include <iostream>
using namespace std;
int main()
{
for(int i = 0x1; 0x1 <= i; i++)
{
int a = 0x5;
int b = 0xa;
cin >> i;
if(b || a)
{
a += 0x5;
cout << "\n ";
cout << "первое условие: ";
cout << "\n ";
cout << "переменная a = " << a;
cout << "\n ";
cout << "переменная b = " << --b + 0x5 - 0x9;
cout << "\n";
goto var;
}
else
{
var:
cout << "\n ";
cout << "второе условие: ";
a = (0xa - 0x5);
cout << "\n ";
cout << "переменная a = " << a;
cout << "\n ";
cout << "переменная b = " << ++b;
cout << "\n";
}
break;
}
system("pause");
return 0;
}
Попросил чела решить классическую задачку - обменять значениями две переменные, не используя третьей