C++ Logo

std-proposals

Advanced search

[std-proposals] 回复: 回复: 回复: [PXXXXR0] Add a New Keyword ‘undecl’

From: SD SH <Z5515zwy_at_[hidden]>
Date: Fri, 12 Dec 2025 15:10:50 +0000
Yes, it is a wrong, I just want to say they will end after that line
to be precise:
} // float b ends there, then int a ends there
________________________________
发件人: Std-Proposals <std-proposals-bounces_at_[hidden]> 代表 Sebastian Wittmeier via Std-Proposals <std-proposals_at_[hidden]>
发送时间: 2025年12月12日 22:51
收件人: std-proposals_at_[hidden] <std-proposals_at_[hidden]>
抄送: Sebastian Wittmeier <wittmeier_at_projectalpha.org>
主题: Re: [std-proposals] 回复: 回复: [PXXXXR0] Add a New Keyword ‘undecl’


} // int a and float b ends there

they not just end at the same time, but in reverse order of starting the lifetime.



You can do



std::string s{"xyz"};

std::string_view v{s};



First the string_view is destructed, then the string. As if there would be an outer and an inner block. They are not destructed at the same time.





-----Ursprüngliche Nachricht-----
Von: SD SH via Std-Proposals <std-proposals_at_[hidden]>
Gesendet: Fr 12.12.2025 15:54
Betreff: [std-proposals] 回复: 回复: [PXXXXR0] Add a New Keyword ‘undecl’
An: std-proposals_at_[hidden]socpp.org;
CC: SD SH <Z5515zwy_at_[hidden]>;

Thanks for your dicussion

in your example,
{
    int a; // int a starts there
    float b; // float b starts there
} // int a and float b ends there
{
    int a; // int a starts there
    { // scope A
        float b; // float b starts there
        using b = const; // OK, it covers the lifeline of 'b'
        using a = const; // OK, it just make 'a' be const // it is allowed but I didn't mentioned above
        using a = float { a }; // error, because float a is starts in scope A and the const int a couldn't end there
    } // float b ends there; if "using a = float { a };" is allowed, both of the lifeline of const int a and float a will end there, but actually it is unexcepted
    using a = float { a }; // int a ends there and float a starts there
} // float a ends there


________________________________


Received on 2025-12-12 15:10:55