Skip to content

Instantly share code, notes, and snippets.

View shardator's full-sized avatar

Gergely Nagy shardator

View GitHub Profile

Print type:

#include <cxxabi.h>
...
auto print_type = []<typename TT>(TT&&) { 
        int s; return abi::__cxa_demangle(typeid(TT).name(),0,0,&s); };

In variant:

@shardator
shardator / mpl_gcd.h
Created March 16, 2022 16:31
C++ Metaprogrammed GCD
namespace detail {
template<size_t M, size_t N>
struct gcd_impl {
static constexpr size_t R = (N == 0) ? 0 : (M % N);
static constexpr size_t value = (R == 0) ? N : gcd_impl<N,R>::value;
};
template<size_t M> struct gcd_impl<M,0> { static constexpr size_t value = M; };
template<size_t N> struct gcd_impl<0,N> { static constexpr size_t value = 0; };
@shardator
shardator / .vimrc
Last active August 17, 2022 10:50
My favourite .vimrc (a mess)
set history=10000
set smartcase
set ignorecase
set expandtab
set shiftwidth=3
set softtabstop=3
set smartindent
let hlstate=1
set hlsearch
@shardator
shardator / .gitconfig
Created June 26, 2019 10:19
My favourite gitconfig
[user]
name = "Gergely Nagy"
email = XXX@YYY.ZZ
[alias]
b = branch
co = checkout
ci = commit
cp = cherry-pick
l = log --oneline --graph --decorate -15
s = status