0%

https://stackoverflow.com/a/5563131/

if:
either is      long double       other is promoted >      long double
either is           double       other is promoted >           double
either is           float        other is promoted >           float
either is long long unsigned int other is promoted > long long unsigned int
either is long long          int other is promoted > long long          int
either is long      unsigned int other is promoted > long      unsigned int
either is long               int other is promoted > long               int
either is           unsigned int other is promoted >           unsigned int
either is                    int other is promoted >                    int

Otherwise:
both operands are promoted to int

在没有 --source 选项时,有 --staged 则默认使用 HEAD 来恢复,如果没有则默认使用 index。此时:

  • git restore 相当于 git restore --worktree
  • git restore --staged 用 HEAD 的信息来恢复 index,不会改动 working tree。
  • git restore --worktree 用 index 的信息来恢复 working tree。
  • git restore --worktree --staged 同时恢复 working tree 和 index。git restore --source HEAD --worktree --staged 相当于 git reset --hard 对于单个文件的效果。(虽然按照官方的描述来说是默认 source 为 HEAD,但是在 git 2.25.1 中实测这种情况下的默认 source 是 index)

-W link1; link2 link3 Specify the restore location. If neither option is specified, by default the working tree is restored. Specifying --staged will only restore the index. Specifying both restores both.

Torek insists on the fact git restore --source <aCommit> --worktree -- somefile is new (cannot be done with checkout): the ability to restore a file in the working tree without touching the index.Torek insists on the fact git restore --source <aCommit> --worktree -- somefile is new (cannot be done with checkout): the ability to restore a file in the working tree without touching the index.

这大概是说 git checkout 利用历史 commit 改动单个文件的同时也会改动 index。

Namespaces - cppreference.com

inline namespace 既本身存在,又将所有内容引入外围(enclosing)名字空间中。相当于名字空间后面加了一句:using namespace X;

例子:

inline namespace A {
    using Int = int;
}

int main() {
    A::Int a;
    Int b; // 也能成功
}

Python 的正则表达式函数基本都是从第一个字符开始匹配的。不像 bash 和 JS 是任意位置匹配都行。所以要适当加上 .*

主要是双显卡笔记本切换显示屏后,部分应用没有切换图形显示卡,导致未活跃的显卡时不时被唤醒,而每次唤醒会有一秒的卡顿。

创建 bat 文件(其中硬件驱动的实例路径需要在设备管理器上查看后根据实际修改):

:: Run as admin
@echo off
%1 mshta vbscript:createobject("shell.application").shellexecute("%~s0","::","","runas",1)(window.close)&exit
cd /d %~dp0

:: 如果变量为空,整个分支判断会被静默掉,所以给个默认值
set "Input=1"
set /p Input=Index of graphics card to reset? (0: Intel, 1: NVIDIA[default])

if %Input% equ 0 (
    pnputil /disable-device "PCI\VEN_8086&DEV_3E9B&SUBSYS_39FD17AA&REV_00\3&11583659&0&10"
    pnputil /enable-device "PCI\VEN_8086&DEV_3E9B&SUBSYS_39FD17AA&REV_00\3&11583659&0&10"
) else if %Input% equ 1 (
    pnputil /disable-device "PCI\VEN_10DE&DEV_1C8C&SUBSYS_39FD17AA&REV_A1\4&77AC7CD&0&0008"
    pnputil /enable-device "PCI\VEN_10DE&DEV_1C8C&SUBSYS_39FD17AA&REV_A1\4&77AC7CD&0&0008"
) else (
    echo:
    echo|set /p _=">>> Unknown choice! Exiting... <<<"
    echo:
    echo:
    pause
)

实际上在桌面上分开放两个脚本文件会比在脚本文件中选择要重启的显卡驱动更方便。因为在脚本中选择是一项额外操作。

cuda-gdb 是 cuda 的调试工具,执行非常慢。

如果需要符号信息,nvcc 的编译选项需要加上 -g -G,其中 -g 是给 host 代码添加符号信息,而 -G 是给 device 侧代码添加符号信息。

提示 XHR failed。

找到插件的网页下载 Linux 版本,然后从文件资源管理器拖动文件到工作目录,拷贝文件后运行:

code --install-extension ./doxdocgen-1.4.0.vsix

也可能是本机的代理设置和远程主机的代理设置冲突了,可以修改远程主机的 "http.proxy" 为空:

{
    "http.proxy": "",
}

decltype 推导可能带有 & 属性

decltype 坑了很多次。推导出来可能有引用类型,想要值类型时需要先去掉!

不同的 variant 在 visitor 的参数里必须独立

std::visit 的多个参数必须独立和模板参数匹配(或者 lambda 和 C++20 函数的 auto),所以即便是要求两个类型相等,也必须写成这样:

template <typename DType1, typename DType2>
void f(DType1* input, DType2* output) {
  // DType1 and DType2 are actually the same type.
}

如果确定两个类型一样,也可以少传入一个 variant,使用 void * 传入类型,然后手动做转换。

if constexpr 的编译问题

if constexpr 只在模板代码中才有去除分支的作用,在普通代码中是不行的,此时不能用来剔除不能编译的分支。