Will unused deconstructors be optimized out?

Posted by Brendan Long on Stack Overflow See other posts from Stack Overflow or by Brendan Long
Published on 2010-04-13T14:38:57Z Indexed on 2010/04/13 14:43 UTC
Read the original article Hit count: 234

Filed under:
|
|

Assuming MyClass uses the default deconstructor (or no deconstructor), and this code:

MyClass buffer[] = new MyClass[i];
// Construct N objects using placement new
for(size_t i = 0; i < N; i++){
    ~buffer[i];
}
delete[] buffer;

Is there any optimizer that would be able to remove this loop?

Also, is there any way for my code to detect if MyClass is using an empty/default constructor?

© Stack Overflow or respective owner

Related posts about c++

Related posts about g++