Skip to content

Instantly share code, notes, and snippets.

@gatchamix
gatchamix / static_polymorphism.cpp
Created October 12, 2018 10:32
simulating features of dynamic polymorphism and class inheritance at compile-time
#include <type_traits>
//
template <class...>
struct type_pack
{};
//
@gatchamix
gatchamix / static_polymorphism_advanced.cpp
Created October 12, 2018 10:56
additional compile-time replacements for polymorphism (more intrusive for end-user)
#include <type_traits>
//
template <class...>
struct type_pack
{};
//
@gatchamix
gatchamix / defer member func.cpp
Last active January 22, 2019 08:57
simplifies the creation of non-const member functions that defer to their const member function counterparts
#include <type_traits>
//
template <class T>
struct remove_qualifiers
: std::remove_cv<T>
{};
template <class T>
#include <variant>
#include <type_traits>
#include <iostream>
#include <concepts>
#include <print>
//
#define FWD(...) static_cast<decltype(__VA_ARGS__)&&>(__VA_ARGS__)