Find references to non-const pointees:
clang-query -c "set output dump" -c "m varDecl(hasType(referenceType(pointee(unless(isConstQualified())))))" source.cpp
| #!/usr/bin/env python | |
| import ctypes | |
| from ctypes import cdll | |
| cur_x = 10 | |
| libpath = "./some_lib.so" | |
| lib = cdll.LoadLibrary(libpath) | |
| print(f"loaded {lib}") | |
| # https://stackoverflow.com/a/62021495/1420489 | 
| #include <iostream> | |
| struct FuncPtr; | |
| typedef FuncPtr(Func)(int); | |
| struct FuncPtr { | |
| void *func; | |
| FuncPtr(Func& f) : func{(void *) &f} {}; | |
| FuncPtr operator()(int x) { return ((Func *)func)(x); } | |
| }; | 
| # 1 "<built-in>" | |
| # 1 "specialise_variadic_templates.cpp" | |
| #if defined(__CLANG_REWRITTEN_INCLUDES) || defined(__CLANG_REWRITTEN_SYSTEM_INCLUDES) /* iostream expanded by -frewrite-includes */ | |
| #include <iostream> | |
| #else /* iostream expanded by -frewrite-includes */ | |
| # 1 "specialise_variadic_templates.cpp" | |
| # 1 "/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/iostream" 1 3 | |
| // Standard iostream objects -*- C++ -*- | |
| #include <iostream> | |
| #include <source_location> | |
| #include <string> | |
| struct Quack; | |
| template <typename T> | |
| concept Duck = requires(T t) { | |
| { t.quack() } -> std::convertible_to<Quack>; | |
| // could be -> std::same_as<Quack>; | |
| }; | 
Find references to non-const pointees:
clang-query -c "set output dump" -c "m varDecl(hasType(referenceType(pointee(unless(isConstQualified())))))" source.cpp
| /* | |
| * Just some notes while reading Game Programming Patterns by Robert Nystrom | |
| * https://gameprogrammingpatterns.com | |
| * | |
| * A command or event made with C++ std::variant. | |
| * The idea is to pack some similar-size but different types into the command. | |
| * How to subscribe components to events from each other | |
| * and construct it declaratively, at compile time? | |
| * The components send events or commands (command pattern). | |
| * You want to verify the interfaces, preferably statically, i.e. at link time. | 
| #[ | |
| # the example is from https://peterme.net/metaprogramming-and-read-and-maintainability-in-nim.html | |
| # plus I used `quote` instead of direct tree nodes | |
| # it almost works the same way | |
| # except, it seems you cannot declare an empty `enum` under `quote` | |
| ]# | |
| import math, strutils | |
| import macros | 
I hereby claim:
To claim this, I am signing this object:
| #define DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL | |
| #include "doctest.h" | |
| //int factorial(int number) { return number <= 1 ? number : factorial(number - 1) * number; } | |
| int factorial(int number) { return number <= 1 ? 1 : factorial(number - 1) * number; } | |
| TEST_CASE("testing the factorial function") { | |
| CHECK(factorial(0) == 1); | |
| CHECK(factorial(1) == 1); | |
| CHECK(factorial(2) == 2); | 
| What exactly is "iowait"? | |
| To summarize it in one sentence, 'iowait' is the percentage | |
| of time the CPU is idle AND there is at least one I/O | |
| in progress. | |
| Each CPU can be in one of four states: user, sys, idle, iowait. | |
| Performance tools such as vmstat, iostat, sar, etc. print | |
| out these four states as a percentage. The sar tool can | |
| print out the states on a per CPU basis (-P flag) but most |