Skip to content

Instantly share code, notes, and snippets.

@rgriege
rgriege / init.cpp
Created April 21, 2017 23:43
C struct initialization in C++
#include <cstdio>
#include <cstdlib>
#define INIT_OPEN(type) [] { type _;
#define INIT_CLOSE ; return _; }()
#define INIT(type, body) INIT_OPEN(type) body INIT_CLOSE
struct A {
int i;
};