This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<class T> | |
auto serialize_imp(std::ostream& os, T const& obj, int) | |
-> decltype(os << obj, void()) | |
{ | |
os << obj; | |
} | |
template<class T> | |
auto serialize_imp(std::ostream& os, T const& obj, long) | |
-> decltype(obj.stream(os), void()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://vittorioromeo.info/index/blog/capturing_perfectly_forwarded_objects_in_lambdas.html | |
#include <iostream> | |
#include <functional> | |
#define FWD(...) std::forward<decltype(__VA_ARGS__)>(__VA_ARGS__) | |
namespace impl | |
{ | |
template <typename... Ts> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstddef> | |
template<typename T1, typename T2> | |
struct StaticPair { | |
T1 first; | |
T2 second; | |
friend constexpr bool operator<(const StaticPair& lhs, const StaticPair& rhs) noexcept { | |
return lhs.first < rhs.first; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tomMath vs GMP vs BSD http://tcl.2662.n7.nabble.com/tommath-is-slow-td64598.html | |
arp vs openssl vs libtommath https://gitlab.haskell.org/ghc/ghc/wikis/replacing-gmp-notes/performance-measurements | |
why arprec https://mail.haskell.org/pipermail/glasgow-haskell-users/2006-September/010963.html | |
http://www.wilfred.me.uk/blog/2014/10/20/the-fastest-bigint-in-the-west/ | |
https://github.com/gcc-mirror/gcc/tree/master/libdecnumber |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Runs clang-format on changed regions before commit. | |
# | |
# To install this, copy it to .git/hooks/pre-commit in your repo. | |
# Remaining installation checks/instructions will be printed when you commit. | |
# | |
read -d '' help <<- EOF | |
This repository requires you to install the git clang-format command. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef MINIPOOL_H | |
#define MINIPOOL_H | |
#include <cassert> | |
#include <cstddef> | |
#include <memory> | |
#include <new> | |
#include <utility> | |
/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::tie(a, b) = std::minmax({a, b}); | |
std::tie(a, b) = std::minmax(+a, +b); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (static bool do_once = true; std::exchange(do_once, false)) { | |
} | |
if (static bool do_once; !std::exchange(do_once, false)) { | |
} | |
struct Once { | |
bool b = true; | |
explicit operator bool() { return std::exchange(b, false); } | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <immintrin.h> | |
// https://stackoverflow.com/a/8456388 | |
// https://docs.microsoft.com/en-us/cpp/intrinsics/div128?view=vs-2019 | |
#pragma code_seg(".text") | |
const unsigned char sdiv128Data[] = | |
{ | |
0x48, 0x89, 0xD0, // mov rax,rdx | |
0x48, 0x89, 0xCA, // mov rdx,rcx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename T> | |
class Badge { | |
friend T; | |
Badge() {} | |
}; | |
class Device; | |
class VFS { | |
public: |