This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

3584. Clarify common comparison category conversions

Section: 17.11.3 [cmp.common] Status: New Submitter: Peter Brett Opened: 2021-08-23 Last modified: 2021-09-20

Priority: 3

View all issues with New status.

Discussion:

17.11.3 [cmp.common]/1 says:

The type common_comparison_category provides an alias for the strongest comparison category to which all of the template arguments can be converted.

A naive reader like me might interpret this as meaning that (1) you attempt to convert the template arguments to comparison categories and then (2) obtain the strongest among them.

However, the intent is in fact to realize the common comparison type notion from 11.10.3 [class.spaceship]/4. To obtain a non-void result, all the template arguments must be comparison categories, rather than convertible to comparison categories.

17.11.3 [cmp.common]/2 mildly contradicts the first paragraph:

Remarks: The member typedef-name type denotes the common comparison type (11.10.3 [class.spaceship]) of Ts..., the expanded parameter pack, or void if any element of Ts is not a comparison category type.

It more precisely states the behaviour, cross-references 11.10.3 [class.spaceship], and uses the correct core terminology for the metafunction that the template represents.

Suggested resolution;

Delete 17.11.3 [cmp.common]/1, because it does not provide any information not already more precisely included in 17.11.3 [cmp.common]/2.

[2021-09-20; Reflector poll]

Set priority to 3 after reflector poll.

[2021-09-20; Reflector poll]

Jens suggests alternative wording.

Previous resolution [SUPERSEDED]:

This wording is relative to N4892.

  1. Modify 17.11.3 [cmp.common] as indicated:

    -1- The type common_comparison_category provides an alias for the strongest comparison category to which all of the template arguments can be converted. [Note 1: A comparison category type is stronger than another if they are distinct types and an instance of the former can be converted to an instance of the latter. — end note]

    template<class... Ts>
    struct common_comparison_category {
      using type = see below;
    };
    

    -2- Remarks: The member typedef-name type denotes the common comparison type (11.10.3 [class.spaceship]) of Ts..., the expanded parameter pack, or void if any element of Ts is not a comparison category type.

Proposed resolution:

This wording is relative to N4892.

  1. Modify 17.11.3 [cmp.common] as indicated:

    -1- The type common_comparison_category provides an alias for the strongest comparison category to which all of the template arguments can be converted among all the template arguments. [Note 1: A comparison category type is stronger than another if they are distinct types and an instance of the former can be converted to an instance of the latter. — end note]

    template<class... Ts>
    struct common_comparison_category {
      using type = see below;
    };
    

    -2- Remarks: The member typedef-name type denotes the common comparison type (11.10.3 [class.spaceship]) of Ts..., the expanded parameter pack, or void if any element of Ts is not a comparison category type.