Skip to content

Instantly share code, notes, and snippets.

@bkietz
bkietz / operators.hpp
Created September 15, 2016 21:19
Operator overload playground
#include <iostream>
#include <type_traits>
template <typename T>
struct is_expression : std::false_type {};
template <typename T, typename R = T>
using expression_enable = typename std::enable_if<
is_expression<T>::value, R
>::type;

Keybase proof

I hereby claim:

  • I am bkietz on github.
  • I am bkietz (https://keybase.io/bkietz) on keybase.
  • I have a public key ASCAhdOocQjz-VyMlfqTniJGcorPWw23rtj7frsYdmWqqQo

To claim this, I am signing this object:

@bkietz
bkietz / Main.cpp
Last active July 3, 2022 18:52
exposing FSINCOS to Visual C++ using assembly
#include "SinCos.h"
#include <cmath>
#include <cassert>
#include <limits>
int main()
{
constexpr double pi = 3.14159265358979323846;
constexpr double err = std::numeric_limits<double>::epsilon();
@bkietz
bkietz / pattern_matching_lite.adoc
Last active December 18, 2023 16:10
A sketch of a simple pattern matching syntax for c++

Pattern Matching

@bkietz
bkietz / usage.sh
Created February 8, 2019 22:11
basic git rebase conflicts
source utilities.sh
init
make_rebase_conflict
# observe conflict, panic a little
fix_rebase_conflict
cd lo
# push gets rejected, feel despair
@bkietz
bkietz / out_ptr.h
Last active April 5, 2019 19:26
dead simple output pointer
#pragma once
#include <memory>
#include <type_traits>
#include <utility>
/// \brief out_ptr provides a low boilerplate output argument for
/// shared_ptr and unique_ptr values
template <typename T>
class out_ptr {
@bkietz
bkietz / LICENSE.txt
Last active December 7, 2019 16:28
Lazily initialized data member: c++11, thread safe, const correct.
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
@bkietz
bkietz / kms_design.md
Last active November 15, 2020 20:56
A proposal for a KMS interaction API in parquet-cpp
/// Distributed under the Boost Software License, Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt)
#include <tuple>
#include <cassert>
#include "reflection.h"
struct Person {
std::string name;
int age;
@bkietz
bkietz / float_ord_usage.cc
Last active August 16, 2021 15:06
A simple function for configuring and disambiguating the ordering of floating point numbers
#include <cassert>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <limits>
#include <optional>
#include <vector>
enum NanOrdering {