Skip to content

Instantly share code, notes, and snippets.

View ldalessa's full-sized avatar

Luke D'Alessandro ldalessa

View GitHub Profile
@ldalessa
ldalessa / p1895_tag_invoke.hpp
Created May 8, 2023 22:33
Just the tag invoke part of p1895 copied from https://godbolt.org/z/3TvO4f
#include <type_traits>
/// see https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1895r0.pdf
/// downloaded from https://godbolt.org/z/3TvO4f
namespace std
{
namespace __tag_invoke_fn_ns
{
void tag_invoke() = delete;
@ldalessa
ldalessa / soa_iterator.hpp
Created April 30, 2023 02:16
A simple random access iterator helper for soa structures that have an `operator[]`.
#include <concepts>
#include <cstddef>
#include <iterator>
template <class T, class It>
struct soa_iterator
{
using iterator_category = std::random_access_iterator_tag;
using value_type = typename T::value_type;
////////////////////////////////////////////////////////////////
// Reference implementation of std::generator proposal P2502R2
//
#include <algorithm>
#include <cassert>
#include <coroutine>
#include <cstdint>
#include <cstring>
#include <exception>
@ldalessa
ldalessa / emacs-pkg-install.sh
Last active February 24, 2023 20:24 — forked from padawanphysicist/emacs-pkg-install.sh
Install emacs packages from the command-line
#!/bin/bash
#
# I wrapped the code constructed in
#
# http://hacks-galore.org/aleix/blog/archives/2013/01/08/install-emacs-packages-from-command-line
#
# in a single bash script, so I would a single code snippet.
#
# Packages to be installed
@ldalessa
ldalessa / it.hpp
Created January 20, 2022 23:03
nested lambda iterations
ops::for_each_essential_point(distribution, geometry, ε, fields(data), [&](level_t r, Lambda μ, Index const& l, offset_t i, Bitset active) {
geometry.mark(r, μ, i);
geometry.union_active(r, μ, i, active);
ops::for_each_trial_point(domain, geometry, r, μ, l, [&](level_t j0, Lambda λ0, Index const& k0, std::optional<offset_t> i0) {
mrwt_expect(bool(i0));
geometry.mark(j0, λ0, *i0);
geometry.union_active(j0, λ0, *i0, active);
ops::for_each_derivative_stencil_point(domain, dop, geometry, j0, λ0, k0, [&](level_t j1, Lambda λ1, Index const&, std::optional<offset_t> i1) {
mrwt_expect(bool(i1));
geometry.mark(j1, λ1, *i1);
@ldalessa
ldalessa / tag_invoke.hpp
Created May 6, 2021 23:45 — forked from ericniebler/tag_invoke.hpp
Simple implementation of the tag_invoke customization point
#include <utility>
#include <type_traits>
namespace _tag_invoke {
void tag_invoke();
struct _fn {
template <typename CPO, typename... Args>
constexpr auto operator()(CPO cpo, Args&&... args) const
noexcept(noexcept(tag_invoke((CPO &&) cpo, (Args &&) args...)))