Skip to content

Instantly share code, notes, and snippets.

@mbencik
mbencik / static_inline_example.md
Created January 23, 2025 10:31 — forked from htfy96/static_inline_example.md
static inline vs inline vs static in C++

In this article we compared different behavior of static, inline and static inline free functions in compiled binary. All the following test was done under g++ 7.1.1 on Linux amd64, ELF64.

Test sources

header.hpp

#pragma once

inline int only_inline() { return 42; }
static int only_static() { return 42; }
@mbencik
mbencik / elf_format_cheatsheet.md
Created January 21, 2025 17:04 — forked from x0nu11byt3/elf_format_cheatsheet.md
ELF Format Cheatsheet

ELF Format Cheatsheet

Introduction

Executable and Linkable Format (ELF), is the default binary format on Linux-based systems.

ELF

Compilation

@mbencik
mbencik / tuple_hash.cxx
Created May 27, 2021 20:03 — forked from sarangxyz/tuple_hash.cxx
hashing tuples
// https://stackoverflow.com/a/6894436/916549
template<typename T>
inline void hash_combine(std::size_t& seed, const T& val)
{
std::hash<T> hasher;
seed ^= hasher(val) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}
template<class... TupleArgs>