Skip to content

Instantly share code, notes, and snippets.

@jdiego
jdiego / source_location.cpp
Created October 17, 2019 11:35
How to use source_location in a variadic template function?
#include <iostream>
#include <utility>
#include <experimental/source_location>
/*
The C++20 feature std::source_location is used to capture information about the context in which a function is called.
*/
template <typename... Ts>
struct debug
{
@looopTools
looopTools / Read File to std::vector<uint8_t> in C++
Created February 1, 2019 13:33
How to read a file from disk to std::vector<uint8_t> in C++
inline std::vector<uint8_t> read_vector_from_disk(std::string file_path)
{
std::ifstream instream(file_path, std::ios::in | std::ios::binary);
std::vector<uint8_t> data((std::istreambuf_iterator<char>(instream)), std::istreambuf_iterator<char>());
return data;
}
@mbinna
mbinna / effective_modern_cmake.md
Last active April 21, 2025 14:17
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft