今天看啥  ›  专栏  ›  OSC开源社区

“革命性”「Safe C++」扩展提案:质疑Rust、理解Rust、成为Rust?

OSC开源社区  · 公众号  · 程序员  · 2024-09-22 20:40

文章预览

↑点击上方蓝字关注「OSC开源社区」 C++ 社区公布了堪称 “革命性” 的「Safe C++」扩展提案,目标是 为 C++ 添加内存安全特性 。 该项提案将由名为 "C++ Alliance" 的机构与工程师 Sean Baxter 合作开发,C++ Alliance 计划将「Safe C++」扩展提案提交给 ISO,以纳入 C++ 标准。 C++ Alliance(C++ 联盟)是一个旨在使 C++ 编程语言易于访问和有用的公益机构,使命是让所有希望学习和应用 C++ 编程语言的人都能掌握和使用这种语言 。 采用「Safe C++」扩展编写的代码示例: #feature on safety # include int main () safe { std2:: vector < int > vec { 11 , 15 , 20 }; for ( int x : vec) { // Ill-formed. mutate of vec invalidates iterator in ranged-for. if (x % 2 ) mut vec.push_back(x); std2::println(x); } } $ circle iterator.cxx -I ../libsafecxx/single-header/ safety : during safety checking of int main() safe borrow checkin ………………………………

原文地址:访问原文地址
快照地址: 访问文章快照
总结与预览地址:访问总结与预览