Skip to content

Instantly share code, notes, and snippets.

@bkietz
bkietz / find_first.hxx
Last active September 21, 2023 21:04
C++17 string search with SSE4.2's `_mm_cmpistrm`
#if defined(__SSE4_2__)
#if defined(__has_builtin)
#if __has_builtin(__builtin_ctz)
#include <immintrin.h>
#include <cstring>
#define ARROW_TOO_SIMD_FIND_FIRST_OF
#endif
@bkietz
bkietz / LICENSE.txt
Created July 7, 2023 00:45
Minimal std::ostream which outputs to a fixed span of `char`
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 / LICENSE.txt
Created June 23, 2023 13:08
Minimal C++17 utility for writing `concept`-like checks
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 / CMakeLists.txt
Created August 8, 2022 21:20
backward trace from all threads
# https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.18)
project(backward_trace_all_threads)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(Threads)
enable_testing()
add_executable(main main.cc)
target_link_libraries(main Threads::Threads dw)
@bkietz
bkietz / LICENSE.txt
Last active May 8, 2023 13:08
Tiny C++17 zip ranges utility
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 / 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 {
/// 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 / kms_design.md
Last active November 15, 2020 20:56
A proposal for a KMS interaction API in parquet-cpp
@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 / 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 {