Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #37102

Re: Why are there throw() following the delete[]?

From Bo Persson <bop@gmb.dk>
Newsgroups comp.lang.c++
Subject Re: Why are there throw() following the delete[]?
Date 2015-07-16 11:03 +0200
Message-ID <d0paadFh3ueU1@mid.individual.net> (permalink)
References <20afc0b3-d071-4681-8bea-de40158a7ff0@googlegroups.com> <d0o824FqegtU5@mid.individual.net> <85288470-2662-4de8-856a-7884686c68cb@googlegroups.com>

Show all headers | View raw


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

Back to comp.lang.c++ | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Why are there throw() following the delete[]? fl <rxjwg98@gmail.com> - 2015-07-15 16:05 -0700
  Re: Why are there throw() following the delete[]? Ian Collins <ian-news@hotmail.com> - 2015-07-16 11:18 +1200
    Re: Why are there throw() following the delete[]? fl <rxjwg98@gmail.com> - 2015-07-15 16:36 -0700
      Re: Why are there throw() following the delete[]? Ian Collins <ian-news@hotmail.com> - 2015-07-16 11:44 +1200
      Re: Why are there throw() following the delete[]? Bo Persson <bop@gmb.dk> - 2015-07-16 11:03 +0200

csiph-web