On Thu, 18 Dec 2025 at 08:20, Kim Eloy <eloy.kim@outlook.com> wrote:
And, I reply to your topic undeclare key word. It's useless, and unnecessary. Just as I said, use scope.
if(true){
 scope variables.
}
std:: funtional<void()> task = []()->{
scope variables.
};


This is useless for the problem that was presented, where the 'data' variable needs to outlive the 'i' variable:

    auto i = somemap.find(key);
    auto data = i->second.main_info;
    somemap.erase(i);
    undecl i; // this would be really nice
    // go on to use `data`


If you use a new scope, then you can't use 'data' either. So your suggestion is not helpful. Everybody understands how to use a new scope, that's not what's being discussed.

Anyway, if you want a new scope, using 'if (true)' or a lambda body is ridiculous, just create a new block scope:

{ // this creates a new scope
  auto i = somemap.find(key);
  auto data = i->second.main_info;
  somemap.erase(i);
}
// oops, can't use data.