-
+5
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
#include <iostream>
using namespace std;
struct ko{
int r;
} f;
const ko& taras=f;
int main() {
cout<<
is_same<decltype(taras.r), int>::value
<<" "<<
is_same<decltype((taras.r)), const int &>::value
<<endl;
return 0;
}
What is output you expect? You should answer without looking at ideone link and without using compiler.
http://ideone.com/5O9vtZ
LispGovno,
30 Мая 2014
-
+6
- 1
- 2
- 3
- 4
- 5
const int cx = 5;
int main() {
auto lam = [cx]() mutable {cx=40;};
return 0;
}
Will it compile or not? Why?
http://ideone.com/gtlXKb
LispGovno,
30 Мая 2014
-
+3
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
#define BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(TRAITS_PREFIX, TYPEDEF_TO_FIND) \
template <class T>\
struct TRAITS_PREFIX##_bool\
{\
template<bool Add>\
struct two_or_three {one _[2 + Add];};\
template <class U> static one test(...);\
template <class U> static two_or_three<U::TYPEDEF_TO_FIND> test (int);\
static const std::size_t value = sizeof(test<T>(0));\
};\
\
template <class T>\
struct TRAITS_PREFIX##_bool_is_true\
{\
static const bool value = TRAITS_PREFIX##_bool<T>::value > sizeof(one)*2;\
};\
//
Ну тут как бы все просто и понятно. Но зачем заканчивают макрос кодом
\
//
?
laMer007,
29 Мая 2014
-
+5
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
struct A {
int a;
virtual ~A() {}
};
struct B: public A {
int b;
B(int _b):b(_b){}
virtual ~B() {}
};
A func(){return A();}
int main(int argc, char* argv[])
{
A* a = new B(2);
*a = func();
a->a = 5;
B *b = dynamic_cast<B*>(a);
std::cout << b->b << "\t" << b->a;
return 0;
}
Меня попросили ответить что выведет на экран.
laMer007,
29 Мая 2014
-
+11
- 1
- 2
- 3
- 4
- 5
- 6
- 7
for (_i = 1;_i <= int(strlen(Query10->FieldValue("pattern").c_str()));_i++) {
// ...
}
if (strlen(Query10->FieldValue("pattern_before").c_str()) == strlen(Query10->FieldValue("pattern_short").c_str())) {
// ...
}
Nuff said.
bormand,
29 Мая 2014
-
+12
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
template<typename T, typename T1>
class TSwitch
{
private:
std::function<T1(T)> _functionSwitch;
std::function<void(T)> _defaultFunction;
std::map<T1, std::function<void(T)> > _map;
private:
IActorPtr _protocol;
IActorPtr _port;
IActorPtr _listParam;
IActorPtr _managerData;
public:
TSwitch(std::function<T1(T)> functionSwitch,std::map<T1, std::function<void(T)> > mapSwitch):_functionSwitch(functionSwitch)
,_defaultFunction([](T value){std::cout<<"no way";})
,_map(mapSwitch){}
TSwitch(std::function<T1(T)> functionSwitch, std::function<void(T)> defaultValue,std::map<T1, std::function<void(T)> > mapSwitch):_functionSwitch(functionSwitch)
,_defaultFunction(defaultValue) ,_map(mapSwitch){}
virtual ~TSwitch(){}
public:
void switches(T value)
{
auto it=_map.find(_functionSwitch(value));
if (it==_map.end()) {_defaultFunction(value); return;}
it->second(value);
}
};
Вот такая замена switch. Отстойно не правда-ли?
IKing,
29 Мая 2014
-
+5
- 1
- 2
- 3
- 4
//Так я легко "девушку" найду
If(user.usingOS =="linux" && user.female=true){
user.Подкатить();
}
Решил выпендриться, и сам наговнокодил
joker,
28 Мая 2014
-
+16
- 1
- 2
- 3
- 4
- 5
- 6
std::string response;
...
char* result = new char[response.size() + 1];
memcpy(&result[0], &response.c_str()[0], response.size());
result[response.size()] = 0;
return result;
Сам метод возвращает char * (при этом никто не запрещал использовать непосредственно std::string).
ЗЫ жаль что весь проект запостить нельзя. Он весь достоин.
h4tr3d,
27 Мая 2014
-
+17
- 1
- 2
- 3
- 4
- 5
io_service::strand strand_one(service), strand_two(service);
for (int i = 0; i < 5; ++i)
service.post(strand_one.wrap(boost::bind(func, i)));
for (int i = 5; i < 10; ++i)
service.post(strand_two.wrap(boost::bind(func, i)));
Пример из книги Boost.Asio C++ Network Programming.
In the preceding code, we made sure that the first five and the last five were serialized namely, "func called, i = 0" is called before "func called, i = 1", which is called before "func called, i = 2", and so on. The same goes for "func called, i = 5", which is called before "func called, i = 6", and "func called, i = 6" is called before "func called, i = 7", and so on.
"А вот хуй тебе!", - сказал четырёхъядерный процессор, и выполнил коллбеки внутри strand'ов в случайном порядке.
bormand,
25 Мая 2014
-
+11
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
QString Factory::lifeEqual(WidgetEnum::SearchWidgetSet param) {
switch (param) {
case WidgetEnum::station:
return "Станция";
case WidgetEnum::water_area:
return "Акватория";
case WidgetEnum::station_coordinates:
return "Координаты станции";
case WidgetEnum::volume_of_filtered_water:
return "Объем отфильтрованной воды";
case WidgetEnum::chlorophyll_a_concentration:
return "Концентрация хлорофила а";
case WidgetEnum::chlorophyll_b_concentration:
return "Концентрация хлорофила b";
case WidgetEnum::chlorophyll_c_concentration:
return "Концентрация хлорофила c";
case WidgetEnum::A665k:
return "A(665k";
case WidgetEnum::pigment_index:
return "Индекс пигмента";
case WidgetEnum::pheopigments:
return "Феопигменты";
case WidgetEnum::upholding_sample_time:
return "Время выдержки образца";
case WidgetEnum::concetrated_sample_volume:
return "Объемная концентрация образца";
case WidgetEnum::cameras_viewed_number:
return "Качество камеры";
case WidgetEnum::total:
return "Общая численость";
case WidgetEnum::total_species:
return "Число видов в пробе";
case WidgetEnum::total_biomass:
return "Общая биомасса";
case WidgetEnum::total_percent:
return "Итоговый процент";
case WidgetEnum::biomass_percent:
return "Процент биомасс";
case WidgetEnum::percentage_of_total:
return "Процент от общего числа";
case WidgetEnum::percentage_of_the_total_biomass:
return "Процент от общего числа биомассы";
case WidgetEnum::number:
return "Номер";
case WidgetEnum::biomass:
return "Биомасса";
case WidgetEnum::total_species_in_group:
return "Всего видов в группе";
case WidgetEnum::name:
return "Название";
case WidgetEnum::name_alt:
return "Альтернативное название";
case WidgetEnum::name_rus:
return "Русское название";
case WidgetEnum::fishing_gear:
return "Рыболовный аппарат";
case WidgetEnum::assessment_of_zooplankton:
return "Оценка зоопланктона";
case WidgetEnum::date:
return "Дата";
case WidgetEnum::Station_water_area:
return "";
case WidgetEnum::groupsOfPh_name:
return "Название группы";
case WidgetEnum::groups:
return "Вид";
case WidgetEnum::error:
return "errorA";
case WidgetEnum::chlorinity:
return "chlorinity";
case WidgetEnum::density:
return "density";
case WidgetEnum::volume:
return "volume";
case WidgetEnum::o2_mg_l:
return "o2_mg_l";
case WidgetEnum::o2_ml_l:
return "o2_ml_l";
case WidgetEnum::bod5:
return "bod5";
case WidgetEnum::ph:
return "ph";
case WidgetEnum::alk:
return "alk";
case WidgetEnum::no2:
return "no2";
case WidgetEnum::no3:
return "no3";
case WidgetEnum::total_n:
return "total_n";
case WidgetEnum::po4:
return "po4";
case WidgetEnum::total_p:
return "total_p";
case WidgetEnum::si:
return "si";
And etc.....
В таком духе имеется строк 300, и если бы выход здравого смысла из спячки и наличие базы данных, 50 строчек которыми все это стало, с течением времени могло бы превратиться в 1000 строк, если не больше.
И хоть это банальный гавногод, жалко трудов и времени на него затраченных. А так хоть канет в бездне говногода, а не в бездне моего винта.
smith599,
25 Мая 2014