Skip to content

Instantly share code, notes, and snippets.

View johnmcfarlane's full-sized avatar

John McFarlane johnmcfarlane

View GitHub Profile
@johnmcfarlane
johnmcfarlane / functional.h
Created July 14, 2017 20:35
Fixing `std::functional`.
#include <functional>
#include <memory>
#include <stdlib.h>
#if defined(USE_ALTERNATIVE)
template<class FunctionSignature>
class function;
template<class Result, class...Args>
@johnmcfarlane
johnmcfarlane / cnl_complete_11.h
Last active March 29, 2018 16:52
single-header versions of the CNL library
// Copyright John McFarlane 2017.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file ../LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// mechanically retrieved, single-header version of CNL library
// https://github.com/johnmcfarlane/cnl
#if ! defined(CNL_COMPLETE_H)
@johnmcfarlane
johnmcfarlane / 20170726_accu_bay_area_signed_ub.html
Last active August 9, 2017 18:58
Signed UB Lightning Talk
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
<meta charset="utf-8">
<style>
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
@johnmcfarlane
johnmcfarlane / mandelbrot.h
Created August 1, 2017 14:15
Minimal Mandelbrot generator using CNL
#include <cnl/fixed_point.h>
#include <array>
using namespace cnl;
using namespace std;
constexpr int mandelbrot(float f_x, float f_y, int const limit) {
using scalar = fixed_point<int64_t, -28>;
auto c_x = scalar{f_x};
auto c_y = scalar{f_y};
@johnmcfarlane
johnmcfarlane / debug.txt
Created August 27, 2017 17:57
One of many uncrustify failures found using unformat project.
# Uncrustify-0.65-153-37c30cf5
newlines = lf
output_tab_size = 17
string_replace_tab_chars = true
sp_assign = remove
sp_compare = force
sp_paren_paren = force
sp_after_ptr_star = force
sp_ptr_star_paren = remove
sp_before_byref_func = add
@johnmcfarlane
johnmcfarlane / constant.md
Last active October 13, 2017 20:03
Draft proposal for addition of `std::constant`

Document number: DXXXXR0
Date: 2017-09-19
Reply-to: John McFarlane, cnl@john.mcfarlane.name
Reply-to: Louis Dionne, ldionne.2@gmail.com
Audience: SG6, SG14, LEWG

General-Purpose Constant Value Type

Introduction

@johnmcfarlane
johnmcfarlane / cnl_complete_int128.h
Last active February 9, 2018 06:05
A single-header C++17 version of CNL library with 128-bit integer support. (Only works on some platforms.)
// Copyright John McFarlane 2017.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file ../LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// mechanically retrieved, single-header version of CNL library
// https://github.com/johnmcfarlane/cnl
#if ! defined(CNL_COMPLETE_H)

(Line 1) Line with double space
(Line 2) Line with backslash
(Line 3) Line without either (Line 4) and continuation of previous line

@johnmcfarlane
johnmcfarlane / Commonmark_Edits.md
Created February 20, 2018 23:50
very brief demo of document edit marks (suitable for WG21 papers) in a commonmark document
<style type="text/css"> del {color:red;} ins {color:green;} </style>

Commonmark Edits

Commonmark has noHTML block-provided support for edits.

@johnmcfarlane
johnmcfarlane / date.h
Created April 6, 2018 05:05
Taken from Howard Hinnant's Wandbox link
#ifndef DATE_H
#define DATE_H
// The MIT License (MIT)
//
// Copyright (c) 2015, 2016, 2017 Howard Hinnant
// Copyright (c) 2016 Adrian Colomitchi
// Copyright (c) 2017 Florian Dang
// Copyright (c) 2017 Paul Thompson
//