Forwarded from Vitya Smirnov 😐
YouTube
Coding In China Be Like (C++)
Font used:
Consolas
Credits:
https://www.youtube.com/watch?v=0cjQ-QFimw4
if (you.liked((*this).video)) {
subscribe.to(SENTRY);
} else if (you.disliked((*this).video)) {
subscribe.to(SENTRY);
} else {
subscribe.to(SENTRY);
}
#meme
#memes…
Consolas
Credits:
https://www.youtube.com/watch?v=0cjQ-QFimw4
if (you.liked((*this).video)) {
subscribe.to(SENTRY);
} else if (you.disliked((*this).video)) {
subscribe.to(SENTRY);
} else {
subscribe.to(SENTRY);
}
#meme
#memes…
👍3
int plus(int a, int b);
int minus(int a, int b);
int plus(int a, int b){
if(a<0 && b>0) return minus(b, -a);
if(b<0 && a>0) return minus(a, -b);
if(a<0 && b<0) return -plus(-a, -b);
if(a==0) return b;
if(b==0) return a;
return plus(a-1, b-1)+2;
}
int minus(int a, int b){
if(a<0 && b>0) return -plus(-a, b);
if(b<0 && a>0) return plus(a, -b);
if(a<0 && b<0) return -minus(-a, -b);
if(a==0) return -b;
if(b==0) return a;
return minus(a-1, b-1);
}
🔥1
#![no_main]
#[link_section=".text"]
#[no_mangle]
pub static main: [u32; 9] = [
3237986353,
3355442993,
120950088,
822083584,
252621522,
1699267333,
745499756,
1919899424,
169960556,
];
👍6
В std::function нельзя сложить лямбду которая захватила uptr
https://godbolt.org/z/jr3oxj1hd дрался с компилятором. Победил и проиграл одновременно(он компилит без ошибки, но не линкуется)
godbolt.org
Compiler Explorer - C++
namespace {
struct A{
int i;
};
}
template<typename... Ts>
auto tupleAlloc(std::tuple<Ts...>&& args) {
auto lamb = [&](Ts... args) {
return std::make_unique<std::tuple<std::decay_t<Ts>...>>(args...);
};
return std::apply(std::move(lamb)…
struct A{
int i;
};
}
template<typename... Ts>
auto tupleAlloc(std::tuple<Ts...>&& args) {
auto lamb = [&](Ts... args) {
return std::make_unique<std::tuple<std::decay_t<Ts>...>>(args...);
};
return std::apply(std::move(lamb)…
struct slice {
T* ptr; // петербург
size_t len; // ленобласть
};😁12🤡1🤣1
Forwarded from Андрей Будиловский
Если вы понимаете этот код, то вам открыт доступ в айти-канал с мемами для программистов 👇
template <typename T, typename... Args,
typename = std::void_t<decltype(::new(std::declval<void*>()) T(std::declval<Args>()...))>>
AA_ALWAYS_INLINE constexpr T* construct_at(const T* location, Args&&... args) noexcept(noexcept(
::new(const_cast<void*>(static_cast<const volatile void*>(location))) T(std::forward<Args>(args)...))) {
return ::new (const_cast<void*>(static_cast<const volatile void*>(location)))
T(std::forward<Args>(args)...);
}
template <typename T, typename... Args,
typename = std::void_t<decltype(::new(std::declval<void*>()) T(std::declval<Args>()...))>>
AA_ALWAYS_INLINE constexpr T* construct_at(const T* location, Args&&... args) noexcept(noexcept(
::new(const_cast<void*>(static_cast<const volatile void*>(location))) T(std::forward<Args>(args)...))) {
return ::new (const_cast<void*>(static_cast<const volatile void*>(location)))
T(std::forward<Args>(args)...);
}
😁1
Forwarded from Vladimir🏴☠️ [🥴] 💅
#include <cinttypes>
#include <string>
#include <variant>
#include <optional>
#include <vector>
using u8 =uint8_t;
using i8 = int8_t;
using u16= uint16_t;
using i16 = int16_t;
using u32= uint32_t;
using i32 = int32_t;
using u64 = uint64_t;
using i64 = int64_t;
using usize = size_t;
using isize = ptrdiff_t;
using f32 = float;
using f64 = double;
using String = std::string;
template <typename T>
using Vec = std::vector<T>;
template <typename T>
using Option = std::optional<T>;
Программируйте на плюсах правильно!
#include <string>
#include <variant>
#include <optional>
#include <vector>
using u8 =uint8_t;
using i8 = int8_t;
using u16= uint16_t;
using i16 = int16_t;
using u32= uint32_t;
using i32 = int32_t;
using u64 = uint64_t;
using i64 = int64_t;
using usize = size_t;
using isize = ptrdiff_t;
using f32 = float;
using f64 = double;
using String = std::string;
template <typename T>
using Vec = std::vector<T>;
template <typename T>
using Option = std::optional<T>;
Программируйте на плюсах правильно!
❤1
trait Abs { fn abs(self) -> Self; }
impl Abs for i64 {
fn abs(self) -> Self { 2 * self }
}
fn main() {
let x = 42;
println!("{} {}", x.abs(), x.abs());
}$ rustc abs.rs -o abs && ./abs
84 42
🤯3🤨1
error-log
9 MB
namespace ns {
struct Foo;
using Foo = int;
}
#include <fmt/format.h>$ time g++-13 -std=gnu++20 -c foo.cpp 2>error-log
real 1m44.740s
user 1m44.370s
sys 0m0.313s
$ du -h error-log
9.1M error-log
🤯2😁1
План по развалу проклятой Америки:
1. Присоединяем Грузию к США как штат
2. Нарушается ODR, пендосы переиграны
1. Присоединяем Грузию к США как штат
2. Нарушается ODR, пендосы переиграны
👍7
