Skip to content

Instantly share code, notes, and snippets.

Avatar

Mathias Stearn RedBeard0531

View GitHub Profile
@RedBeard0531
RedBeard0531 / cpp17.md
Last active Apr 23, 2019
New C++17 features
View cpp17.md

Supplement to this video. Watch first 35 min (the language bits), then 1:14:30 - 1:18:15 (the new map features).

You can find a fairly comprehensive list of new features on cppreference or here if you really want to see it all.

Recap of features described in the video

View another_take_on_bulk.cpp
#include <cstdlib>
#include <boost/optional.hpp>
#include <string>
using boost::optional;
template <typename T>
struct Future{};
template <typename T>
View fallibility.cpp
template <typename T>
struct ValueReceiver {
virtual void value(T) = 0;
};
template <typename T>
struct ValueOrErrorReceiver : ValueReceiver<T> {
virtual void value(T) = 0;
virtual void error(std::exception_ptr) = 0;
};
View lazy_futures.h
#include <functional>
#include <exception>
#include <optional>
#include <memory>
#include <cassert>
#include <atomic>
#include <iostream>
#include <mutex>
#include <condition_variable>
#include <thread>
@RedBeard0531
RedBeard0531 / include_magic.md
Last active Jun 13, 2018
Proposal for making third-party libs easier to use
View include_magic.md

Magic #includes (and eventually imports)

By: Mathias Stearn
Please provide feedback either by email, or on #sg15-tooling in cpplang.slack.com.

This is an alternative to a proposal that I'm sure was offered with good intentions, but that I and several others shuddered at the sight of:

@RedBeard0531
RedBeard0531 / future_traits.cpp
Last active Apr 26, 2018
Future then() traits
View future_traits.cpp
#include <tuple>
#include <optional>
#include <functional>
/////////////////////
/// PRIMARY TEMPLATES
template <typename T>
struct future_then_return_traits {
// Future::then(cb) for a callback that returns T,
@RedBeard0531
RedBeard0531 / example_1.cpp
Created Apr 14, 2018
Examples of broken release sequences
View example_1.cpp
enum State {INIT, PHASE2, DONE};
std::atomic<State> state{INIT};
int non_atomic = 0; // placeholder for actual data.
auto phase1 = std::thread([&] {
non_atomic = 1;
state.store(PHASE2, std::memory_order_release);
auto phase2 = std::thread([&] {
View P0911R0.md
Document Number: P0911R0
Date: 2018-02-03
Project: Programming Language C++, CWG, LWG
Revises: none
Reply to: gorn@microsoft.com

Rebase the Coroutines TS onto the C++17 Standard

View p0959r0.md
Doc. No.: P0959R0
Date: 2018-02-12
Reply to: Marius Bancila
Audience: Library WG
Title: A Proposal for a Universally Unique Identifier Library

A Proposal for a Universally Unique Identifier Library

@RedBeard0531
RedBeard0531 / nimsuggest.vim
Created Jan 10, 2018
Terrible implementation of nimsuggest integration with zah/nim.vim
View nimsuggest.vim
" :source this file in your "main" nim file to activate.
" You can run :source again to switch main file or when nimsuggest crashes.
" You can also :call nimsuggest#run('use') to see all uses of the thing your
" cursor is on.
"call system("killall nimsuggest")
let nimsuggest_job = job_start(["nimsuggest", "--stdin", "--v2", "--debug", "--log", expand("%")], {
\ "in_mode" : "nl",
\ "out_mode" : "nl",
\ "err_io": "out",