Skip to content

Instantly share code, notes, and snippets.

View notfoundry's full-sized avatar

Mark Johnson notfoundry

  • Canada
View GitHub Profile
Verifying that +foundry is my openname (Bitcoin username). https://onename.com/foundry
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="versiontype">
<xs:restriction base="xs:string"/>
</xs:simpleType>
<xs:complexType name="targettype">
<xs:sequence>
<xs:element name="id" type="xs:string"/>
@notfoundry
notfoundry / with_defaults.hpp
Created May 26, 2018 15:35
Keep some default template parameters of a type while replacing others
#include <boost/mp11/list.hpp>
#include <boost/mp11/utility.hpp>
#include <boost/mp11/algorithm.hpp>
#include <type_traits>
#include <cstddef>
struct _ {};
namespace detail {
@notfoundry
notfoundry / strongdim.hpp
Last active June 16, 2018 17:17
Strongly-dimensioned quantity types for C++11
#include <cstddef>
#include <type_traits>
#include <boost/mp11/list.hpp>
#include <boost/mp11/bind.hpp>
#include <boost/mp11/utility.hpp>
#include <boost/mp11/function.hpp>
#include <boost/mp11/integral.hpp>
#include <boost/mp11/algorithm.hpp>
#include <boost/mp11/map.hpp>
@notfoundry
notfoundry / jni_classpath.cpp
Created July 24, 2018 16:51
JNI-querying IClassPath implementation for the JNIF C++ library
#include <exception>
#include <string>
#include <memory>
#include <jni.h>
#include <jnif/jnif.hpp>
class jni_class_loader {
public:
@notfoundry
notfoundry / static_typeid.hpp
Last active November 24, 2018 19:05
static_typeid
#include <cstddef>
namespace nonstd {
namespace detail {
template <class Tag, class Type = int, Type Start = 0, Type Step = 1>
class meta_counter {
template <Type N>
struct flag {
friend constexpr bool adl_flag (flag<N>);
};
#include <utility>
template <std::size_t Index, class T>
struct indexed_pack_element {
constexpr static T element(std::integral_constant<std::size_t, Index>);
};
template <class IndexSeq, class... Ts>
struct pack_indices_impl;
@notfoundry
notfoundry / cpp_raw_string_align_udl.cpp
Created June 24, 2019 01:33
Align raw string literals to a common baseline at compiletime
#include <cstdlib>
#include <array>
#include <boost/mp11/list.hpp>
#include <boost/mp11/algorithm.hpp>
using namespace boost::mp11;
template <class C, C... Cs>
struct nttp_string {};
@notfoundry
notfoundry / ct_string.hpp
Created July 20, 2019 02:16
cpp_constexpr_string_interpolation
#include <boost/mp11/map.hpp>
#include <boost/mp11/list.hpp>
namespace ct {
using namespace boost::mp11;
template <class C, C... Cs>
struct nttp_string {
constexpr static C data[sizeof...(Cs)] = {Cs...};
@notfoundry
notfoundry / meta-lambdas.hpp
Last active February 19, 2020 16:36
Type-level lambda expressions for template metaprogramming in C++20
#include <boost/preprocessor/punctuation/is_begin_parens.hpp>
#include <boost/preprocessor/punctuation/remove_parens.hpp>
#include <boost/preprocessor/control/if.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#include <boost/preprocessor/seq/variadic_seq_to_seq.hpp>
namespace metalambda {
template <auto T>