admin管理员组文章数量:1336631
I am so confused about this part from cppreference, which talks about the partial ordering of constraints
Here's my understanding.
// Dummy concepts
template<auto...>
concept CA = true;
template<auto...>
concept CB = true;
// Tester
template<auto...Args>
struct Tester {};
template<auto...Args>
requires CA<Args...> || CB<Args...> // #1
struct Tester<Args...>
{
static constexpr int value {0};
};
template<auto...Args>
requires (CA<Args...> && CB<Args...>) && (CA<Args...> && CB<Args...>) // #2
struct Tester<Args...>
{
static constexpr int value {1};
};
To check if #1 subsumes #2,
- #1 is converted to a disjunctive normal form that consists of two clauses:
CA<Args...>
andCB<Args...>
. - #2 is converted to a conjunctive normal form that consists of two clauses:
CA<Args...> && CB<Args...>
andCA<Args...> && CB<Args...>
. - According to this line,
CA<Args...>
subsumesCA<Args...> && CB<Args...>
sinceCA<Args...>
is a disjunctive clause andCA<Args...> && CB<Args...>
is a conjunctive clause andCA<Args...>
subsumes itself. - Similarly,
CB<Args...>
subsumesCA<Args...> && CB<Args...>
.
Therefore, #1 subsumes #2.
This is clearly wrong. I think I misunderstood what a normal form and a clause in a normal form mean. But I could not find good explanations. Any help would be appreciated.
本文标签: c20Need help to understand C partial ordering of constraintsStack Overflow
版权声明:本文标题:c++20 - Need help to understand C++ partial ordering of constraints - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742374417a2462872.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论