Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #37090 > unrolled thread
| Started by | fl <rxjwg98@gmail.com> |
|---|---|
| First post | 2015-07-15 16:05 -0700 |
| Last post | 2015-07-16 11:03 +0200 |
| Articles | 5 — 3 participants |
Back to article view | Back to comp.lang.c++
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
| From | fl <rxjwg98@gmail.com> |
|---|---|
| Date | 2015-07-15 16:05 -0700 |
| Subject | Why are there throw() following the delete[]? |
| Message-ID | <20afc0b3-d071-4681-8bea-de40158a7ff0@googlegroups.com> |
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(); The description for the above definitions is: (1) ordinary delete Deallocates the memory block pointed to by ptr (if not null), releasing the storage space previously allocated to it by a call to operator new[] and rendering that pointer location invalid. (2) nothrow delete Same as above (1). (3) placement delete Does nothing. 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() Could you explain it to me as I am still a newbie on such a question? Thanks,
[toc] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2015-07-16 11:18 +1200 |
| Message-ID | <d0o824FqegtU5@mid.individual.net> |
| In reply to | #37090 |
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. -- Ian Collins
[toc] | [prev] | [next] | [standalone]
| From | fl <rxjwg98@gmail.com> |
|---|---|
| Date | 2015-07-15 16:36 -0700 |
| Message-ID | <85288470-2662-4de8-856a-7884686c68cb@googlegroups.com> |
| In reply to | #37091 |
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. > > > -- > Ian Collins 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. Thanks again.
[toc] | [prev] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2015-07-16 11:44 +1200 |
| Message-ID | <d0o9j7FqegtU6@mid.individual.net> |
| In reply to | #37094 |
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? As I said above, throw() (noexcept in modern C++) is telling you that the operators will not throw an exception. -- Ian Collins
[toc] | [prev] | [next] | [standalone]
| From | Bo Persson <bop@gmb.dk> |
|---|---|
| Date | 2015-07-16 11:03 +0200 |
| Message-ID | <d0paadFh3ueU1@mid.individual.net> |
| In reply to | #37094 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c++
csiph-web