C++ std -- range
Range libcxx implementation. Let’s walk through a simple example. #include <iostream> #include <ranges> using namespace std; int main() { vector<int> a = {1, 2, 3, 4}; int ...
Range libcxx implementation. Let’s walk through a simple example. #include <iostream> #include <ranges> using namespace std; int main() { vector<int> a = {1, 2, 3, 4}; int ...
Parser See code. One interesting thing is that is uses Pratt parser to parse constraint expression. Beginners to C++ concepts may be confused by the new keyword requires. For example, template&l...
Why do we have header files? p0132r0 is a great manuscript about the history and problems with using header files. To sum up, C/C++ files has a notion called independent compilation, which means e...
Structured Binding Structured binding dcl.struct.bind is easy to use but has many pitfalls if you zoom in on the details. The first question is what types do the binding variables have. Let’s take...
client-go is the Go client for Kubernetes. Authentication I use EKS at work. Below is the section of my ./kube/config file, - name: arn:aws:eks:us-east-2:597088060484:cluster/staging user: ...
weakref.ref and weakref.ReferenceType are the same thing. See code. The __call__ is implemented here.
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...