Martin Sebor wrote:
Travis Vitek wrote:
[...]
IMO, the class should have an explicit requirement on the first
template argument. If there isn't one I would propose adding
paragraph 2 with the text:
-2- The template parameter T shall have an integral type (3.9.1).
integral_constant<T>::value shall be a integral constant
expression (5.19).
With concepts, we would change the definition of the class like
this (I think):
template <IntegralConstantExpressionType T, T v>
Actually, I don't think this is quite sufficient. T is more
constrained than that. If there were an OR in Concepts it
would be:
template <IntegralConstantExpressionType T, T v>
requires IntegralType<T> || EnumerationType<T>
struct integral_constant;
I've written up an issue/proposal to fix this without using
concepts that I plan to send to the list shortly unless you
see a better way of dealing with it. Here's the proposal:
Add a new paragraph to [meta.help] with the following
requirement:
-2- The template parameter T shall have an integral type
(3.9.1) or be an enumeration (3.9.2).
integral_constant<T>::value shall be an integral
constant expression (5.19).
In addition, declare the value data member of the template
constexpr:
template <class T, T v>
struct integral_constant {
typedef T value_type;
typedef integral_constant<value_type, v> type;
static constexpr value_type value = v;
};
struct integral_constant {
// ...
};
Strangely, this isn't in N2625:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2625.pdf
Incidentally, it also seems to me that value should be declared
constexpr (both in our implementation and in the spec).
Travis