webrtc的scoped_ptr

本文探讨了WebRTC中scoped_ptr的用法,包括其如何像普通指针一样操作、所有权管理、禁止赋值和复制的特点,以及在内存管理中的栈和堆思想。通过示例代码,解释了正确和错误的使用方式。
摘要由CSDN通过智能技术生成

前几天看的webrtc实际上一直是libjingle的talk,base目录下的基础性东西,似乎是google在原来的webrtc的代码中又做了一些改进。现在由于工作的需要,所有的眼光都集中到webrtc上了,让我也不得不将精力向webrtc的代码靠拢。

最近几天的文章不会涉及到任何关于webrtc框架的东西,何况我也不懂框架,仅仅是对webrtc一些基础类的封装的使用的库,学鲁迅的拿来主义,读懂,然后据为己有,然后在自己的以后的编程中应用上面的思想进行改进。

今天主要讨论scoped_ptr,先上代码:

//  (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
//  Copyright (c) 2001, 2002 Peter Dimov
//
//  Permission to copy, use, modify, sell and distribute this software
//  is granted provided this copyright notice appears in all copies.
//  This software is provided "as is" without express or implied
//  warranty, and with no claim as to its suitability for any purpose.
//
//  See http://www.boost.org/libs/smart_ptr/scoped_ptr.htm for documentation.
//

//  scoped_ptr mimics a built-in pointer except that it guarantees deletion
//  of the object pointed to, either on destruction of the scoped_ptr or via
//  an explicit reset(). scoped_ptr is a simple solution for simple needs;
//  use shared_ptr or std::auto_ptr if your needs are more complex.

//  scoped_ptr_malloc added in by Google.  When one of
//  these goes out of scope, instead of doing a delete or delete[], it
//  calls free().  scoped_ptr_malloc<char> is likely to see much more
//  use than any other specializations.

//  release() 
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值