C++ std -- queue
priority queue Constructor Priority queue has signature std::priority_queue<T,Container=vector,Compare=std::less> , so you can see that comparator class is provided as a template parameter....
priority queue Constructor Priority queue has signature std::priority_queue<T,Container=vector,Compare=std::less> , so you can see that comparator class is provided as a template parameter....
pop_front Below code has a bug auto& element = que.pop_front() According to the standard, reference to the popped element will be invalidated, so we should create a copy instead of referenc...
Various components inside header <functional>. std::less and std::greater These are two structs with trivial implementation of operator(). It relies on the value type to implement operator&...
One lesson I learnt from reading std::variant implementation is that union in C++ can have complicated structure. Before, I thought we should only use union in this way: union U { int a; c...
I got quite confused the first time I read vector implementation. After a few minutes’ struggle, I realized that there are two implementations: the general vector and the specialized vector<boo&...
std::unordered_set Both unordered_set and unordered_map use an internal __hash_table object, so it suffices to only talk about how hash table works in C++. The basic structure looks like diagram ...
I use SSH almost every work day, but never thought about how it works exactly until one day I got an error message Permission denied (publickey) when trying to git clone a repo. This post documents...
pg_repack What locks used https://github.com/reorg/pg_repack/blob/306b0d4f7f86e807498ac00baec89ecd33411398/bin/pg_repack.c#L1599 How to clean up things DROP EXTENSION IF EXISTS pg_repack CASCAD...
Semgrep is a cool project. Command line entry is here. A few comment commands # scan a doc to test patthen matching semgrep scan -l yaml -e '<pattern_to_test>' <file_name> # Sometime...
Aarch64 is just arm64. The instruction set used in aarch64 is called A64. Procedure Calls The standard says that the first few parameters should be loaded to X0-X7. If more than 8 arguments, then...