Skip to content

Instantly share code, notes, and snippets.

View DieHertz's full-sized avatar

Andrey Mironov DieHertz

  • Tel-Aviv
View GitHub Profile
int main(int argc, char** argv) {
const auto n = argc;
[=] () mutable {
return ++n;
};
}
#include <thread>
#include <atomic>
#include <iostream>
int x, y;
int r1, r2;
int main() {
auto th1 = std::thread{[] {
r1 = x;
#include <thread>
#include <atomic>
#include <iostream>
int x, y;
int r1, r2;
int main() {
auto th1 = std::thread{[] {
y = 1;
#include <memory>
inline int32_t murmur_hash_3_finalizer(int32_t key) {
key ^= key >> 16;
key *= 0x85ebca6b;
key ^= key >> 13;
key *= 0xc2b2ae35;
key ^= key >> 16;
return key;
@DieHertz
DieHertz / rvalue-reference-to-temporary-subobject.cpp
Created April 26, 2014 17:36
Lifetime of temporary object is extended until the end of scope of reference to subobject.
#include <iostream>
struct Foo {
~Foo() { std::cout << "~Foo()\n"; }
};
struct Bar {
Foo foo;
~Bar() { std::cout << "~Bar()\n"; }
};
#include <vector>
#include <functional>
#include <algorithm>
#include <utility>
#include <type_traits>
#include <iostream>
template<typename T> auto read_vector() {
return std::vector<T>{std::istream_iterator<T>{std::cin}, std::istream_iterator<T>{}};
}
#include <vector>
#include <functional>
#include <algorithm>
#include <iterator>
#include <iostream>
#include <utility>
#include <type_traits>
template<typename T> auto read_vector() {
return std::vector<T>{std::istream_iterator<T>{std::cin}, std::istream_iterator<T>{}};
#include <utility>
struct Foo {
void method_one(const int& a, bool b) {}
template<typename... T> using mem_fn_ptr = void (Foo::*)(T...);
// 1
template<typename... T> void process(mem_fn_ptr<T...>) {}
@DieHertz
DieHertz / fetch-pkg-deps-no-ignore.py
Created April 21, 2014 10:07
arch-pkg-fake-fetcher.py
from htmldom import htmldom
import string
import re
import sys
import queue
def get_pkg_name(pkg_url):
return pkg_name_regex.search(pkg_url).group(1)
def fetch_with_deps():
@DieHertz
DieHertz / int-plus-uint.cpp
Last active August 29, 2015 13:59
int-plus-int.cpp
#include <iostream>
int main() {
std::cout << 180u - 360 << std::endl;
}