- 1
Тест потерянных комментариев
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
Тест потерянных комментариев
0
class UnitedFigure : public Figure {
Figure &f1;
Figure &f2;
public:
UnitedFigure (Figure &_f1, Figure &_f2) : f1(_f1), f2(_f2) {}
double distance_to(const Point &p) const override {
return std::min(f1.distance_to(p), f2.distance_to(p));
}
}
Завезли ссылочные поля класса, это в каком стандарте?
Даже тестил когда то такое, наверное на C++03 и получал ошибку компилятора.
Я и не знал, что добавили такую прекрасную возможность выстрелить себе в ногу.
+2
Definition read_t key cont : Thread :=
call tx_context <- get_tx_context;
call cell <- get_cell key tx_context;
match cell.(cell_write) with
| Some v =>
do _ <- log (read key v);
cont v
| None =>
do v <- read_d key;
let tx_context' := set tx_cells <[key := cell]> tx_context in
do _ <- pd_set tx_context';
do _ <- log (read key v);
cont v
end.
Continuations are like violence, if they don't work then you're not using enough of them.
0
Хрюкни #7
._ __,
|\,../'\
,'. . `.
.-- '`.
( `' , ;
,`--' _, ,'\
,`.____ `.
/ `, |
' \, '
| / /`,
`, . ,` ./ |
' `. ,' |;,' ,@
______| | _________,_____jv______
`. `. ,'
,'_,','_,
`' `'
#1: (vanished) https://govnokod.xyz/_26863
#2: (vanished) https://govnokod.xyz/_26868
#3: https://govnokod.ru/26881 https://govnokod.xyz/_26881
#4: https://govnokod.ru/26896 https://govnokod.xyz/_26896
#5: https://govnokod.ru/26928 https://govnokod.xyz/_26928
#6: (vanished) https://govnokod.xyz/_26952
0
uint64_t stored_msg_id = _container_msg_id.get(ctrl_msg.sequence); // Получаем msg_id из мапы для связки сообщений
if (stored_msg_id)
proto_fill(ctrl_msg, stored_msg_id); // если он там был то новому сообщению даем этот msg_id
else
proto_fill(ctrl_msg); // Иначе формируем новый msg_id
// Отсылаем сообщение
...
// Если msg_id не был в _container_msg_id то произойдет попытка вставки msg_id полученного через proto_fill.
if (!stored_msg_id && !_container_msg_id.insert(ctrl_msg.sequence, ctrl_msg.msg_id))
{
DEBUG(L, 0, "[%p] Can't store request's control message id (%llu) in bunch map" \
", response's msg_id will differ", this, msg.msg_id);
}
С точки зрения читабельности кода, в последнем ветвлении говнокод?
0
#include <stdio.h>
#include <csptr/smart_ptr.h>
#include <csptr/array.h>
void print_int(void *ptr, void *meta) {
(void) meta;
// ptr points to the current element
// meta points to the array metadata (global to the array), if any.
printf("%d\n", *(int*) ptr);
}
int main(void) {
// Destructors for array types are run on every element of the
// array before destruction.
smart int *ints = unique_ptr(int[5], {5, 4, 3, 2, 1}, print_int);
// ints == {5, 4, 3, 2, 1}
// Smart arrays are length-aware
for (size_t i = 0; i < array_length(ints); ++i) {
ints[i] = i + 1;
}
// ints == {1, 2, 3, 4, 5}
return 0;
}
Allocating a smart array and printing its contents before destruction.
C Smart Pointers
What this is
This project is an attempt to bring smart pointer constructs to the (GNU) C programming language.
Features: unique_ptr, shared_ptr macros, and smart type attribute
https://github.com/Snaipe/libcsptr
0
Trying to get property '%s' of non-object: Notice -> Warning
Undefined property: %s::$%s Notice -> Warning
тут брейкинг ченджес подвезли
https://wiki.php.net/rfc/engine_warnings
+2
public function getFlagCode()
{
$code = $this->_storeManager->getStore()->getCode();
switch ($code) {
case 'us':
return 'us';
break;
case 'eu':
return 'eu';
break;
default;
return 'ww';
}
}
+1
catch (Exception &exception)
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
https://github.com/greatis/Anti-WebMiner/blob/master/AntiWebMiner.cpp#L23
+3
foreach ($files as $n => $f) {
$new_content = $common.$namespace_begin.$f.$namespace_end;
$std_methods = array();
preg_match_all('/std::[a-z_0-9]*/', $new_content, $std_methods);
$std_methods = array_unique($std_methods[0]);
$needed_std_headers = array();
$type_headers = array(
'std::move' => '',
'std::vector' => '',
'std::string' => '',
// [...]
'std::unordered_set' => 'unordered_set');
foreach ($type_headers as $type => $header) {
if (in_array($type, $std_methods)) {
$std_methods = array_diff($std_methods, array($type));
if ($header && !in_array($header, $needed_std_headers)) {
$needed_std_headers[] = $header;
}
}
}
if (!$std_methods) { // know all needed std headers
$new_content = preg_replace_callback(
'/#include <([a-z_]*)>/',
function ($matches) use ($needed_std_headers) {
if (in_array($matches[1], $needed_std_headers)) {
return $matches[0];
}
return '';
},
$new_content
);
}
Тут вот в https://govnokod.ru/20049 CHayT предлагал использовать «PHP» в качестве препроцессора для «C» — так вот в «Телеграме» совет оценили и решили взять на вооружение.
https://github.com/tdlib/td/blob/master/SplitSource.php