+ 2

does nothrow applicable to delete as well?

Hi I have used nothrow in below code: https://code.sololearn.com/c4A2a24A7a20 but it does not build with no throw used accordance to delete. does it only applicable to new only?

9th Feb 2021, 10:52 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
3 Respuestas
+ 4
Delete operator never throws an exception. But still there is exists a nothrow version of delete operator which is only used by system when the `new`(nothrow version) operator fails to allocate required memory, then nothrow version of delete is called implicitly to clean the mess.
9th Feb 2021, 12:14 PM
Arsenic
Arsenic - avatar
9th Feb 2021, 1:12 PM
Arsenic
Arsenic - avatar
+ 1
Does this mean we don't have to do anything specific like nothrow in case we allocated memory using nothrow ? Perfect than ...just allocate with noththrow and simply delete
9th Feb 2021, 1:11 PM
Ketan Lalcheta
Ketan Lalcheta - avatar