力為的技術(shù)博客
聯(lián)系
聚合
管理
154 Posts :: 1 Stories :: 561 Comments :: 0 Trackbacks
公告
@上海浦東
常用鏈接
我的隨筆
我的評(píng)論
我參與的隨筆
留言簿
(58)
給我留言
查看公開留言
查看私人留言
隨筆分類
(154)
2. Graphics(10)
3. VC&MFC&Qt(35)
4. C++ FAQ(35)
5. GP&STL&BOOST(10)
6. COM&ATL&WTL(5)
7. OGRE Analysis(14)
8. ACIS/HOOPS(4)
9.OpenCASCADE(13)
Mac&iOS(5)
Mac&iOS(1)
Tools(22)
積分與排名
積分 - 712763
排名 - 22
最新評(píng)論
1.?re: 2015武漢校園招聘歸來
@eryar
時(shí)間安排的太緊,就沒有驚擾你啦。
--力為
2.?re: 2015武漢校園招聘歸來
評(píng)論內(nèi)容較長,點(diǎn)擊標(biāo)題查看
--sunyuanbo
3.?re: 2015武漢校園招聘歸來
謝謝 您的筆記讓我受益匪淺
--仝錫林
4.?re: 2015武漢校園招聘歸來
不知道來武漢了??!
--eryar
5.?re: 2015武漢校園招聘歸來
@力為
謝謝提醒,還在學(xué)習(xí)中。。。
--編程小學(xué)徒
6.?re: 2015武漢校園招聘歸來
評(píng)論內(nèi)容較長,點(diǎn)擊標(biāo)題查看
--編程小學(xué)徒
7.?re: 2015武漢校園招聘歸來[未登錄]
評(píng)論內(nèi)容較長,點(diǎn)擊標(biāo)題查看
--chipset
8.?re: 2015武漢校園招聘歸來
@編程小學(xué)徒
考研也不僅僅靠有編程興趣就夠了,還有其他的課程。好好準(zhǔn)備吧,??荚図樌?。
--力為
9.?re: 2015武漢校園招聘歸來
評(píng)論內(nèi)容較長,點(diǎn)擊標(biāo)題查看
--編程小學(xué)徒
10.?re: 2015武漢校園招聘歸來[未登錄]
為了混口飯吃,大家都不容易啊,原諒刷題的同學(xué)吧。話說學(xué)校里能教啥呀,都靠自己用心,有上進(jìn)心才是最重要的,否則筆試面試再好也是白扯。從面試官的角度看考試沒有錯(cuò),換成我會(huì)找有潛力的或者上進(jìn)心強(qiáng)的。
--chipset
11.?re: 【代碼】使用Teigha讀取DWG
要用vs2010編譯么?
--jj
12.?re: 臨時(shí)對(duì)象引用[未登錄]
最后一個(gè)例子也是零時(shí)變量?
--zhonghuajia
13.?re: 為什么需要給函數(shù)返回類型加const
評(píng)論內(nèi)容較長,點(diǎn)擊標(biāo)題查看
--冬瓜
14.?re: 【代碼】使用Teigha讀取DWG
歡迎加入QQ群122751318,討論Teigha
--Teigha開發(fā)
15.?re: CMake + Qt5.1.0
@MIKE
還是不行。
不管是prefix還是library還是include,都嘗試過了,不行,網(wǎng)上的方法都不行……
--Delbert
評(píng)論排行榜
1.?Pro OGRE 3D Programming 電子版(54)
2.?手機(jī)號(hào)碼黑名單(53)
3.?屏幕截圖工具V1[附源碼](22)
4.?波形顯示不是很難(15)
5.?五個(gè)小矮人分桃子-一道小學(xué)生的作業(yè)題目(15)
6.?用istringstream 解決問題一則(14)
7.?用CImage加載內(nèi)存里的Image(14)
8.?fstream 和 中文路徑(13)
9.?OGRE動(dòng)畫練習(xí)(13)
10.?VC+ADO操作數(shù)據(jù)庫注意事項(xiàng)(1)(13)
11.?OGRE粒子系統(tǒng)之在烈火中永生(11)
12.?如何通過FILE*操作內(nèi)存文件?(11)
13.?VC2008 Feature Pack的問題(11)
14.?升級(jí)到 VS2008 SP1 注意問題(11)
15.?失足于shared_ptr(11)
const auto_ptr保證擁有權(quán)不能轉(zhuǎn)移的實(shí)現(xiàn)原理?
const auto_ptr保證擁有權(quán)不能轉(zhuǎn)移的實(shí)現(xiàn)原理?
在《C++標(biāo)準(zhǔn)程序庫》p55,提到了auto_ptr使用了一個(gè)技巧,能夠copy和復(fù)制non-const auto_ptr,但不可以copy和復(fù)制const atuo_ptr。
可看了之后沒感覺,等待高手指點(diǎn)中.....
CSDN領(lǐng)分之處:
http://community.csdn.net/Expert/topic/4347/4347660.xml?temp=.3555872
VC7的
//
VC7中的
//
TEMPLATE CLASS auto_ptr
template
<
class
_Ty
>
class
auto_ptr;
template
<
class
_Ty
>
struct
auto_ptr_ref
{
//
proxy reference for auto_ptr copying
auto_ptr_ref(auto_ptr
<
_Ty
>&
_Right)
: _Ref(_Right)
{
//
construct from compatible auto_ptr
}
auto_ptr
<
_Ty
>&
_Ref;
//
reference to constructor argument
}
;
template
<
class
_Ty
>
class
auto_ptr
{
//
wrap an object pointer to ensure destruction
public
:
typedef _Ty element_type;
explicit
auto_ptr(_Ty
*
_Ptr
=
0
) _THROW0()
: _Myptr(_Ptr)
{
//
construct from object pointer
}
auto_ptr(auto_ptr
<
_Ty
>&
_Right) _THROW0()
: _Myptr(_Right.release())
{
//
construct by assuming pointer from _Right auto_ptr
}
auto_ptr(auto_ptr_ref
<
_Ty
>
_Right) _THROW0()
: _Myptr(_Right._Ref.release())
{
//
construct by assuming pointer from _Right auto_ptr_ref
}
template
<
class
_Other
>
operator
auto_ptr
<
_Other
>
() _THROW0()
{
//
convert to compatible auto_ptr
return
(auto_ptr
<
_Other
>
(
*
this
));
}
template
<
class
_Other
>
operator
auto_ptr_ref
<
_Other
>
() _THROW0()
{
//
convert to compatible auto_ptr_ref
return
(auto_ptr_ref
<
_Other
>
(
*
this
));
}
template
<
class
_Other
>
auto_ptr
<
_Ty
>&
operator
=
(auto_ptr
<
_Other
>&
_Right) _THROW0()
{
//
assign compatible _Right (assume pointer)
reset(_Right.release());
return
(
*
this
);
}
template
<
class
_Other
>
auto_ptr(auto_ptr
<
_Other
>&
_Right) _THROW0()
: _Myptr(_Right.release())
{
//
construct by assuming pointer from _Right
}
auto_ptr
<
_Ty
>&
operator
=
(auto_ptr
<
_Ty
>&
_Right) _THROW0()
{
//
assign compatible _Right (assume pointer)
reset(_Right.release());
return
(
*
this
);
}
auto_ptr
<
_Ty
>&
operator
=
(auto_ptr_ref
<
_Ty
>&
_Right) _THROW0()
{
//
assign compatible _Right._Ref (assume pointer)
reset(_Right._Ref.release());
return
(
*
this
);
}
~
auto_ptr()
{
//
destroy the object
delete _Myptr;
}
_Ty
&
operator
*
()
const
_THROW0()
{
//
return designated value
return
(
*
_Myptr);
}
_Ty
*
operator
->
()
const
_THROW0()
{
//
return pointer to class object
return
(
&**
this
);
}
_Ty
*
get
()
const
_THROW0()
{
//
return wrapped pointer
return
(_Myptr);
}
_Ty
*
release() _THROW0()
{
//
return wrapped pointer and give up ownership
_Ty
*
_Tmp
=
_Myptr;
_Myptr
=
0
;
return
(_Tmp);
}
void
reset(_Ty
*
_Ptr
=
0
)
{
//
destroy designated object and store new pointer
if
(_Ptr
!=
_Myptr)
delete _Myptr;
_Myptr
=
_Ptr;
}
private
:
_Ty
*
_Myptr;
//
the wrapped object pointer
}
;
posted on 2005-10-24 22:07
力為
閱讀(1132)
評(píng)論(3)
編輯
收藏
引用
所屬分類:
5. GP&STL&BOOST
評(píng)論
#
re: const auto_ptr保證擁有權(quán)不能轉(zhuǎn)移的實(shí)現(xiàn)原理? 2005-10-24 23:32
ilovevc
要不看看我寫的
http://blog.csdn.net/ilovevc/archive/2005/09/09/475896.aspx
回復(fù)
更多評(píng)論
#
re: const auto_ptr保證擁有權(quán)不能轉(zhuǎn)移的實(shí)現(xiàn)原理? 2005-10-25 09:22
ly4cn
const auto_ptr
對(duì)于const實(shí)體來說,只有類的構(gòu)造函數(shù)、析構(gòu)函數(shù)和聲明后帶有const的函數(shù)允許調(diào)用。
因此,對(duì)于const auto_ptr<>來說,它允許調(diào)用成員函數(shù)只有:get,operator*,operator->。
明顯的,這幾個(gè)函數(shù)不能轉(zhuǎn)移所有權(quán)。
而用于轉(zhuǎn)移所有權(quán)的release,reset等等函數(shù)均不能調(diào)用。如果調(diào)用了,將產(chǎn)生編譯期錯(cuò)誤。
回復(fù)
更多評(píng)論
#
re: const auto_ptr保證擁有權(quán)不能轉(zhuǎn)移的實(shí)現(xiàn)原理?
2005-10-26 10:08
力為
多謝各位的提供的資料:)
回復(fù)
更多評(píng)論
刷新評(píng)論列表
只有注冊(cè)用戶
登錄
后才能發(fā)表評(píng)論。
【推薦】100%開源!大型工業(yè)跨平臺(tái)軟件C++源碼提供,建模,組態(tài)!
相關(guān)文章:
Buffer和std::stream
[Ideas] Generic Serialization Framework
我的原創(chuàng)技術(shù)隨筆大全(2000~2009)
Boost.Python與C++互操作的問題(更新)
boost::any 與 boost::variant 的區(qū)別
An Adapter Solution
fstream 和 中文路徑
用std::find查找文件流中的內(nèi)容
const auto_ptr保證擁有權(quán)不能轉(zhuǎn)移的實(shí)現(xiàn)原理?
網(wǎng)站導(dǎo)航:
博客園
IT新聞
BlogJava
博問
Chat2DB
管理
Powered by:
C++博客
Copyright © 力為
精品熟女少妇av免费久久
|
亚洲av伊人久久综合密臀性色
|
久久精品中文字幕无码绿巨人
|
奇米综合四色77777久久
|
精品久久久久久国产91
|
久久精品国产黑森林
|
久久亚洲精品无码播放
|
国产精品久久久久久久久免费
|
久久影院综合精品
|
久久男人中文字幕资源站
|
久久99精品国产麻豆
|
久久久久久精品久久久久
|
手机看片久久高清国产日韩
|
狠色狠色狠狠色综合久久
|
国产亚洲欧美成人久久片
|
天堂久久天堂AV色综合
|
青青青国产成人久久111网站
|
伊人久久国产免费观看视频
|
亚洲第一永久AV网站久久精品男人的天堂AV
|
中文国产成人精品久久不卡
|
久久精品极品盛宴观看
|
欧美午夜精品久久久久免费视
|
香蕉久久夜色精品国产尤物
|
欧美日韩成人精品久久久免费看
|
精品伊人久久久
|
A狠狠久久蜜臀婷色中文网
|
久久久久久免费一区二区三区
|
亚洲伊人久久大香线蕉综合图片
|
国产精品中文久久久久久久
|
99久久99这里只有免费的精品
|
久久r热这里有精品视频
|
久久青青国产
|
久久精品无码免费不卡
|
日产精品99久久久久久
|
国产一区二区三精品久久久无广告
|
18岁日韩内射颜射午夜久久成人
|
69久久夜色精品国产69
|
噜噜噜色噜噜噜久久
|
久久免费视频6
|
久久久久久国产精品无码下载
|
国产情侣久久久久aⅴ免费
|