On 2015-07-16 01:36, fl wrote:
> On Wednesday, July 15, 2015 at 4:18:40 PM UTC-7, Ian Collins wrote:
>> fl wrote:
>>> Hi,
>>>
>>> When I search delete description for C++, I find the following:
>>>
>>> ordinary (1)
>>> void operator delete[] (void* ptr) throw();
>>> nothrow (2)
>>> void operator delete[] (void* ptr, const std::nothrow_t& nothrow_constant) throw();
>>> placement (3)
>>> void operator delete[] (void* ptr, void* voidptr2) throw();
>>>
>> <snip>
>>>
>>> I am puzzled about:
>>>
>>> 1. In the normal use of delete[], I never see the throw() following it;
>>> 2. The description does not mention about throw() although the upper part
>>> has throw()
>>
>> These describe the operators as defined in <new>. The throw() (noexcept
>> in modern C++) is telling you that the operators will not throw.
>>
>> You don't include the throw() when you use operator delete, it is only
>> appropriate in the declaration.
>>
>>
> Thanks. As you said, it is a declaration. Good.
> As I am a newbie to C++, I still feel it is different from a normal
> declaration. What role of the throw() in the declaration?
> I hope your further explanation can teach me more on this.
>
The throw-part lists the execeptions the function (or operator) is
allowed to throw. Here the list is empty, meaning that it throws no
exceptions.
Bo Persson