Victor Bazarov <v.ba...@comcast.invalid> writes:
> On 3/14/2016 11:39 AM, Alain Ketterlin wrote:
>>
r...@zedat.fu-berlin.de (Stefan Ram) writes:
>>
>>> I read a part of the specification of C++. It suggests than
>>> one can use »delete« outside of a class! I never saw this
>>> before, but I made this up:
>>
>> It lets you forbid the use of a particular template instanciation.
>>
>> template <typename T> void f(T x) {...} // Call f on everything
>> void f(int) = delete; // except ints
>
> Shouldn't this "definition" be a template declaration, though? I.e.
>
> template<> void f(int) = delete;
Yes, you're right.
I finally tested this and my compiler didn't complain, in either case
(unless I call f(1), of course). I even tried putting both (without
complaint). When calling f(1) the compiler selected the non-template
version to tell me I wasn't allowed to call f(int). I don't know the
exact rule (or forgot it).
Anyway, thanks for the correction.
-- Alain.