Постироничные идеи для ебаного C++ – Telegram
Постироничные идеи для ебаного C++
322 subscribers
51 photos
1 video
2 files
20 links
Download Telegram
/* /* */
#include <fmt/core.h>
int main() {
fmt::println("Hello C++!");
auto _ = R"(*/
fn main() {
println!("Hello Rust!");
const _:&str = ")";
}

$ g++ -x c++ code.rspp -lfmt -o as-cxx && ./as-cxx
Hello C++!

$ rustc code.rspp -o as-rs && ./as-rs
Hello Rust!
😁11🥰5👍2
Forwarded from Ладно, посмотрим куда приведет меня жизнь
Вы все ждали этого момента и его время пришло...
🔥10😁7🍓2
на код-ревью жаловаться на магические числа под каждым использованием mt19937
❤‍🔥22
Использовать PVS

(🥺https://pvs-studio.ru/ru/docs/warnings/v837/ эта штука ругается в том числе на insert который применяется к результату extract и на insert нескольких элементов через 2 итератора🥺)
🔥11👍31
%:define bitard bitand
%:define pidor bitor

if (a bitard a pidor b) <%
    auto greet = <:bitard:>(auto and n) <%
cout << n << a << endl;
%>;
    greet("Anon");
%>
👍5
macro_rules! static_assert_eq_usize {
($lhs:expr, $rhs:expr) => {
const _: [(); $lhs] = [(); $rhs];
}
}

macro_rules! assert_layout {
{
$(
$t:ident (size = $size:expr, align = $align:expr) {
$($member:ident @ $offset:expr,)*
}
)*
} => {
$(
static_assert_eq_usize!($size, std::mem::size_of::<$t>());
static_assert_eq_usize!($align, std::mem::align_of::<$t>());
$(static_assert_eq_usize!($offset, std::mem::offset_of!($t, $member));)*
)*
}
}

#[repr(C)]
struct LogHeader {
magic: u64,
version: u64,
length: u64,
}

#[repr(C, packed(4))]
struct LogEntry {
timestamp: u32,
data: u64,
}

assert_layout! {
LogHeader (size = 24, align = 8) {
magic @ 0,
version @ 8,
length @ 16,
}
LogEntry (size = 12, align = 4) {
timestamp @ 0,
data @ 4,
}
}
🏆3😁2
Согласно аксиомам практики программирования, любая программа может быть сколько-то сокращена и оптимизирована без потери функциональности; также любая программа содержит хотя бы одну ошибку.

Значит, любую программу можно сократить до программы из одной или нуля инструкций, которая при этом не работает.

Разработчики gcc и clang наперегонки ищут такую результирующию программу для любого исходного кода.
🔥21
struct foo {
int baz[];
}

struct bar;

namespace baz {
struct { void operator&=(auto&&) {} } foo;
}

int main() {
baz::foo &= [](bar* foo) -> int { return 1; };
{ return 1; } int (foo::* bar)[] =& foo::baz;
}
🤯9🤣3👍2
cargo init --bin
cargo add serde
cargo add --features arbitrary_precision

use serde::Deserialize;

#[derive(Debug, Deserialize)]
#[serde(tag = "type")]
enum MyEnum {
A { val: f64 },
}

fn main() {
let json = r#"{ "type": "A", "val": 0.0, "v": 9999999999999999999999999999999 }"#;
let my_enum: MyEnum = serde_json::from_str(json).unwrap();
println!("{:?}", my_enum);
}

thread 'main' panicked at src/main.rs:10:54:
called `Result::unwrap()` on an `Err` value: Error("invalid type: map, expected f64", line: 0, column: 0)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

use serde::Deserialize;
use serde_json::Value;

#[derive(Debug, Deserialize)]
#[serde(tag = "type")]
enum MyEnum {
A { val: f64 },
}

fn main() {
let json = r#"{ "type": "A", "val": 0.0, "v": 9999999999999999999999999999999 }"#;
let value: Value = serde_json::from_str(json).unwrap();
let my_enum: MyEnum = serde_json::from_value(value).unwrap();
println!("{:?}", my_enum);
}

thread 'main' panicked at src/main.rs:12:57:
called `Result::unwrap()` on an `Err` value: Error("invalid type: integer `9999999999999999999999999999999` as u128, expected any value", line: 0, column: 0)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

доброе утро, спасибо за внимание, я пойду спать
💔2🤡1
дёмдальш, следующий донат

"привет марго а кто сильнее C++ или Rust, мне кажется C++, ведь он более низкоуровневый и быстрый"

доооо, охуенно, чувак а ты в курсе что у Rust больше компиляторного контекста и лучше вывод типов ?

Rust сильнее тк он заранее знает какую функцию ты вызовешь и оптимизирует код . это реально нужно объяснять?
🔥16🗿4👏1💋1
Andrew Tomazos, a long-time contributor to the ISO C++ standards committee, recently published a technical paper noscriptd "The Undefined Behavior Question". The paper explores the semantics of undefined behavior in C++ and examines this topic in the context of related research. However, controversy arose regarding the paper's noscript.

Some critics pointed out similarities between the noscript and Karl Marx's 1844 essay "On The Jewish Question", as well as the historical implications of the "Jewish Question", a term associated with debates and events leading up to World War II. This led to accusations that the noscript was "historically insensitive."

In response to requests to change the noscript, Mr. Tomazos declined, stating that "We cannot allow such an important word as 'question' to become a form of hate speech." He argued that the term was used in its plain, technical sense and had no connection to the historical context cited by critics.

Following this decision, Mr. Tomazos was expelled from the Standard C++ Foundation, and his membership in the ISO WG21 C++ Standards Committee was revoked.
🥴15😁8
Как хорошо, что инструменты вроде clang-format и rustfmt полагаются на детерминистичные алгоритмы, а не модные языковые модели! Они всегда сохранят (а иногда и проверят) валидность кода и не подвержены синтаксическим галлюцинациям.
😁23