最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c++20 - Need help to understand C++ partial ordering of constraints - Stack Overflow

programmeradmin0浏览0评论

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...> and CB<Args...>.
  • #2 is converted to a conjunctive normal form that consists of two clauses: CA<Args...> && CB<Args...> and CA<Args...> && CB<Args...>.
  • According to this line, CA<Args...> subsumes CA<Args...> && CB<Args...> since CA<Args...> is a disjunctive clause and CA<Args...> && CB<Args...> is a conjunctive clause and CA<Args...> subsumes itself.
  • Similarly, CB<Args...> subsumes CA<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.

发布评论

评论列表(0)

  1. 暂无评论