if (autoitr (character_map.find(c)); itr !=character_map.end()) { // *itr is valid. Do something with it.} else { // itr is the end-iterator. Don't dereference.}// itr is not available here at all
// if: before C++17{autovar(init_value);if (condition){ // branch A. var is accessible } else { // branch B. var is accessible } // var is still accessible}
// if: since C++17if (autovar (init_value); condition){ // branch A. var is accessible} else { // branch B. var is accessible}// var is not accessible any longer
// switch: before C++17{autovar (init_value);switch (var) {case1: ...case2: ... ... } // var is still accessible}
// switch: since C++17switch(autovar (init_value); var){case1: ...case2: ... ...}// var is not accessible any longer
if (autoshared_pointer (weak_pointer.lock()); shared_pointer !=nullptr) { // Yes, the shared object does still exist} else { // shared_pointer var is accessible, but a null pointer}// shared_pointer is not accessible any longer
if (DWORD exit_code; GetExitCodeProcess(process_handle,&exit_code)) { std::cout <<"Exit code of process was: "<< exit_code <<'\n';}// No useless exit_code variable outside the if-conditional