类似的问题:warning: Zero as nullpointerconstant while Comparison iterators - 这是关于比较迭代器的,这个问题是关于comoparing模板类的。
我正在将 c++14 代码库迁移到 c++20。但是使用 spaceship Operator 会发出警告zero as null pointer constant,我无法弄清楚为什么会发生这种情况以及错误意味着什么。
clang++14与 一起使用-std=c++20 -Werror -Wzero-as-null-pointer-constant。
下面是最小的可重现示例,也可以在 godbolt 上运行。
#include <compare>
template<typename V, typename U>
class quantity
{
public:
using value_type = V;
using unit_type = U;
using this_type = quantity<value_type, unit_type>;
constexpr quantity() : value_() {}
constexpr quantity( const value_type &v, unit_type ) : value_( v ) {}
constexpr auto operator<=>( const this_type …Run Code Online (Sandbox Code Playgroud) 我希望 git status 也列出更改的行数,\n就像那些+和:-git pull
例子)
\n\xe2\x9d\xaf LANG=c git status\nOn branch develop\nYour branch is up to date with \'upstream/develop\'.\n\nChanges not staged for commit:\n (use "git add <file>..." to update what will be committed)\n (use "git restore <file>..." to discard changes in working directory)\n modified: package-lock.json | 1093 ++++++++---\n modified: package.json | 26 +++---\nRun Code Online (Sandbox Code Playgroud)\n因为我在文档中找不到这样的选项,所以我尝试使用diffstat,因为它用于git pull。
\xe2\x9d\xaf git diff | diffstat -C\n package-lock.json | 1093 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------\n package.json | …Run Code Online (Sandbox Code Playgroud)