为什么 C++ 标准为 cv 限定符定义偏序?

Why does the C++ Standard define a partial ordering for cv qualifiers?

C++20 标准(在 N4892 上检查过)指出:

There is a partial ordering on cv-qualifiers, so that a type can be said to be more cv-qualified than another. Table 13 shows the relations that constitute this ordering.

6.8.4.5.

与table13:

no cv-qualifier < const
no cv-qualifier < volatile
no cv-qualifier < const volatile
const           < const volatile
volatile        < const volatile

虽然定义很清楚也很容易理解,但我想知道它为什么存在。我在标准中找不到另一段使用此排序的文章(我可能漏掉了什么!)。 Cppreference同table,同样不说明其用途

为什么存在这种偏序?

只需在标准文档中搜索“more cv-qualified”即可。会有很多比赛。也许最明显的例子:

char* pointer1;
...
const char* pointer2 = pointer1; // OK because it's more cv-qualified

在我看来,如果您正在寻找常识,只需考虑“const”而不是“cv”。