On 2014/10/10 13:47, David Krauss wrote:
> On 2014-10-10, at 10:46 AM, T. C. <
rs2...@gmail.com> wrote:
>> -- pointer to object or pointer to function,
>>
>> Since void* isn't a pointer-to-object type, this would prohibit using them as template non-type parameters, which would disallow constructs like
>
> I think this is an editorial issue. void* is an object pointer type, which is probably what is meant.
To really allow void* to be a template parameter type, the restriction
in 14.3.2 [temp.arg.nontype] p5 needs to be relaxed. Now it says:
> — for a non-type template-parameter of type pointer to object,
> qualification conversions (4.4) and the array-to-pointer conversion (4.2)
> are applied; if the template-argument is of type std::nullptr_t, the
> null pointer conversion (4.10) is applied. [ Note: In particular, neither
> the null pointer conversion for a zero-valued integer literal (4.10) nor
> the derived-to-base conversion (4.10) are applied. Although 0 is a valid
> template-argument for a non-type template-parameter of integral type, it
> is not a valid template argument for a non-type template-parameter of
> pointer type. However, both (int*)0 and nullptr are valid
> template-arguments for a non-type template-parameter of type “pointer
> to int.” —end note ]
Since the template argument for pointer to object parameter shall be in
a form &id-expression with a name of an object, and T* to void* conversion
(4.10 [conv.ptr] p2) is not applied, only nullptr (or other constant
expressions of type std::nullptr_t) is valid argument for void* template
parameter.
This also means that there was no valid argument in C++03. Thus I have
thought the exclusion of void* was at least intended.
However, I think it's good to allow them if there is no solid reason to
exclude.
--
k_satoda