Date
2010-08-01.00:00:00
Message id
2883

Content

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

  • an integral constant expression (including a constant expression of literal class type that can be used as an integral constant expression as described in 7.7 [expr.const])

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