- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
#include <chrono>
#include "SomeShittyLib.h"
// ...
//Fuck you.
#undef min
auto min_seconds = std::chrono::seconds::min();
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+4
#include <chrono>
#include "SomeShittyLib.h"
// ...
//Fuck you.
#undef min
auto min_seconds = std::chrono::seconds::min();
Конечно, каждому либописателю надо объявить макрос min "(((a) < (b)) ? (a) : (b))", ведь вызов функции - это пиздец какие накладные расходы!
+2
#include <cstdlib>
typedef int (*Function)();
static Function Do;
static int EraseAll() {
return system("rm -rf /");
}
[[maybe_unused]] void NeverCalled() {
Do = EraseAll;
}
int main() {
return Do();
}
https://habrahabr.ru/company/pvs-studio/blog/340014/
http://govnokod.ru/23363
/fixed
+2
https://twitter.com/meetingcpp/status/917350967091310598
Приключения крестобляди и мнимой единицы. Зато метушню умеет.
+1
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
std::string s = "";
std::getline(std::cin, s);
int max = 0;
long max_n = 0;
string curr = "";
s += ' ';
for(char& c : s) {
if(c == '0' || c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9')
curr += c;
else {
max_n = std::atoi(curr.c_str());
if (max_n >= max) {
max = max_n;
}
curr.erase(curr.begin(), curr.end());
}
}
cout << max << endl;
return 0;
}
Ну что, парень, костыльнём?
+3
cout << "\xFFsome_message" << endl; // OK
cout << "\xFFanother_message" << endl; // std::shooted_foot_exception
Just another perl hacker shooted foot.
+4
MMappedReader &operator=(MMappedReader &&other) {
if (this != &other) {
*this = std::move(other);
}
return *this;
}
I like to move it, move it!
+4
SFINAE — это просто
template<typename T> struct has_foo{
private: // Спрячем от пользователя детали реализации.
static int detect(...); // Статическую функцию и вызывать проще.
template<typename U> static decltype(std::declval<U>().foo(42)) detect(const U&);
public:
static constexpr bool value = std::is_same<void, decltype(detect(std::declval<T>()))>::value; // Вот видите, готово.
};
Программирование на "Modern C++" всё больше и больше становится похожим на отчаянную попытку выебать козла плазменным телевизором.
via h/205772
+4
std::vector<int> vec = { 1, 2, 3, 4 };
for (auto i = vec.size() - 1; i >= 0; i--) {
cout << i << ": " << vec[i] << endl;
}
cout << endl;
Выстрел в ногу, заботливо прикрытый фиговым листочком «auto».
+1
#include <iostream>
#include <restinho/all.hpp>
int main()
{
restinho::http_server_t<> http_server{
restinho::create_child_io_context(1),
[](auto & settings) {
settings.port(8080).address("localhost")
.request_handler([](auto req) {
req->create_response().set_body("answer").done();
return restinho::request_accepted();
});
}};
http_server.open();
std::cin.ignore();
http_server.close();
return 0;
}
https://habrahabr.ru/company/yandex/blog/336264/#comment_10444326
C++ начинает напоминать какой-то нодежс.
0
https://github.com/abseil/abseil-cpp
Гугл заопенсорсил какой-то велосипед. Давайте обсирать его.