- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
void setEnabled(bool enabled)
{
super.setEnabled(enabled)
if (enabled) {
objectsArray.disable();
return;
}
enable();
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+16
void setEnabled(bool enabled)
{
super.setEnabled(enabled)
if (enabled) {
objectsArray.disable();
return;
}
enable();
}
−1
parallel_for(1, 6, [](int value) {
wstringstream ss;
ss << value << L' ';
wcout << ss.str();
});
Вместо того чтобы заняться допиливанием С++11 для студии, макрософт решила написать своё параллельное апи и глупые примерчики к нему на тему вывести случайную перестановку элементов.
+6
#include <iostream>
using std::cout;
using std::endl;
auto power(double x, int n)-> double*;
int main()
{
void * c = power(5,2);
std::cout << *(double*)c << std::endl;
return 0;
}
auto power(double x, int n)-> double*
{
double* result(new double(1.0));
for(int i = 1; i <= n; i++)
*result *= x;
return result;
}
+9
// When F does not contain result_type, result_of<F(T1, T2, ..., TN)>::type is F::result<F(T1, T2, ..., TN)>::type when N > 0 or void when N = 0.
http://www.boost.org/doc/libs/1_54_0/libs/utility/utility.htm#result_of
> void when N = 0.
Создатели boost::result_of решили, что если функция принимает 0 аргументов, то она не может ничего возвращать кроме void.
+20
Matrix matrix ( h, w );
delete &h, &w;
for ( int i = 0; i < h; i++ )
{
for ( int j = 0; j < w; j++ )
{
cout << "Введите элемент [" << i << ", " << j << "]: ";
cin >> matrix[i][j];
}
}
Найди ошибку...
+14
#include <iostream>
#include <conio.h>
#include <math.h>
using namespace std;
int main()
{
setlocale(0,"Russian");
cout<<"Пишиш без a,b,c,приклад: 2 5 -12 або натиснеш на Enter и пишеш вниз,"<<endl;
cout<<"ПИШИ:"<<endl;
float D;
int repetare=0;
int a;
int b;
int c;
int x1;
int x2;
repetare;
{
while(repetare<100)
{
cout<<"a=";
cin>>a;
cout<<"b=";
cin>>b;
cout<<"c=";
cin>>c;
D=(b^2-(4*a*c))*(-1);
x1=(b-sqrt(D))/(2*a);
x2=(b+sqrt(D))/(2*a);
if (D>0)
{
cout<<"D="<<D<<endl;
cout<<"x1="<<x1<<endl;
cout<<"x2="<<x2<<endl;
cout<<"Имеет два кореня"<<endl;
}
if (D<0)
{
cout<<"D="<<D<<endl;
cout<<"Не имеет кореней"<<endl;
}
if(D=0)
{
cout<<"D="<<D<<endl;
cout<<"x1="<<x1<<endl;
cout<<"Имеет один корень"<<endl;
}
repetare++;
}
}
getche();
return 0;
}
С одного из сайтов игроделов. Просто оставлю это здесь
+83
typedef map<string,string> keys_map;
...
const keys_map::const_iterator SectionData::operator[](int Index) const
{
keys_map::const_iterator it=m_Keys.begin();
int cnt=0;
for(;it!=m_Keys.end(); it++)
{
if(cnt==Index)
return it;
cnt++;
}
return (keys_map::const_iterator)NULL;
}
...
SectionData section;
keys_map::::const_iterator iter;
for (i=0; i<section.GetSize(); i++) {
iter = section[i];
...
}
правильный способ итерироваться по мапу
+77
float tlen = sqrtf(top[0]*top[0]+top[1]*top[1]+top[2]*top[2]);
Всё в мире тлен и безысходность. В том числе и код.
+15
union AtomicIndx
{
struct { std::atomic<uint16> ReadCur, ReadMax, WriteCur, WriteMax; };
struct { struct Idx { uint16 Cur, Max; }; std::atomic<Idx> Read, Write; };
struct { struct Idx { uint16 ReadCur, ReadMax, WriteCur, WriteMax; }; std::atomic<Idx> All; };
};
static_assert(sizeof(AtomicIndx) == sizeof(uint64), "sizeof(AtomicIndx) != sizeof(uint64)");
Мы все знаем откуда это.
+20
template<class T>
void FuncSmth(T value)
{
if(typeid(T) == typeid(int))
FuncInt(value);
else if(typeid(T) == typeid(char*))
FuncCharPtr(value);
}
Оттуда