- 1
- 2
- 3
//
// TEMPLATE CLASS vector<bool, Alloc> AND FRIENDS
//
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+2
//
// TEMPLATE CLASS vector<bool, Alloc> AND FRIENDS
//
0xB друзей Вектора.
via UCRT <vector>
0
void DevToolsHttpHandler::OnJsonRequest(
int connection_id,
const net::HttpServerRequestInfo& info) {
// Trim /json
std::string path = info.path.substr(5);
// Trim fragment and query
std::string query;
size_t query_pos = path.find("?");
if (query_pos != std::string::npos) {
query = path.substr(query_pos + 1);
path = path.substr(0, query_pos);
}
size_t fragment_pos = path.find("#");
if (fragment_pos != std::string::npos)
path = path.substr(0, fragment_pos);
std::string command;
std::string target_id;
if (!ParseJsonPath(path, &command, &target_id)) {
SendJson(connection_id,
net::HTTP_NOT_FOUND,
NULL,
"Malformed query: " + info.path);
return;
}
...
100500 строк типичного ЦПП бреда
}
https://cs.chromium.org/chromium/src/content/browser/devtools/devtools_http_handler.cc?l=487
https://cs.chromium.org/chromium/src/third_party/WebKit/Source/devtools/scripts/build/generate_protocol_externs.py
+2
#define max(x, y) ((x) > (y) ? (x) : (y)) // Вводим макрос
#define MAX(x, y) max(x, y) // Чтобы не конфликтовал со стандартным max
#define Std namespace std // Так короче
#include <iostream>
#include <vector>
#include <algorithm>
using Std;
int main()
{
bool vvedeno = false;
int kolichestvo;
cin >> kolichestvo;
vector<char> A(kolichestvo);
A: if (vvedeno){goto B;}else{
while(kolichestvo != 0){vvedeno = true; cin >> A[kolichestvo - 1]; kolichestvo = kolichestvo - 1;} // вводим
}
reverse (A.begin(), A.end()); // для определённости развернём
B:
vector<int> B; // Массив из цифр
try{
for (char tipachislo : A)
B.push_back(int(tipachislo) - 48); // преобразуем char к int
}catch(errc){vvedeno = false; kolichestvo = A.size(); goto A;} // ну что-то же ввести надо
C:
int maxim = B[1];
int dlina = B.size();
D:
maxim = MAX(B[dlina - 1], maxim);
dlina--;
if(dlina == -1){cout << maxim;}else{goto D;} // ищем
}
+1
#if ( clang_major==7 && clang_minor==3 )
public std::enable_shared_from_this<CryptoContainer>
#else
public std::enable_shared_from_this<CryptoContainerInterface>
#endif
Во первых непонятно зачем, а во вторых clang > 6 на момент написания даже в проекте не было.
0
https://github.com/TartanLlama/optional/blob/master/optional.hpp#L853
/// Constructs the stored value with `u`.
/// \synopsis template <class U=T> constexpr optional(U &&u);
template <
class U = T,
detail::enable_if_t<std::is_convertible<U &&, T>::value> * = nullptr,
detail::enable_forward_value<T, U> * = nullptr>
constexpr optional(U &&u) : base(in_place, std::forward<U>(u)) {}
/// \exclude
template <
class U = T,
detail::enable_if_t<!std::is_convertible<U &&, T>::value> * = nullptr,
detail::enable_forward_value<T, U> * = nullptr>
constexpr explicit optional(U &&u) : base(in_place, std::forward<U>(u)) {}
/// Converting copy constructor.
/// \synopsis template <class U> optional(const optional<U> &rhs);
template <
class U, detail::enable_from_other<T, U, const U &> * = nullptr,
detail::enable_if_t<std::is_convertible<const U &, T>::value> * = nullptr>
optional(const optional<U> &rhs) {
this->m_has_value = true;
new (std::addressof(this->m_value)) T(*rhs);
}
/// \exclude
template <class U, detail::enable_from_other<T, U, const U &> * = nullptr,
detail::enable_if_t<!std::is_convertible<const U &, T>::value> * =
nullptr>
explicit optional(const optional<U> &rhs) {
this->m_has_value = true;
new (std::addressof(this->m_value)) T(*rhs);
}
/// Converting move constructor.
/// \synopsis template <class U> optional(optional<U> &&rhs);
template <
class U, detail::enable_from_other<T, U, U &&> * = nullptr,
detail::enable_if_t<std::is_convertible<U &&, T>::value> * = nullptr>
optional(optional<U> &&rhs) {
this->m_has_value = true;
new (std::addressof(this->m_value)) T(std::move(*rhs));
}
/// \exclude
template <
class U, detail::enable_from_other<T, U, U &&> * = nullptr,
detail::enable_if_t<!std::is_convertible<U &&, T>::value> * = nullptr>
explicit optional(optional<U> &&rhs) {
this->m_has_value = true;
new (std::addressof(this->m_value)) T(std::move(*rhs));
}
Я даже не знаю, какой конкретно фрагмент этого творчества сюда выкладывать.
https://github.com/TartanLlama/optional C++11/14/17 std::optional with functional-style extensions https://optional.tartanllama.xyz
Вообще меня это забавляет, все эти костылепостроения поверх плюсов. Сделайте там уже возможность в компилтайме работать напрямую с исходным кодом самого себя, т.е. чтобы был некий код, который плюсокомпилятором в компилтайме обрабатывался, и чтобы он принимал исходник самого себя просто в виде тупо текста, и мог произвольно менять содержимое исходника на этапе компиляции (не меняя при этом сами файлы в файловой системе), и чтоб в качестве библиотек к этому компилтайм-метушению шел лексер-парсер плюсов.
Понятно что из плюсов никакого гомоиконного лиспа сделать не выйдет, ведь тогда надо выкинуть очень красивый и элегантный плюсосинтаксис вида std::kukarek(std:kudah<std:kokoko{kokoko ko[hui<govno>]}>:()[*huita]{}) и заменить его на бездуховные скобочки
+2
https://github.com/BlackMATov/kari.hpp/blob/master/kari.hpp
Безответственные функциональщики сливали в океан блогосферы радиоактивные отходы, и вот печальный итог: гигантская радиоактивная Метушилла начала сокрушать гитхаб! Даже само название либы уже намекает.
+5
// 600+ lines skipped
int main() {
window["console"] = console;
window["Math"] = Math;
Math["sin"] = Math.sin;
Math["cos"] = Math.cos;
Math["PI"] = Math.PI;
// EXAMPLE:
var x = 3;
var y = x + null;
var z = "hello, " + y;
var n = NaN << NaN;
var f = Function();
console.log("x = " + x + " y = " + y + " z = " + z);
console.log("x =", x,"y =", y, "z =", z);
console.log(String("222") + true);
console.log(String("222") + 3);
console.log(Number("222") + 3);
console.log(NaN << NaN, !NaN);
console.log(undefined + 1);
console.log(f("hello, ", "world"));
console.log("sin(pi/4) = ", Math.sin(Math["PI"] / 4));
console.log("sin(pi/4) = ", window["Math"]["sin"](Math["PI"] / 4));
}
Я поехал вслед за gost'ом (см. http://govnokod.ru/23440)
Читать далее: https://ideone.com/mLM4yN
Рахитектура:
<|- Number
<|- String
<|- Boolean
<|- Function
Object = var <|- Console <- +
| |
| <|- Window - - + ref
| |ref
| v
| <|- Math - - - - -
| |
| |
| |
| ptr | value
| |
| <|- ObjectBody |
| <|- NumberBody |
v <|- StringBody |
BaseBody <|- BoolBody |
<|- NullBody |
<|- UndefinedBody |
v
<|- FunctionBody <|- SinBody
<|- CosBody
Object null, undefined, NaN, Infinity;
Math Math;
Window window;
Console console;
+5
#include <iostream>
#include <type_traits>
#include <list>
#include <vector>
using std::cout;
using std::endl;
using function = int;
struct Console {
private:
template<typename SS, typename TT>
static auto test(int)
-> decltype(std::declval<SS&>() << std::declval<TT>(), std::true_type());
template<typename, typename>
static auto test(...) -> std::false_type;
template<typename T>
static const bool canCout = decltype(test<decltype(cout), T>(0))::value;
public:
template<typename T>
typename std::enable_if<std::is_same<decltype(std::declval<T>().begin()),
decltype(std::declval<T>().end())>::value && !canCout<T>>::type
log(T arg) {
log('[');
for (typename T::const_iterator it = arg.begin(); it != arg.end(); ++it) {
auto nextIt = it;
++nextIt;
if (nextIt != arg.end()) {
log(*it);
log(", ");
} else {
log(*it);
log(']');
}
}
}
template<typename T>
typename std::enable_if<canCout<T>>::type
log(T arg) {
cout << arg;
}
template<typename H, typename ... T>
void log(H arg, T... rest) {
log(arg);
log(' ');
log(rest...);
}
};
static Console console;
function main()
{
console.log(std::vector<int>({ 1, 2, 3 }), "Hello World!", 100.1, "\n");
console.log(std::string("std::string"), std::list<std::string>({ "one", "two", "three" }), '\n');
return 0;
}
Javascript++.
https://ideone.com/NykL0u
0
#include<iostream>
void suka( void(*callback)( void(*)( void(*)() ) ) ) {
std::cout << "Suka, ";
callback( suka );
}
void blyad( void(*callback)( void(*)( void(*)() ) ) ) {
std::cout << "Blyad !!!" << std::endl;
callback( blyad );
}
int main() {
suka( blyad );
return 0;
}
...
+3
https://pbs.twimg.com/media/DMbz4s9UEAACa5x.jpg
how to deprecate an interface