Skip to content

Instantly share code, notes, and snippets.

#include <cstdlib>
#include <atomic>
#include <exception>
#include <iostream>
#include <memory>
#include <mutex>
#include <utility>
class JrpException : public ::std::exception {};
#include <cstdio>
#include <future>
#include <map>
#include <memory>
#include <string>
void do_thing(std::string a); // forces a copy
void do_thing_ref(std::string& a); // no copy, can mutate a
void do_thing_ptr(std::string* a); // no copy, can obviously mutate a
@mrdomino
mrdomino / stkintro.c
Last active September 15, 2023 13:27
compile with -lsigsegv
#include <inttypes.h>
#include <setjmp.h>
#include <signal.h>
#include <sigsegv.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
struct bond {
uintptr_t dof;
#include <cassert>
#include <future>
#include <list>
#include <queue>
#include <thread>
#include <vector>
class State {
public:
State(): started(false), pending_get_values(false), exiting(false) {}
#pragma once
#include <mutex>
#include <type_traits>
template <typename Mutex, typename... Args>
auto make_unique_lock(Mutex&& m, Args&&... args)
-> std::unique_lock<typename std::remove_reference<Mutex>::type> {
return std::unique_lock<typename std::remove_reference<Mutex>::type>(
std::forward<Mutex>(m), std::forward<Args>(args)...);
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
static const char slash[] = "/";
int main(__attribute__((unused)) int argc, char* argv[]) {
char *self;
@mrdomino
mrdomino / lexical_cast.hpp
Created August 4, 2015 16:16
sstream-driven lexical cast
#pragma once
#include <sstream>
#include <string>
namespace detail {
template <typename T, typename U>
class LexicalCast {
public:
T operator()(U const& u) {
#!/bin/sh
function main {
for cpu in ${CPUS[@]}
do
echo ==== $cpu ====
check bazel build --ios_cpu=$cpu $DEPS
check mkdir -p $WORK/$cpu
for dep in $DEPS
do
@mrdomino
mrdomino / copies.c++
Last active October 24, 2015 17:41
copy and assignment operator autogeneration
class A {};
class B {
public:
B() = default;
B(B const&) = delete;
};
class C {
public:
#include <cstdio>
#include <exception>
#include <utility>
// hypothetically...
class MyException : public std::exception {
public:
const char *what() const noexcept {
return "nope";