- 1
- 2
- 3
- 4
- 5
- 6
#ncld<strm.h>
vd mn()
{
ct<<"Hll, wrld!";
cn.gt();
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+25
#ncld<strm.h>
vd mn()
{
ct<<"Hll, wrld!";
cn.gt();
}
Нхй пргрммрвн.
−28
template<typename T, int $1, int _2> struct Matrix
{
...
Vector<T, _2> vectors[$1];
};
−23
std::bad_alloc e;
throw std::move(e);
Написал один новичок. Говорит это особая сильно ускоряющая оптимизация.
−23
bool strictlyLess(std::vector<int> v1, std::vector<int>v2) { // v1 < v2
bool strictly = false;
for(int i = 0; i < v1.size(); i++) {
if(v1[i] > v2[i]) {
return false;
}
if(v1[i] < v2[i]) {
strictly = true;
}
}
return strictly;
}
−22
// UNALIGNED only for IA64 (Itanium)
// for AMD64 & i386 this not needed
void * c_memmove(void *dest, void const *src, size_t n)
{
void *ret = dest;
if (n)
{
(__int8 *&)dest += n;
(__int8 *&)src += n;
switch (int x = n % 4)
{
do
{
if (!!'true')
{
case 0:
*--(UNALIGNED __int32 *&)dest = *--(UNALIGNED __int32 *&)src;
n -= 4;
}
else
{
case 3:
*--(__int8 *&)dest = *--(__int8 *&)src;
case 2:
*--(__int8 *&)dest = *--(__int8 *&)src;
case 1:
*--(__int8 *&)dest = *--(__int8 *&)src;
n -= x;
}
} while (n);
}
}
return ret;
}
−17
if(0){}else for (... тут всякий код...) и тут всякий код
Из реализации foreach в Qt. Не ГК. Кто первый скажет почему не ГК получит пирожок с полочки.
−19
TElement* get(void)
{
TElement* result = this->allocateBuffer();
if (result!=NULL)
{
try
{
::new(result) TElement; //Вызов конструктора.
}catch(...)//Получили исключение в конструкторе конструироваемого объекта.
{
this->deallocateBuffer(result);
throw;
};
};
return result;
};
template<class TArg1>
TElement* get(TArg1 arg1)
{
TElement* result = this->allocateBuffer();
if (result!=NULL)
{
try
{
::new(result) TElement(arg1); //Вызов конструктора.
}catch(...)//Получили исключение в конструкторе конструироваемого объекта.
{
this->deallocateBuffer(result);
throw;
};
};
return result;
};
//...
template<class TArg1, class TArg2, class TArg3, class TArg4, class TArg5, class TArg6>
TElement* get(TArg1 arg1, TArg2 arg2, TArg3 arg3, TArg4 arg4, TArg5 arg5, TArg6 arg6)
{
TElement* result = this->AllocateBuffer();
if (result!=NULL)
{
try
{
::new(result) TElement(arg1, arg2, arg3, arg4, arg5, arg6); //Вызов конструктора.
}catch(...)//Получили исключение в конструкторе конструироваемого объекта.
{
this->DeallocateBuffer(result);
throw;
};
};
return result;
};
Хотя этот баян мы уже видели на Action Script.
−22
class TFunctorMap
{
public:
typedef bool (*TFunctor)(const TSentenceList&, unsigned short &);
private:
std::map<char, TFunctor> _functorMap;
public:
TFunctorMap(void)
{
_functorMap.insert(std::make_pair('g', &RZC));
_functorMap.insert(std::make_pair('t', &STN));
_functorMap.insert(std::make_pair('d', &RTC));
}
TFunctor GetFunctor(const char Key)
{
if (_functorMap.find(Key) == _functorMap.end())
return NULL;
return _functorMap[Key];
}
};
−24
template <bool ValueToLock>
class TBoolLocker
{
private:
bool _lockedValue;
public:
TBoolLocker(void) : _lockedValue(!ValueToLock) {}
TBoolLocker(const TBoolLocker & Copy) : _lockedValue(Copy._lockedValue) {}
const TBoolLocker & operator=(const TBoolLocker & Copy)
{
_lockedValue = Copy._lockedValue;
return *this;
}
bool update(const bool NewValue)
{
if (_lockedValue != ValueToLock)
_lockedValue = NewValue;
return _lockedValue;
}
};
−26
Apply_Deferred_Lighting_Template< LIGHT_STAGE, ELightType::Light_Point >(
context, queue,
lightsArray + lightOffsets[ LIGHT_STAGE, ELightType::Light_Point ],
lightCounts[LIGHT_STAGE][ELightType::Light_Point]
);
Apply_Deferred_Lighting_Template< LIGHT_STAGE, ELightType::Light_Point >(
context, queue,
lightsArray + lightOffsets[ LIGHT_STAGE, ELightType::Light_Spot ],
lightCounts[LIGHT_STAGE][ELightType::Light_Spot]
);
Apply_Deferred_Lighting_Template< LIGHT_STAGE, ELightType::Light_Beam >(
context, queue,
lightsArray + lightOffsets[ LIGHT_STAGE, ELightType::Light_Beam],
lightCounts[LIGHT_STAGE][ELightType::Light_Beam]
);
Здесь больше:
http://www.gamedev.ru/code/forum/?id=162116