Skip to content

Instantly share code, notes, and snippets.

@jvranish
jvranish / c_option_type.c
Last active May 2, 2022 19:17
Simple option type in C
//usr/bin/make -s "${0%.*}" CFLAGS="-O2 -Wall -Werror" && ./"${0%.*}" "$@"; s=$?; rm ./"${0%.*}"; exit $s
#include <stdio.h>
#include <stdbool.h>
enum option_tag { OPTION_SOME, OPTION_NONE };
#define option_type(T) { enum option_tag tag; T some; }
#define SOME(S) { .tag = OPTION_SOME, .some = S }
#define NONE() { .tag = OPTION_NONE }
@nabijaczleweli
nabijaczleweli / wscript
Last active September 26, 2015 17:45
The base waf build system script
#!/usr/bin/env python3
def options(opts):
opts.load('compiler_cxx')
def configure(conf):
conf.load('compiler_cxx')
conf.check(features='cxx cxxprogram', cxxflags=['-std=c++14', '-Wall', '-Wextra', '-O3', '-pedantic', '-pipe'], uselib_store='M')
@nabijaczleweli
nabijaczleweli / variadic-template-iterate.hpp
Last active June 13, 2021 21:35
Iterate over all elements of variadic template
#include <cstddef>
#include <utility>
template<class T, class... TT>
struct over_all {
using next = over_all<TT...>;
static const constexpr std::size_t size = 1 + next::size;
template<class C>