Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does C++14 require that the delete expression must call `void operator ::delete(void*, std::size_t)` instead of `void ::operator delete(void*)`?

According to this

void operator delete  (void*);                                    (1)   
void operator delete[](void*);                                    (2)   
void operator delete  (void*, const std::nothrow_t&);             (3)   
void operator delete[](void*, const std::nothrow_t&);             (4)   
void operator delete(void*, std::size_t)                          (5)
void operator delete[](void*, std::size_t)                        (6)
void operator delete(void*, std::size_t, const std::nothrow_t&)   (7)
void operator delete[](void*, std::size_t, const std::nothrow_t&) (8)

(5-8) Called instead of (1-4) if a user-defined replacement is provided. The standard library implementations are identical to (1-4).

I believe the cited statement is correct; however, I cannot confirm it as per the draft C++14 standard n3797 .

I examined 3.7.4 and 18.6, and found nothing to explicitly require the delete expression must call void ::operator delete(void*, std::size_t) instead of void ::operator delete(void*) if the former exists.

Could you refer me to the right page of the draft standard?

like image 918
xmllmx Avatar asked Jul 07 '14 06:07

xmllmx


1 Answers

The selection of deallocation functions is explained in:

5.3.5 Delete [expr.delete]

10 If the type is complete and if deallocation function lookup finds both a usual deallocation function with only a pointer parameter and a usual deallocation function with both a pointer parameter and a size parameter, then the selected deallocation function shall be the one with two parameters. Otherwise, the selected deallocation function shall be the function with one parameter.

like image 145
TemplateRex Avatar answered Oct 22 '22 14:10

TemplateRex