This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115d. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-10-26


1100. constexpr conversion functions and non-type template arguments

Section: 7.7  [expr.const]     Status: C++11     Submitter: Jason Merrill     Date: 2010-08-01

[Voted into the WP at the March, 2011 meeting as part of paper N3260.]

According to 13.4.3 [temp.arg.nontype] paragraph 1, one of the possibilities for a template-argument for a non-type, non-template template-parameter is

However, the requirement for such a literal class type is (7.7 [expr.const] paragraph 5):

...that class type shall have a single non-explicit conversion function to an integral or enumeration type and that conversion function shall be constexpr.

Note that this normative requirement for a single conversion function is contradicted by the example in that paragraph, which reads in significant part,

    struct A {
      constexpr A(int i) : val(i) { }
      constexpr operator int() { return val; }
      constexpr operator long() { return 43; }
    private:
      int val;
    };
    template<int> struct X { };
    constexpr A a = 42;
    X<a> x; // OK: unique conversion to int

Proposed resolution (February, 2011):

This issue is resolved by the resolution of issue 1197.