- 1
QVector<double*>*** ElemBoundCond = tbc->getElementsBC();
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+28
QVector<double*>*** ElemBoundCond = tbc->getElementsBC();
+16
function<future<int> (int)> f = [](int a){ cout << a << '\n'; return mreturn(a + 6); };
int a = (mreturn(5) >>= f).get();
cout << a;
+137
int memcmp (const void* v1, const void* v2, size_t n)
{
uint32_t *s1;
uint32_t *s2;
size_t i;
s1 = (uint32_t*) v1;
s2 = (uint32_t*) v2;
for (i = 0; i < n; i++) {
if (*s1 != *s2) {
return *(const uint32_t *)s1 >
*(const uint32_t *)s2 ? 1 : -1;
}
s1++;
s2++;
}
return 0;
}
Реализация memcmp в библиотеке одной малоизвестной "учебной" ОС реального времени. Учебной в том смысле, что по этой системе разве что доклады, презентации и статьи делали, где-то реально она вряд ли использовалась.
Для интересующихся http://pok.safety-critical.net/
+72
String isFeatureEnabled = object.get("featureEnabledParam");
boolean featureEnabled = app.isFeatureEnabled();
if (Boolean.parseBoolean(isFeatureEnabled) && !featureEnabled) {
return false;
}
if (!Boolean.parseBoolean(isFeatureEnabled) && featureEnabled)
{
return false;
}
+4
int DataBase::garbageCollector(string filename){
fstream from(filename.c_str());
fstream from0((filename+".index").c_str());
Index x;
Data d;
char *a/*,*b*/;
int oldpos = 0 ;
bool done = false;
from.seekg(0,ios::end);
int dbend = static_cast<int>(from.tellp());
from0.seekg(0,ios::end);
int indexend = static_cast<int>(from0.tellp());
if(dbend == BlockSize || indexend == IndexSize){
from.close();
from0.close();
return 0;
}
from.seekg(0,ios::beg);
from0.seekg(0,ios::beg);
while(true){
from0 >> x;
if(from0.eof())break;
if(!x.Num()){
int count = dbend - x.Pointer() - BlockSize;
int count0 = indexend - (static_cast<int>(from0.tellp())+1);
from.seekg(x.Pointer()+BlockSize);
a = new char[count];
from.read(a,count);
from.seekp(x.Pointer());
from.write(a,count);
delete a;
a = new char[count0];
from0.seekp(1,ios::cur);
int test = from0.tellp();
from0.read(a,count0);
from0.clear();
from0.seekp(indexend - count0 - IndexSize,ios::beg);
test = from0.tellp();
from0.write(a,count0);
test = from0.tellp();
delete a;
ofstream to("tmp.base",ios::trunc),to0("tmp.index",ios::trunc);
a = new char[dbend - BlockSize];
from.seekg(0,ios::beg);
from.read(a,dbend - BlockSize);
to.write(a,dbend - BlockSize);
delete a;
a = new char[indexend - IndexSize];
from0.seekg(0,ios::beg);
test = from0.tellp();
from0.read(a,indexend - IndexSize);
to0.write(a,indexend - IndexSize);
delete a;
from.close();
from0.close();
if(remove(filename.c_str()) || rename("tmp.base",filename.c_str())) return -1;
if(remove((filename+".index").c_str()) || rename("tmp.index",(filename+".index").c_str())) return -1;
oldpos = indexend - count0 - IndexSize;
done = true;
break;
}
}
if(done){
from0.open((filename+".index").c_str());
while(true){
from0 >> x;
if(from0.eof())break;
if(x.Pointer() > static_cast<unsigned>((oldpos/23)*BlockSize) ){
x.Pointer(x.Pointer()-BlockSize);
from0.seekp(-(IndexSize-1),ios::cur);
from0 << x;
int test = from0.tellp();
}
else{
from0.seekp(-(IndexSize-1),ios::cur);
from0 << x;
int test = from0.tellp();
from0.clear();
}
}
}
return 0;
}
Собираем пустые блоки
+127
<Grid x:Name="LayoutRoot" >
<Grid.ColumnDefinitions>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
// .. разные контролы
</Grid>
Это тоже кусочек XAML (WPF)
+141
for (; b < d; b++)
subj
+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;
}
+5
#include <iostream>
using namespace std;
void f(void){cout<<"f"<<endl;}
void f1(void){cout<<"f1"<<endl;}
bool secondIfIsTryed(){cout<<"secondIfIsTryed"<<endl;return true;}
#define asserts(Condition) {cout<<"Assert"<<endl;}
int main() {
if(true)
if(secondIfIsTryed() && false)
f();
else
f1();
if(true)
if(secondIfIsTryed() && false)
asserts(true)
else
f1();
return 0;
}
Помните того вечно сомневающегося знакомого, тест крестов, написанный которым я недавно приводил?
http://ideone.com/9Q61D1
В этот раз под его глуповатый, но пытливый взгляд попал макрос ассерта. Написан он конечно не так, как в этом тесте, но имеет код вида:
#define asserts(Condition) {/*...*/}+125
wrs(S):-put_char('\"'), wrsi(S).
wrsi([C|S]):-put_char(C), wrsi(S).
wrsi([]):-put_char('\"').
wrl(S):-put_char('['), wrli(S), put_char(']').
wrli([C|[O|S]]):-wrs(C), put_char(','), wrli([O|S]).
wrli([C]):-wrs(C).
:- wrl(["dog", "cat", "canary"]).
Курю правильные примеры кода на прологе. PrologGovno ждите во всех кинотеатрах страны.
http://ideone.com/L4vIKs
Почему вместо того чтобы пользоваться стандартной функцией вывода списков или строк - автор рекомендует это? Я код правда поправил, а то хаскельных скобок (я уже без них не могу) не было и запятую в конце списка выдавало.