Skip to content

Instantly share code, notes, and snippets.

View rmartinho's full-sized avatar

R. Martinho Fernandes rmartinho

View GitHub Profile
#include <tuple>
#include <type_traits>
template <int... I>
using bar = std::tuple<std::integral_constant<int, I>...>;
template <int... I>
struct foo {
int total(bar<I...> const&) const { return 0; } // error C3520: 'I' : parameter pack must be expanded in this context
};

Writing benchmarks with nonius

Writing benchmarks is not easy. Nonius simplifies certain aspects but you'll always need to take care about various aspects. Understanding a few things about the way nonius runs your code will be very helpful when writing your benchmarks.

First off, let's go over some terminology that will be used throughout.

  • User code: user code is the code that the user provides to be measured.
  • Run: one run is one execution of the user code.
@rmartinho
rmartinho / game.md
Last active August 29, 2015 14:06
A game of Nomic run by denizens of the Lounge<C++>.

Lounge<Nomic>

Immutable Rules

101. All players must always abide by all the rules then in effect, in the form in which they are then in effect. The rules in the Initial Set are in effect whenever a game begins. The Initial Set consists of Rules 101-116 (immutable) and 201-213 (mutable).

102. Initially rules in the 100's are immutable and rules in the 200's are mutable. Rules subsequently enacted or transmuted (that is, changed from immutable to mutable or vice versa) may be immutable or mutable regardless of their numbers, and rules in the Initial Set may be transmuted regardless of their numbers.

103. A rule-change is any of the following:

@rmartinho
rmartinho / gist:15e4f2e48f2a746ee256
Last active August 29, 2015 14:07
Constexpr myths
// Myth #1: constexpr is the same as const
// (note: there is a difference between C++11 and C++14 here)
// (see: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3598.html)
namespace myth1 {
struct foo {
int i;
constexpr int& get() { return i; } // not a const function
}
int f() {

Keybase proof

I hereby claim:

  • I am rmartinho on github.
  • I am rmf (https://keybase.io/rmf) on keybase.
  • I have a public key whose fingerprint is 2901 0F82 D8E7 C64C 795E A932 6617 B752 0A19 4EA0

To claim this, I am signing this object:

Randall Munroe's Radiation Dose Chart

(presented in units of time of exposure to background radiation)

Description Dose
Sleeping next to someone 7m
Living within 50 miles of a nuclear power plant for a year 13m
Eating one banana 15m
Living within 50 miles of a coal power plant for a year 45m
@rmartinho
rmartinho / rad.md
Last active April 9, 2019 00:37
Randall Munroe's Radiation Dose Chart

(presented in units of time of exposure to background radiation)

You can find the original chart here. I added some other values; additional sources can be found at the bottom.

Description Dose
Sleeping next to someone 7m
Living within 50 miles of a nuclear power plant for a year 13m
Eating one banana 15m
Living within 50 miles of a coal power plant for a year 45m

Keybase proof

I hereby claim:

  • I am rmartinho on github.
  • I am rmf (https://keybase.io/rmf) on keybase.
  • I have a public key ASCYKofoBc-K2YaOXeUUED7xdcVf2C3dpJmsdZbT-cMaCAo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am rmartinho on github.
  • I am rmf (https://keybase.io/rmf) on keybase.
  • I have a public key ASBIyYm_eGuZT1d7ge401nPRHeGKB2pX7SAcVcyqcm4y2go

To claim this, I am signing this object:

@rmartinho
rmartinho / pbmx-doc.md
Last active October 31, 2019 16:44
PBMX docs draft

PBMX

PBMX is a framework to creating secure and fair games that can be played over mail.

The main concern is supporting games that feature information that is secret, unknown, or unavailable without the need for a trusted third party. Secret information is information known to only a subset of the players; this could be e.g. in a game of poker, the contents of a player's hand. Unknown information is information that no player knows; in a game of poker, the contents of the deck