In C++, an object\'s destructor is called at the closing \"}\" for the block it was created in, right? So this means that if I have:
while(some_condition) {
Yes.
But you could have tested it yourself. This is a language feature that compilers are unlikely to get wrong.
#include struct S { S() { std::cout << "S::S()\n"; } ~S() { std::cout << "S::~S()\n"; } }; int main () { int i = 10; while(i--) { S s; } }