TODO: Need to figure this out.
Collection of writings about stuff related to math, coding, and engineering.
It wasn't vey clear to me whether fold
expressions (introduced in
C++17) shortcut, e.g., when the fold's binary operator is logical and &&
or logical or ||. They should be due to the fact that the operators &&
and || shortcut themselves, and, here is an example to demonstrate that yes,
fold expressions shortcut (also Compiler Explorer
link):
#include <iostream>
bool g(int x) {
std::cout << "g(" << x << ") is evaluated" << std::endl;
return x % 2 == 0;
}
template <typename... Vs> bool all_even(Vs... vs) {
return (... && g(vs));
}
int main() { return all_even(4, 7, 2, 0); }Also note: because of the sequence point requirement for the first (left)
operand of either && or || the order of evaluation of the expressions is
always the same, left to right:
// left-fold requires that (E1 op E2) is evaluated first so the order is E1, E2,
// E3
(E1 op E2) op E3
// right fold requires that E1 is evaluated first so the order is E1, E2, E3
E1 op (E2 op E3)Nothing yet.
How I setup my MacBook Pro M1 (13-inch, 2020), Apple Silicon, to work they way I wanted it.
-
Install Xcode from the App Store;
- also install the command line tools.
-
Install QLMarkdown to be able to use the Apple Quick Look feature to preview files, specifically
*.mdand*.markdownfiles as rendered markdown and not the source. Works really well so far! -
Install MacPorts by downloading the package installer directly from http://www.macports.org/install.php, make sure to get the Big Sur version v2.7.1.
-
Use MacPorts to install emacs, I mostly use it command line mode. It is installed in
/opt/local/bin/emacs.-
Enable packages in emacs (see MELPA), make sure to enable normal and stable versions; if only stable is enabled you will not see many packages
-
Install markdown mode.
-
Install a few color themes.
-
Install the
clang-formatpackage so I can format C and C++ files. It didn't work right out of the box because it could not find theclang-formatbinary so I had to figure out how to get this. Downloaded clang v12.0, then copied justclang-formatto the MacPorts bin directory usingsudo cp ~/Downloads/clang+llvm-12.0.0-x86_64-apple-darwin/bin/clang-format /opt/local/binAs expected, needed to approve running it in the
Security & Privacypreferences. TODO: this is still not fully functional, the formatting works on the command line but not in emacs, apparently some sort of config file needs to be generated. Will try and follow these instructions. -
Set up Authy (app from Twillio) for 2FA for Github. A bit of a mess, but mostly worked. Need to figure out how to cache the token in the keychain so I don't have to enter it every time I
git push.
-
-
Install the GitHub gh CLI. This is not necessary if you want to use git
brew install ghto installgh auth loginafter installation; might have to update the~/.ssh/known_hoststo the GitHub's SSH key fingerprints and generate the required classic authentication token if you don't have one already (see the complete instructions on Testing your SSH connection).