Skip to content

Instantly share code, notes, and snippets.

View rmartinho's full-sized avatar

R. Martinho Fernandes rmartinho

View GitHub Profile
BOOST_DEFINE_MATH_CONSTANT(half, 5.000000000000000000000000000000000000e-01, "5.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e-01")
#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:

@rmartinho
rmartinho / text-design.md
Last active October 7, 2015 12:38
Design ideas for ogonek::text

Motivation

ogonek::text is intended as a Unicode-based string class. Not as a glorified container of characters, like std::basic_string, but as an actual piece of Unicode text.

Storage

text is not about storage, so it delegates that to another container. That container can be customized, yielding a varied range of performance characteristics suitable to any situations. One could have a Unicode text array, similar to std::basic_string, or one could have a Unicode text deque, or even a rope.

Encoding

@rmartinho
rmartinho / deprecated.md
Last active October 7, 2015 13:17
[[deprecated]] attribute proposal

Introduction

This documents describes a proposal for providing authors of C++ libraries with a standard facility to mark code entities as deprecated.

Motivation and Scope

Libraries change with time. Sometimes features are replaced by more powerful ones, or are found to be inherently flawed. A common way for library writers to deal with this problem is to recommend against such old features, i.e., to mark them as deprecated.

Right now there is no standard means of doing that. Library writers are thus forced to either simply document them as deprecated, or to use the preprocessor to decide upon one of the various compiler extensions that exist to support this feature.

@rmartinho
rmartinho / frontier-magic.md
Last active October 7, 2015 13:38
Beyond the Frontier Magic

The [Frontier Magic rules][wizards rules] created by Wizards are a good start but not as fun as we had expected. So we made up new rules based off of the same idea. These are those modified rules.

Terrain

TODO: more complete description of the terrain

Home row

The home row is a row between a player and the land cards.

@rmartinho
rmartinho / gist:3174021
Created July 25, 2012 02:33
Example of gist.io bug with quotes and lists
> - This is a list item, in a quote!
> - This is another list item, in a quote!