Skip to content

Instantly share code, notes, and snippets.

View ldionne's full-sized avatar

Louis Dionne ldionne

View GitHub Profile
@ldionne
ldionne / static_map.cpp
Last active August 8, 2023 10:17
Toy implementation of a static constexpr map
#include <algorithm>
#include <array>
#include <cassert>
#include <experimental/string_view>
#include <functional>
#include <initializer_list>
#include <iterator>
#include <utility>
#!/usr/bin/env bash
cat <<EOF | clang++ -xc++ - -c -o string.o
template <class T>
struct basic_string {
__attribute__((internal_linkage))
void shrink_to_fit();
};
template <class T>
#!/usr/bin/env bash
clang++ -std=c++14 -stdlib=libc++ -c string16.ii
clang++ -std=c++14 -stdlib=libc++ -c utf_string_conversions.ii
clang++ -std=c++14 -stdlib=libc++ string16.o utf_string_conversions.o
@ldionne
ldionne / bind_back.diff
Created July 30, 2021 16:24
Diff to get Zoe's suggestion for bind_back
diff --git a/libcxx/include/__functional/bind_back.h b/libcxx/include/__functional/bind_back.h
index fd4d0ea75ade..110cab61f8d6 100644
--- a/libcxx/include/__functional/bind_back.h
+++ b/libcxx/include/__functional/bind_back.h
@@ -26,36 +26,22 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 17
-// Passes the provided arguments to std::invoke in the order specified by the given index_sequence.
-template <size_t ..._Ip, class ..._Args, class _AsTuple = tuple<_Args&&...>>
@ldionne
ldionne / README.md
Last active September 1, 2020 18:59
From-scratch Lit configuration for Wakely

Put the libstdcxx.cfg.in file in libcxx/test/configs/libstdcxx.cfg.in. Then, configure the LLVM tree with -DLIBCXX_TEST_CONFIG=<path-to-libstdcxx.cfg.in>.

Then, you should be able to use ./build/bin/llvm-lit -sv <whatever>.

(view as text)
******************** TEST 'libc++ :: std/re/re.const/re.matchflag/match_prev_avail.pass.cpp' FAILED ********************
Script:
--
: 'COMPILED WITH'; /usr/local/bin/clang++ /b/b3/libcxx-libcxxabi-x86_64-linux-ubuntu-asan/llvm/libcxx/test/std/re/re.const/re.matchflag/match_prev_avail.pass.cpp -Werror -v -g -fno-omit-frame-pointer -fsanitize=address -Werror=thread-safety -std=c++2a -include /b/b3/libcxx-libcxxabi-x86_64-linux-ubuntu-asan/llvm/libcxx/test/support/nasty_macros.h -nostdinc++ -I/b/b3/libcxx-libcxxabi-x86_64-linux-ubuntu-asan/llvm/libcxx/include -I/b/b3/libcxx-libcxxabi-x86_64-linux-ubuntu-asan/build/projects/libcxx/include/c++build -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -I/b/b3/libcxx-libcxxabi-x86_64-linux-ubuntu-asan/llvm/libcxx/test/support -ftemplate-depth=270 -O1 -Wall -Wextra -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -Wuser-defined-warnings -Wshadow -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-u
@ldionne
ldionne / pre-push
Created November 9, 2018 19:26
Pre-push hook for LLVM monorepo
#!/bin/sh
# Pre-push hook making sure there is no merge commit in the set of commits
# being pushed upstream. This hooks works by walking the set of commits being
# pushed and making sure that none of them has two parents or more (which is
# the definition of a merge commit).
#
# This hook is called with the following parameters:
#
# ${1} -- Name of the remote to which the push is being done
@ldionne
ldionne / codegen.cpp
Created May 23, 2018 01:52
example of bad codegen with Hana
#include <cstddef>
#include <type_traits>
#include <utility>
//////////////////////////////////////////////////////////////////////////////
// Utilities required to make the bug report self-contained.
//
// Basically, this defines a very minimal tuple<> structure along with a
// function (operator+) which allows appending an element to a tuple. We
@ldionne
ldionne / minimal-handwritten-config-header-only.cmake
Last active June 20, 2017 01:14
CMake Package Config for Boost
# Compute the installation prefix relative to this file. This file is expected
# to be located at ${PREFIX}/lib/cmake/Hana/HanaConfig.cmake, so this simply
# computes the installation's ${PREFIX}.
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
if(_IMPORT_PREFIX STREQUAL "/")
set(_IMPORT_PREFIX "")
endif()
@ldionne
ldionne / constexpr_control_flow.cpp
Created March 3, 2017 19:28
Scratchpad for compile-time control flow
void foo() {
for (auto x : tuple) {
if (runtime-bool) // ill formed
constexpr break;
}
}
void foo() {
for (auto x : tuple) {
if constexpr (compile-time-bool) // yes!