Skip to content

Instantly share code, notes, and snippets.

@sjolsen
sjolsen / cudamap.cc
Last active July 3, 2021 13:43
Combining memory-mapped I/O and CUDA mapped memory
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <cuda_runtime.h>
#include <cerrno>
#include <cstring>
#include <memory>
#include <stdexcept>
@sjolsen
sjolsen / lazy.cc
Last active December 19, 2015 14:49
Simple lazy evaluator for C++
#include <functional>
#include <optional>
template <typename T>
class lazy
{
std::optional <T> result;
std::function <T ()> generator;
public:
@sjolsen
sjolsen / gist:5817795
Last active December 18, 2015 17:19
Lisp in C++ templates: proof-of-concept
// NUM
template <typename T, T Val>
struct _NUM_IMPL
{
static const T value = Val;
};
#define NUM(val) _NUM_IMPL <decltype (val), val>