logo
  • 教程列表
  • SO官方文档
  • 范围守卫
    • 将分配和清理代码放在一起
    • 多个嵌套范围
  1. StackOverflow 文档
  2. D Language 教程
  3. 范围守卫
  4. 将分配和清理代码放在一起

将分配和清理代码放在一起

Created: November-22, 2018

如果保留当前块,则范围保护允许在特定条件下执行语句。

import core.stdc.stdlib;

void main() {
    int* p = cast(int*)malloc(int.sizeof);
    scope(exit) free(p);
}
  • 多个嵌套范围
  • 范围守卫

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 关于我们
  • 免责声明