【C++ 小问答】1:模板实例化

问 以下 foo 函数模板被实例化多少次? 1template <typename T> 2void foo(T f) {} 3 4struct Bar { 5 void operator()(bool x) {} 6}; 7 8void f1(bool x) {} 9 10void f2(bool x) {} 11 12int main() { 13 foo(f1); 14 foo(Bar()); 15 foo(f2); 16 foo([](bool x){}); 17 foo([](bool x){}); 18} 答 使用 C++ Insights 生成该代码的编译器视角: 1template …

一个简洁实用的进入 Chroot 环境的脚本

之前在某处看到了这么一份用于进入 Chroot 环境的 Bash 脚本,感觉不错就收藏了。先贴一下原始脚本: 1#!/bin/bash 2 3CHROOT_DIR=$(dirname $(readlink -f $0)) 4 5USAGE=" 6Usage: sh $0 [option] 7 8Warning: This script cannot be used in compile_env 9Options: 10 init init compile_env and mount the required directories 11 no option default to init 12 umount clean up …

Install & Explain SSL Certificates

This is a repost of this answer on Ask Ubuntu, which, primarily showing how to install SSL certificates on CLI, explains as well what happens behind the scene when a certificate verification error occurs1. This work is licensed under the Creative Common Attribute-SharedAlike 3.0 Unported License , as the original post …

Check What Libraries an ELF Depends On

Immediate Dependencies Only 1objdump -x a.out | grep NEEDED # or -p 2 3 NEEDED libstdc++.so.6 4 NEEDED libgcc_s.so.1 5 NEEDED libc.so.6 Alternative: 1readelf -d a.out | grep NEEDED 2 3 0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6] 4 0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1] 5 …

Vim: List All Matching Lines

1. vimgrep (Error List) 1:vimgrep pattern % To open the list of matches in a buffer: 1:copen On the list, navigate normally, and use <Enter> to select a match. 2. lvim (Location List) 1:lvim pattern % To open the list 1:lopen Navigation is similar with vimgrep. 3. Global Search1 1:g/regular-expression/p Note that …