Skip to content

Instantly share code, notes, and snippets.

View newlawrence's full-sized avatar

Alberto Lorenzo Márquez newlawrence

View GitHub Profile
@newlawrence
newlawrence / enums.cpp
Last active April 15, 2022 09:14
Enhanced enums
#define COUNT_( \
X64, X63, X62, X61, X60, X59, X58, X57, X56, X55, X54, \
X53, X52, X51, X50, X49, X48, X47, X46, X45, X44, X43, \
X42, X41, X40, X39, X38, X37, X36, X35, X34, X33, X32, \
X31, X30, X29, X28, X27, X26, X25, X24, X23, X22, X21, \
X20, X19, X18, X17, X16, X15, X14, X13, X12, X11, X10, \
X9, X8, X7, X6, X5, X4, X3, X2, X1, N, ... \
) N
#define COUNT(...) COUNT_( __VA_ARGS__, \
64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, \
@newlawrence
newlawrence / isa.cpp
Last active May 23, 2020 17:52
Compile Time International Standard Atmosphere
#include <array>
#include <limits>
#include <type_traits>
#include <cmath>
namespace isa {
template<typename Params, int Offset=0>
class ISA : public Params {
@newlawrence
newlawrence / ctstr.cpp
Created April 15, 2022 10:02
Portable C++17 compile time string implementation
#include <ostream>
#include <string>
#include <string_view>
#include <cstdint>
#define CTSTR_DEFINE_LITERAL_OPERATOR(NAMESPACE, CHARSET) \
namespace NAMESPACE { \
using ctstr_t = basic_ctstr_t<charset::CHARSET>; \
namespace literals { \