锘??xml version="1.0" encoding="utf-8" standalone="yes"?>免费亚洲一区二区,黄色影院成人,裸体歌舞表演一区二区http://www.shnenglu.com/Streamlet/category/11878.html鑽掑簾涓紝姹傝閱拁zh-cnSat, 05 Nov 2022 18:05:23 GMTSat, 05 Nov 2022 18:05:23 GMT60寤虹珛涓涓畝鍗曞共鍑鐨?gn+ninja 宸ュ叿閾?/title><link>http://www.shnenglu.com/Streamlet/archive/2022/11/06/229483.html</link><dc:creator>婧祦</dc:creator><author>婧祦</author><pubDate>Sat, 05 Nov 2022 18:05:00 GMT</pubDate><guid>http://www.shnenglu.com/Streamlet/archive/2022/11/06/229483.html</guid><wfw:comment>http://www.shnenglu.com/Streamlet/comments/229483.html</wfw:comment><comments>http://www.shnenglu.com/Streamlet/archive/2022/11/06/229483.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/Streamlet/comments/commentRss/229483.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Streamlet/services/trackbacks/229483.html</trackback:ping><description><![CDATA[ <h2>鑳屾櫙</h2> <p>浜嬫儏鐨勮搗鍥犳槸錛屾兂鎵句釜璺?Windows 鍜?Mac 鐨勬瀯寤烘柟妗堛傜涓鑰冭檻鑷劧鏄?CMake錛屾瘯绔熷熀鏈笂鏄簨瀹炴爣鍑嗕簡銆?/p> <p>浣嗘槸鐮旂┒浜嗕竴涓?Modern CMake錛屼篃灝辨槸浠?target 涓烘牳蹇冪殑鐞嗗康銆備絾鍙戠幇鐪嬩簡濂藉嚑澶╂枃妗o紝涔熸姌鑵懼嚭浜嗗彲鐢ㄧ殑涓滆タ錛屼絾浠嶇劧鏄病姊崇悊娓呮浠涔堢悊蹇點佸師鐞嗐傜劧鍚?CMake 鏈韓璇硶灝卞緢澶嶆潅錛屽啀鍔犱笂鎼?target 涓濂楁蹇碉紝瑕佺粰 target 璁劇疆鍚勭灞炴т箣綾葷殑錛屾湁鐐瑰己琛?OOP 鐨勬劅瑙夆︹︿絾鍏跺疄鎴戜滑鍙槸闇瑕佷竴涓?include_dir 鍜?lib_dir 鑰屽凡錛屽叾浠栭兘鏄誕浜憕</p> <p>浣嗗鏋滈鍥炲埌浼犵粺妯″紡錛屼笉鐢?Modern 姒傚康鍛紝濂藉儚鍙互灝嗗氨錛屼絾絎竴涓嶅幓鐢ㄤ竴涓伐鍏風殑鏈鏂版ā寮忥紝濂藉儚鏈夌偣涓嶄笂榪涚殑鎰熻錛坧ython 2 闄ゅ錛夛紱絎簩錛孋Make 鐨勪袱澶х棝鐐光斺旇娉曠壒绔嬬嫭琛屻佹枃妗f櫐娑╅毦鎳傗斺旇繕鏄浜烘湁鐐逛笉鐖姐?/p> <p>閭h煩鍑烘潵鐪嬪埆鐨勯夋嫨鍛紵鐩墠鐩稿鎴愮啛鐨勪篃鍙湁 Google 鐨?gn+ninja 鏂規浜嗐俫n 榪欏涓滆タ鍦?Chromium 閲屾槸瀹屽叏閰嶇疆濂界殑錛岀敤璧鋒潵榪樼畻欏烘墜錛屼絾瑕佹槸鐙珛鎷垮嚭鏉ュ憿錛屽氨娌¢偅涔堜究瀹滀簡銆傚叧閿槸瀹冪殑 toolchain 鏄鑷繁瀹氫箟鐨勩?/p> <p>涔嬪墠榪樺湪鍏徃鎼炲鎴風鐨勬椂鍊欙紝澶у灝變粠 Chromium 閲岄潰鎶?build銆乥uild_overrides 絳夌瓑涓滆タ鍏ㄩ儴鎷峰嚭鏉ワ紝濂藉浼欙紝鍑犵櫨 MB 鐢氳嚦涓?G銆備絾鏄叕鍙擱噷鍢涳紝娌′漢綆″共涓嶅共鍑錛屾庝箞蹇庝箞鏉ャ傚悗鏉ュ張鐪嬪埌 Google 鑷鐨?Crashpad 閲岄潰涔熺敤浜嗚繖濂楁瀯寤猴紝浣嗗伐鍏烽摼琚畝鍖栦簡涓涓嬶紝鍙?mini_chromium銆傝繖涓瘮 Chromium 閲岀殑灝忓浜嗭紝鏄彲浠ユ嬁榪囨潵鐩存帴鐢ㄧ殑錛岀己灝戜竴浜涢厤緗彲浠ヨ嚜宸卞姞銆備絾鏄憿錛屽儚鎴戜滑榪欑媧佺櫀錛屼粛鐒舵槸鍙椾笉楦熺殑銆傛墍浠ュ憿錛屾垜浠騫插共鍑鍑鐨勫緩绔嬩竴濂楀伐鍏烽摼銆?/p> <h2>鏋勫緩緋葷粺瀹夎</h2> <p>棣栧厛錛屾垜浠槑紜畾浣嶃俫n 鍜?ninja 閮芥槸寮鍙戞満涓婇渶瑕侀瑁呯殑錛屼笉鏄蔣浠舵彁渚涚殑銆侰hromium 鐨勬悶娉曟槸鑷繁鎻愪緵錛実n 鐨勬枃妗d篃璇磋寮鍙戣呮彁渚涘伐鍏楓備絾榪欏鎬濊礬璺熶紶緇熺殑鐞嗗康鏄啿紿佺殑銆傚悓鏃訛紝鑷繁瀹夎宸ュ叿鎴愭湰鏄瘮杈冧綆鐨勶細</p> <ul> <li>linux <ul> <li>ninja 鍦ㄤ富嫻佸寘綆$悊緋葷粺閲屽凡緇忔湁浜嗭紝鍖呭悕鍙兘鏄?ninja 鎴?ninja-build錛岀洿鎺ュ畨瑁呭氨鍙互</li> <li>gn 鍦ㄩ儴鍒嗗寘綆$悊緋葷粺鏈夛紝灝濊瘯鍖呭悕 gn 鎴?gn-build 絳夛紝娌℃湁鐨勮瘽鍙互涓嬭澆<a >浜岃繘鍒剁増鏈?/a>錛屾垨鑰呬粠婧愪唬鐮佽嚜琛岀紪璇?/li> </ul> </li> <li>mac <ul> <li>ninja 鍦?brew 閲屽寘鍚嶅彨 ninja錛屽湪 MacPorts 閲屽寘鍚嶅彨 ninja-build</li> <li>gn 鍦?brew 閲屾病鏈夛紝鍙互涓嬭澆<a >浜岃繘鍒剁増鏈?/a>錛涘湪 MacPorts 閲屽彨 gn-devel</li> </ul> </li> <li>win <ul> <li>ninja 鍙互鍦?<a >GitHub</a> 涓嬭澆浜岃繘鍒剁増鏈紝gn 鍙互鍦?gn 瀹樼綉涓嬭澆<a >浜岃繘鍒剁増鏈?/a></li> </ul> </li> </ul> <p>鑷繁涓嬭澆鐨勮緗埌 PATH錛屾祴璇?<code>gn --version</code> 浠ュ強 <code>ninja --version</code>錛岃兘榪愯鍗沖彲</p> <h2>鐩爣</h2> <p>甯屾湜鍋氬埌鎻愪緵涓涓?git repo錛屼嬌鐢ㄨ?clone 鍒拌嚜宸遍」鐩殑 build 鐩綍錛岀劧鍚庝嬌鐢ㄨ呭彧瑕佸湪 .gn 鏂囦歡閲岄厤緗?/p> <pre><code class="language-gn">buildconfig = "//build/BUILDCONFIG.gn" </code></pre> <p>灝卞彲浠ヤ嬌鐢ㄦ垜浠彁渚涚殑宸ュ叿閾撅紝鍦?PC 涓夌榪涜鏋勫緩銆?/p> <p>浣跨敤鑰呯殑鍞竴璐熸媴灝辨槸緙栧啓鑷繁鐨?BUILD.gn</p> <h2>宸ュ叿閾炬惌寤?/h2> <p>棣栧厛鎴戜滑鐪?gn 鐨勬枃妗o紝浠ュ強瀹冪殑渚嬬▼ simple_build 閲岀殑宸ュ叿閾鵑厤緗細</p> <p>https://gn.googlesource.com/gn/+/HEAD/examples/simple_build/build/toolchain/BUILD.gn</p> <p>榪欎釜鏄彲浠ョ洿鎺ョ敤鐨勶紝鍙笉榪囧彧鏈?linux 绔紙褰撶劧 mac 涔熻兘鐢級銆傛垜浠啀緇撳悎 chrome 閲岀殑宸ュ叿閾鵑厤緗紝榪涜涓浜涘畬鍠勩?/p> <h3>鍩虹姒傚康</h3> <p>棣栧厛鎴戜滑浜嗚В gn 浣撶郴闇瑕佺殑鏈灝忛厤緗槸浠涔堛?/p> <p>絎竴錛屽畠闇瑕佸湪鏍圭洰褰曞啓涓涓?.gn 鏂囦歡錛屽湪閲岄潰瀹氫箟 buildconfig錛屾寚鍒板彟涓涓枃浠訛紝涓鑸槸</p> <pre><code class="language-gn">buildconfig = "//build/BUILDCONFIG.gn" </code></pre> <p>絎簩銆丅UILDCONFIG.gn 閲岄潰闇瑕佽緗粯璁ゅ伐鍏烽摼錛屼篃灝辨槸鍐欎竴琛?/p> <pre><code class="language-gn">set_default_toolchain("//build/toolchain:gcc") </code></pre> <p>絎笁銆佸畾涔夊伐鍏烽摼錛屽涓婁緥鐨?//build/toolchain:gcc銆?/p> <p>闇瑕佸湪 build/toolchain 涓嬪緩绔?BUILD.gn 鏂囦歡錛屽唴瀹規槸</p> <pre><code>toolchain("gcc") { # ... } </code></pre> <p>鏈鍚庡湪 toolchain 閲屽畾涔夊悇縐?tool銆?/p> <h3>宸ュ叿閾句腑鐨勫伐鍏?/h3> <p>榪欓儴鍒嗘枃妗e湪榪欓噷錛歨ttps://gn.googlesource.com/gn/+/main/docs/reference.md#func_tool</p> <p>綆鍗曞榪頒竴涓嬶紝鍙瀹氫箟鐨勫伐鍏鋒湁錛?/p> <ul> <li>緙栬瘧宸ュ叿:<br /> "cc": C 緙栬瘧鍣?br /> "cxx": C++ 緙栬瘧鍣?br /> "cxx_module": 鏀寔 module 鐨?C++ 緙栬瘧鍣?br /> "objc": Objective C 緙栬瘧鍣?br /> "objcxx": Objective C++ 緙栬瘧鍣?br /> "rc": Windows 璧勬簮鑴氭湰緙栬瘧鍣?br /> "asm": 姹囩紪鍣?br /> "swift": Swift 緙栬瘧鍣?/li> <li>閾炬帴宸ュ叿:<br /> "alink": 闈欐佸簱閾炬帴鍣?br /> "solink": 鍔ㄦ佸簱閾炬帴鍣?br /> "link": 鍙墽琛屾枃浠墮摼鎺ュ櫒</li> </ul> <p>錛堝叾浠栫殑灝卞厛涓嶇湅浜嗭級</p> <p>鎴戜滑鏉ョ湅涓涓?https://gn.googlesource.com/gn/+/HEAD/examples/simple_build/build/toolchain/BUILD.gn 鐨勪竴浜涘叧閿厤緗細</p> <pre><code class="language-gn">toolchain("gcc") { tool("cc") { command = "gcc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" outputs = [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ] # ... } tool("cxx") { command = "g++ -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}" outputs = [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ] # ... } tool("alink") { command = "rm -f {{output}} && ar rcs {{output}} {{inputs}}" outputs = [ "{{target_out_dir}}/{{target_output_name}}{{output_extension}}" ] # ... } tool("solink") { command = "g++ -shared {{ldflags}} -o $sofile $os_specific_option @$rspfile" outputs = [ sofile ] # ... } tool("link") { command = "g++ {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group {{libs}}" outputs = [ outfile ] # ... } tool("stamp") { command = "touch {{output}}" } tool("copy") { command = "cp -af {{source}} {{output}}" } } </code></pre> <p>鍙互鐪嬪埌錛宑c 鍜?cxx 鎵ц command 鍚庯紝鐢熸垚 .o 鏂囦歡錛岀劧鍚庤繖浜?.o 鏂囦歡鍙互浣滀負 alink銆乻olink銆乴ink 鐨?inputs錛岃瀹冧滑 command 緇х畫浣跨敤錛屾渶鍚庤緭鍑洪潤鎬佸簱銆佸姩鎬佸簱浠ュ強鍙墽琛屾枃浠躲?/p> <p>鍏朵綑灞炴у彲浠ユ煡鏂囨。浜嗚В鍚箟銆?/p> <h3>瀵規瘮 Chromium 涓殑閰嶇疆</h3> <h4>Linux</h4> <p>涓昏閰嶇疆鍦ㄨ繖閲岋細https://source.chromium.org/chromium/chromium/src/+/main:build/toolchain/gcc_toolchain.gni</p> <p>涔熸槸 gcc 鐨勶紝涓?simple_build 閲岀殑澶у悓灝忓紓錛屾病鏈夌壒鍒殑銆?/p> <h4>Mac</h4> <p>涓昏閰嶇疆鍦ㄨ繖閲岋細https://source.chromium.org/chromium/chromium/src/+/main:build/toolchain/apple/toolchain.gni</p> <p>鍖哄埆鏈夛細</p> <ul> <li>鐢?clang 緋誨垪緙栬瘧宸ュ叿錛岃屼笉鏄?gcc</li> <li>alink 涓嶆槸鐢?ar錛岃屼嬌鐢?libtool</li> <li>solink 鐨勯粯璁ゆ墿灞曞悕鏀規垚浜?dylib</li> <li>鐢ㄤ簡涓涓?linker_driver.py 鏉ユ敮鎸佺敓鎴?dSYM錛屽湪閲岄潰璋冪敤浜?dsymutil 鍜?strip</li> </ul> <h4>Win</h4> <ul> <li>緙栬瘧鐢?cl錛岄潤鎬佸簱閾炬帴鐢?lib錛屽姩鎬佸簱鍜屽彲鎵ц鏂囦歡鐨勯摼鎺ョ敤 link</li> <li>lib_switch = ""錛宭ib_dir_switch = "/LIBPATH:"錛涘墠涓よ?lib_switch = "-l"錛宭ib_dir_switch = "-L"</li> </ul> <h3>寤虹珛鎴戜滑鐨勫伐鍏烽摼</h3> <p>鍩烘湰涓婃槸鏍規嵁涓婇潰鍒嗘瀽鐨勮鐐歸厤緗紝鏈緇堢粨鏋滃湪姝わ細https://github.com/Streamlet/gn_toolchain</p> <p>鏂板鐨勪竴浜涘樊寮傛湁錛?/p> <ul> <li> <p>澧炲姞鍏ㄥ眬鍙傛暟 is_debug錛屽彲浠ュ湪 <code>gn gen out --args="is_debug=true"</code>浼犲叆銆傞粯璁?is_debug 涓?false錛屽紑鍚墍鏈変紭鍖栥?/p> </li> <li> <p>mac 涓嬬敓鎴?dSYM 涓嶄嬌鐢?python 鑴氭湰錛岀洿鎺ユ槸 <code>$ld ... && dsymutil ... && strip</code></p> </li> <li> <p>mac 涓嬪姞浜嗕竴涓?template錛歛pp_bundle錛岀敤鏉ョ敓鎴?xxx.app錛屼富瑕侀厤緗潵鑷簬 create_bundle 鏂囨。閲岀殑渚嬪瓙</p> </li> <li> <p>win 涓嬪鍔犱簡涓浜涢厤緗泦</p> <ul> <li> <p>鍔ㄦ?闈欐侀摼鎺?CRT錛?/build/config/win:console_subsystem銆?/build/config/win:static_runtime</p> </li> <li> <p>鎺у埗鍙扮▼搴忋乄in32 紼嬪簭錛?/build/config/win:console_subsystem銆?/build/config/win:windows_subsystem</p> <p>榪欎釜鍏跺疄涓鑸儏鍐典笅鐢ㄤ笉鐫錛屽彧瑕佸叆鍙e嚱鏁版槸 main/WinMain錛宭ink 榛樿灝辨槸鎺у埗鍙扮▼搴?Win32 紼嬪簭</p> </li> <li> <p>XP 鏀寔錛?/build/config/win:console_subsystem_xp銆?/build/config/win:windows_subsystem_xp</p> <p>鍏蜂綋瀹炵幇鏄摼鎺ュ弬鏁板姞 /SUBSYSTEM:CONSOLE,5.01 鎴?/SUBSYSTEM:WINDOWS,5.01銆傚叧閿槸鍚庨潰鐨勭増鏈彿 5.01錛屼負浜嗗姞鐗堟湰鍙峰垯蹇呴』鎸囧畾瀛愮郴緇熷悕縐幫紝鎵浠ュ垎浜?console_subsystem_xp 鍜?windows_subsystem_xp銆傚張錛寈p 榪欓噷鎻愪緵浜嗕袱涓?subsystem 鐨勯厤緗泦錛岄潪 xp 涔熸彁渚涗袱涓?/p> <p>浣嗘槸鎴戜滑娌℃湁鍔?_WIN32_WINNT=0x0501銆乄INVER=0x0501銆乢USING_V110_SDK71_錛屼篃娌℃湁鎸囧畾蹇呴』浣跨敤 7.0 鐗堟湰鐨?SDK錛岃繖浜涢兘鏄潪蹇呴』鐨勶紝鍙涓嶇敤鍒?XP 浠ュ悗娣誨姞鐨?API 鍗沖彲銆備嬌鐢ㄨ呭彲浠ュ湪鑷繁鐨?target 閲岄潰瀹氫箟榪欎簺瀹忋?/p> </li> </ul> </li> </ul> <h2>浣跨敤妗堜緥</h2> <p>鎻愪緵涓涓嬌鐢ㄦ渚嬶細https://github.com/Streamlet/gn_toolchain_sample</p> <p>鍥犱負瀹冧互 git submodule 褰㈠紡寮曠敤浜?https://github.com/Streamlet/gn_toolchain錛屾墍浠?git clone 浠ュ悗錛岄渶瑕?<code>git submodule update --init</code>涓涓嬨?/p> <p>鐒跺悗鍦ㄦ牴鐩綍鎵ц錛氾紙紜繚 gn 鍜?ninja 宸茬粡鍦?PATH 涓級</p> <pre><code class="language-sh">gn gen out ninja -C out </code></pre> <p>鍗沖彲銆?/p> <p>Mac 涓嬩細棰濆鐢熸垚涓涓?objc 欏圭洰 objc_console_application 浠ュ強涓涓?app_bundle錛歯s_application.app銆?/p> <p>Win 浼氶澶栫敓鎴愪竴涓?Win32 欏圭洰 win32_application銆?/p> <p>Win 涓嬮渶瑕佸厛鎵ц涓涓?Visual Studio 甯︾殑鍛戒護琛岀幆澧冿紝濡?VS 2022 Community 鐨?鈥渪64 Native Tools Command Prompt for VS 2022鈥濓紝cl 絳夊伐鍏鋒墠浼氬彲鐢ㄣ?/p> <p>濡傛灉瑕佹祴璇?XP錛?2浣嶏級錛岀敤鈥渪86 Native Tools Command Prompt for VS 2022鈥濊繘鍏ワ紝CD 鍒伴」鐩洰褰曪紝鎵ц錛?/p> <pre><code class="language-gn">gn gen out --args="target_cpu=\"x86\"" ninja -C out </code></pre> <h2>鎬葷粨</h2> <p>鎴戜滑鍙敤鍑犲崄 KB 鐨勫ぇ灝忓畬鎴愪簡璺ㄧ鏀寔錛屾槸寰堣交閲忕殑涓涓厤緗傚鏋滄偍瑙夊緱瀹炵敤騫惰鍙繖縐嶆柟寮忥紝嬈㈣繋涓璧鋒潵緇存姢銆佸畬鍠勩?/p> <img src ="http://www.shnenglu.com/Streamlet/aggbug/229483.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Streamlet/" target="_blank">婧祦</a> 2022-11-06 02:05 <a href="http://www.shnenglu.com/Streamlet/archive/2022/11/06/229483.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>寰蔣鎷奸煶闀垮彞妯″紡鎭㈠宸ュ叿鏀寔Win10 1803http://www.shnenglu.com/Streamlet/archive/2020/09/20/217462.html婧祦婧祦Sun, 20 Sep 2020 05:53:00 GMThttp://www.shnenglu.com/Streamlet/archive/2020/09/20/217462.htmlhttp://www.shnenglu.com/Streamlet/comments/217462.htmlhttp://www.shnenglu.com/Streamlet/archive/2020/09/20/217462.html#Feedback0http://www.shnenglu.com/Streamlet/comments/commentRss/217462.htmlhttp://www.shnenglu.com/Streamlet/services/trackbacks/217462.html4鏈堜喚灝辨湁浜虹暀璦鏃у井杞嫾闊蟲仮澶嶅伐鍏蜂笉鏀寔Win10 1803浜嗭紝鎴戣嚜宸變篃閬囧埌浜嗭紝浣嗗洜涓烘病鏃墮棿鎼烇紝鍕変負鍏墮毦浣跨敤浜嗚瘝緇勬ā寮忕殑寰蔣鎷奸煶鍑犱釜鏈堬紝緇堜簬鍦ㄥ叓鏈堜喚鎶戒釜絀虹爺絀朵簡涓嬶紝瑙e喅浜嗐?/p>

榪欐鏄洜涓哄偦閫煎ぇ寰蔣鏀逛簡 System32\IME\shared 閲岀殑涓滆タ錛屽鑷存棫緋葷粺鎷瘋繃鏉ョ殑鏂囦歡涓?System32\IME\shared 鐨勪笢瑗夸笉鍏煎浜嗐傝В鍐蟲柟寮忓緢鏆村姏錛氫粠浠ュ墠鐨勭増鏈鍒?System32\IME\shared 榪囨潵銆?/p>

涓嬭澆錛?a >https://www.streamlet.org/software/mspyforever/

錛堝師鍙戜簬 GitHub Pages錛?018-10-13 13:36:04錛?/p>

婧祦 2020-09-20 13:53 鍙戣〃璇勮
]]>
鍙戝竷涓伐鍏鳳紝涓閿仮澶峎in8/8.1涓殑寰蔣鎷奸煶闀垮彞妯″紡錛堟柊浣撻獙妯″紡錛?/title><link>http://www.shnenglu.com/Streamlet/archive/2014/03/26/206335.html</link><dc:creator>婧祦</dc:creator><author>婧祦</author><pubDate>Tue, 25 Mar 2014 17:10:00 GMT</pubDate><guid>http://www.shnenglu.com/Streamlet/archive/2014/03/26/206335.html</guid><wfw:comment>http://www.shnenglu.com/Streamlet/comments/206335.html</wfw:comment><comments>http://www.shnenglu.com/Streamlet/archive/2014/03/26/206335.html#Feedback</comments><slash:comments>24</slash:comments><wfw:commentRss>http://www.shnenglu.com/Streamlet/comments/commentRss/206335.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Streamlet/services/trackbacks/206335.html</trackback:ping><description><![CDATA[<p align="center">錛坈nBeta錛?a title="http://www.cnbeta.com/articles/277936.htm" target="_blank">http://www.cnbeta.com/articles/277936.htm</a>錛?/p> <p>棣栧厛璐翠釜鍥撅紝澶у鏉ヤ竴璧峰康鍙拌瘝~</p> <p><a href="http://www.shnenglu.com/images/cppblog_com/Streamlet/Windows-Live-Writer/880134ac1d58_D1E/MSPYForever_2.png"><img title="MSPYForever" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="MSPYForever" src="http://www.shnenglu.com/images/cppblog_com/Streamlet/Windows-Live-Writer/880134ac1d58_D1E/MSPYForever_thumb.png" width="600" height="400"></a></p> <p> </p> <p>蹇靛畬浜嗘湪鏈夛紵寰堟縺鎯呮編婀冧箟鎰ゅ~鑶烘湁鏈ㄦ湁錛?/p> <p> </p> <p>榪欎簨鎯呮渶鏃╄拷婧埌鍓嶅勾 8 鏈堢殑涓綃囨枃绔犮?a href="http://www.shnenglu.com/Streamlet/archive/2014/02/17/188249.html" target="_blank">鍗佷釜姝ラ鎵懼洖 Win8 涓殑寰蔣鎷奸煶鏂頒綋楠屾ā寮?/a>銆嬶紝鍏跺疄灝辨槸鎵嬪伐娉ㄥ唽涓涓狢OM瀹屼簨錛屽彧鏄偦閫煎ぇ寰蔣鍒繪剰寮勪簡娉ㄥ唽琛ㄦ潈闄愭潵灞忚斀錛屾搷浣滆搗鏉ョ暐寰箒鐞愩傚埌鐩墠涓烘錛學in8閲嶈緋葷粺宸茬粡涓嶄笅鍗佹浜嗭紝姣忔閮芥槸榪欐牱鎵嬪伐鎿嶄綔錛屾垜宸茬粡鍘屽︿簡銆?/p> <p>鍙﹀榪樻湁Win8.1涓婄殑闂錛岀敱浜庡偦閫煎ぇ寰蔣宸茬粡瀹屽叏鍒犻櫎浜嗘枃浠訛紝灝辨病娉曡繖涔堟悶浜嗭紝灝辯畻浠嶹in8鎷瘋繃鏂囦歡鏉ワ紝涔熸棤娉曠畝鍗曟敞鍐屼嬌鐢ㄣ傚姞涓婃垜瀵?.1闈炲父闈炲父涓嶆劅鍐掞紝涓鐩存病鍘葷爺絀躲傚墠浜涘ぉ鐪嬪埌涔嬪墠鐨勯偅綃囨枃绔犻噷 Charles Leigh 鍥炲浜嗕袱綃囨枃绔狅紙<a target="_blank">ePig 閭g瘒</a>鏄師鍒涘惂璨屼技錛屾劅璋級錛屾彁渚涗簡瑙e喅鏂規銆備簬鏄笂涓懆鏈埌鐜板湪灝辨崳榧撲釜涓閿仮澶嶅伐鍏鳳紝鏂逛究鑷繁浠ュ悗閲嶈鐢紝涔熸柟渚垮箍澶у井鎷煎厷銆?/p> <p>寰嫾鍏氾紙鍖呮嫭鎴戯級瀛滃瓬涓嶅︾殑榪芥眰寰嫾闀垮彞妯″紡鐨勬儏鎬錛岃鎴戦潪甯告劅鍔ㄣ傚笇鏈涘偦閫煎ぇ寰蔣鐪嬪埌鎴戜滑鐨勫績澹般傚埆鎼炰粈涔堢牬璇嶇粍杈撳叆娉曚簡錛屼綘鎼炰笉榪囨湰鍦熻繖涔堝鍘傚鐨勶紝浣犵殑涓嬮檺涔熸病鏈夋湰鍦熷巶瀹朵綆錛屽敮涓鐨勪紭鍔垮彲鑳藉氨鏄病騫垮憡娌″脊紿椾簡鍚с傝嚦浜庤緭鍏ョ畻娉曚粈涔堢殑錛屽湪璇嶇粍妯″紡閲岄潰鏍規湰涓嶈凍浠ヤ綋鐜板緱澶錛岄暱鍙ユā寮忔墠鏄冮獙鍟娿傚洖澶村惂錛?/p> <p>涓嬭澆欏甸潰錛?a title="http://www.streamlet.org/Software/MSPYForever/" target="_blank">http://www.streamlet.org/Software/MSPYForever/</a></p> <p>CodePlex 欏圭洰欏甸潰錛?a title="https://mspyforever.codeplex.com/" target="_blank">https://mspyforever.codeplex.com/</a></p> <p> </p> <p>璇峰井鎷煎厷浠浼犳挱銆傛湁 Bug 鍙婃椂鍙嶉銆?/p><img src ="http://www.shnenglu.com/Streamlet/aggbug/206335.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Streamlet/" target="_blank">婧祦</a> 2014-03-26 01:10 <a href="http://www.shnenglu.com/Streamlet/archive/2014/03/26/206335.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>灝?Timer 瀵硅薄鍖?/title><link>http://www.shnenglu.com/Streamlet/archive/2013/06/25/201279.html</link><dc:creator>婧祦</dc:creator><author>婧祦</author><pubDate>Mon, 24 Jun 2013 16:18:00 GMT</pubDate><guid>http://www.shnenglu.com/Streamlet/archive/2013/06/25/201279.html</guid><wfw:comment>http://www.shnenglu.com/Streamlet/comments/201279.html</wfw:comment><comments>http://www.shnenglu.com/Streamlet/archive/2013/06/25/201279.html#Feedback</comments><slash:comments>6</slash:comments><wfw:commentRss>http://www.shnenglu.com/Streamlet/comments/commentRss/201279.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Streamlet/services/trackbacks/201279.html</trackback:ping><description><![CDATA[     鎽樿: Timer榪欑帺鎰忓効寰堝父鐢紝鍗村張寰堢儲浜恒傜儲浜轟箣澶勬湁鍥涳細 1.         濡傛灉灝嗗叾璁懼埌HWND涓婏紝鍒?a)         蹇呴』鎵嬪伐緇存姢Timer鐨処D錛屽皬蹇冪考緲煎湴淇濊瘉榪欎簺ID涓嶉噸澶嶏紝鍙兘鏈変漢錛堟瘮濡傛垜錛夊氨涓嶆庝箞鍠滄鎵嬪伐緇存姢紜紪鐮佺殑ID銆?...  <a href='http://www.shnenglu.com/Streamlet/archive/2013/06/25/201279.html'>闃呰鍏ㄦ枃</a><img src ="http://www.shnenglu.com/Streamlet/aggbug/201279.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Streamlet/" target="_blank">婧祦</a> 2013-06-25 00:18 <a href="http://www.shnenglu.com/Streamlet/archive/2013/06/25/201279.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>瑁稿啓涓涓繘紼嬪 COM 緇勪歡http://www.shnenglu.com/Streamlet/archive/2012/12/02/195900.html婧祦婧祦Sun, 02 Dec 2012 11:56:00 GMThttp://www.shnenglu.com/Streamlet/archive/2012/12/02/195900.htmlhttp://www.shnenglu.com/Streamlet/comments/195900.htmlhttp://www.shnenglu.com/Streamlet/archive/2012/12/02/195900.html#Feedback1http://www.shnenglu.com/Streamlet/comments/commentRss/195900.htmlhttp://www.shnenglu.com/Streamlet/services/trackbacks/195900.html闃呰鍏ㄦ枃

婧祦 2012-12-02 19:56 鍙戣〃璇勮
]]>
璁?COM 鑴辯娉ㄥ唽琛?/title><link>http://www.shnenglu.com/Streamlet/archive/2012/09/21/191436.html</link><dc:creator>婧祦</dc:creator><author>婧祦</author><pubDate>Thu, 20 Sep 2012 16:34:00 GMT</pubDate><guid>http://www.shnenglu.com/Streamlet/archive/2012/09/21/191436.html</guid><wfw:comment>http://www.shnenglu.com/Streamlet/comments/191436.html</wfw:comment><comments>http://www.shnenglu.com/Streamlet/archive/2012/09/21/191436.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.shnenglu.com/Streamlet/comments/commentRss/191436.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Streamlet/services/trackbacks/191436.html</trackback:ping><description><![CDATA[     鎽樿: 寮曡█ 鍦ㄤ笂涓綃囥婂湪 DLL 涓姞鍏ョ浜屼釜 COM 綾匯嬬殑鈥滃崟鐢ㄦ埛娉ㄥ唽鈥濅竴鑺備腑錛屾垜浠浘鎻愬埌鑴辯娉ㄥ唽琛ㄤ緷璧栦竴浜嬶紝鐜板湪鎴戜滑鏉ユ妸榪欎簨鍎跨粰鍔炰簡銆?  娉ㄥ唽 鎴戜滑鍦ㄤ箣鍓嶆敮鎸佷簡鈥渞egsvr32 /n /i:user COMProvider.dll鈥濊繖涓娉ㄥ唽鍛戒護銆傝繖涓娉ㄥ唽鍛戒護緇欎簡鎴戜滑涓瀹氱殑鎵╁睍浣欏湴銆備粠ATL榛樿鐨勪唬鐮佹潵鐪嬶紝瀵逛簬DllInstall錛岀洰鍓嶅凡瀹氫箟鐨勫懡浠よ鍙傛暟浼間箮鍙湁user錛屼簬鏄垜浠彲浠ュ畾...  <a href='http://www.shnenglu.com/Streamlet/archive/2012/09/21/191436.html'>闃呰鍏ㄦ枃</a><img src ="http://www.shnenglu.com/Streamlet/aggbug/191436.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Streamlet/" target="_blank">婧祦</a> 2012-09-21 00:34 <a href="http://www.shnenglu.com/Streamlet/archive/2012/09/21/191436.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍦?DLL 涓姞鍏ョ浜屼釜 COM 綾?/title><link>http://www.shnenglu.com/Streamlet/archive/2012/09/12/190331.html</link><dc:creator>婧祦</dc:creator><author>婧祦</author><pubDate>Tue, 11 Sep 2012 16:23:00 GMT</pubDate><guid>http://www.shnenglu.com/Streamlet/archive/2012/09/12/190331.html</guid><wfw:comment>http://www.shnenglu.com/Streamlet/comments/190331.html</wfw:comment><comments>http://www.shnenglu.com/Streamlet/archive/2012/09/12/190331.html#Feedback</comments><slash:comments>6</slash:comments><wfw:commentRss>http://www.shnenglu.com/Streamlet/comments/commentRss/190331.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Streamlet/services/trackbacks/190331.html</trackback:ping><description><![CDATA[     鎽樿: 寮曡█ 鍦ㄥ墠闈㈠嚑綃囨枃绔犻噷錛屾垜浠凡緇忔垚鍔熻劚紱籄TL鍐欎簡涓涓狢OM緇勪歡錛屽茍涓斿疄鐜頒簡鑷姩鍖栥備粖澶╋紝鎴戜滑鏉ュ姞鍏ョ浜屼釜綾伙紝騫朵笖涓哄姞鍏ョ浜屼釜綾誨仛涓浜涙暣鐞嗗伐浣溿?  涓篋LL寤虹珛涓涓狹odule綾?鍦ㄥ墠闈紝鎴戜滑涓轟簡浣垮緱DllCanUnloadNow鑳芥紜伐浣滆屾斁浜嗕竴涓叏灞鍙橀噺LONG g_nModuleCount錛屽茍涓斿湪SampleClass鐨勬瀯閫犲嚱鏁板拰鏋愭瀯鍑芥暟閲屽瀹冭繘琛岃嚜澧炲拰鑷噺銆傚彟澶栬繕鏈変釜IType...  <a href='http://www.shnenglu.com/Streamlet/archive/2012/09/12/190331.html'>闃呰鍏ㄦ枃</a><img src ="http://www.shnenglu.com/Streamlet/aggbug/190331.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Streamlet/" target="_blank">婧祦</a> 2012-09-12 00:23 <a href="http://www.shnenglu.com/Streamlet/archive/2012/09/12/190331.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>璁〤OM緇勪歡鍙璺ㄨ璦璋冪敤http://www.shnenglu.com/Streamlet/archive/2012/09/09/190026.html婧祦婧祦Sun, 09 Sep 2012 04:43:00 GMThttp://www.shnenglu.com/Streamlet/archive/2012/09/09/190026.htmlhttp://www.shnenglu.com/Streamlet/comments/190026.htmlhttp://www.shnenglu.com/Streamlet/archive/2012/09/09/190026.html#Feedback3http://www.shnenglu.com/Streamlet/comments/commentRss/190026.htmlhttp://www.shnenglu.com/Streamlet/services/trackbacks/190026.html闃呰鍏ㄦ枃

婧祦 2012-09-09 12:43 鍙戣〃璇勮
]]>
瑁稿啓涓涓繘紼嬪唴 COM 緇勪歡http://www.shnenglu.com/Streamlet/archive/2012/09/07/189762.html婧祦婧祦Thu, 06 Sep 2012 16:23:00 GMThttp://www.shnenglu.com/Streamlet/archive/2012/09/07/189762.htmlhttp://www.shnenglu.com/Streamlet/comments/189762.htmlhttp://www.shnenglu.com/Streamlet/archive/2012/09/07/189762.html#Feedback5http://www.shnenglu.com/Streamlet/comments/commentRss/189762.htmlhttp://www.shnenglu.com/Streamlet/services/trackbacks/189762.html闃呰鍏ㄦ枃

婧祦 2012-09-07 00:23 鍙戣〃璇勮
]]>
鍐欎釜鍚?Windows Media Player 鐨勭獥鍙?/title><link>http://www.shnenglu.com/Streamlet/archive/2012/09/04/189470.html</link><dc:creator>婧祦</dc:creator><author>婧祦</author><pubDate>Tue, 04 Sep 2012 14:16:00 GMT</pubDate><guid>http://www.shnenglu.com/Streamlet/archive/2012/09/04/189470.html</guid><wfw:comment>http://www.shnenglu.com/Streamlet/comments/189470.html</wfw:comment><comments>http://www.shnenglu.com/Streamlet/archive/2012/09/04/189470.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/Streamlet/comments/commentRss/189470.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Streamlet/services/trackbacks/189470.html</trackback:ping><description><![CDATA[     鎽樿: 鍦ㄤ笂涓綃囦腑錛屾垜浠疄鐜頒簡COM_INTERFACE瀹忥紝騫朵笖閲嶆柊鍐欎簡涓涓惈鏈塛ebBrowser鐨勭獥鍙c傚湪閭i噷鎴戜滑鐣欎簡涓棿灞侽leContainer銆備負浜嗛獙璇丱leContainer鐨勫彲鐢ㄦэ紝鐜板湪鏉ュ啓涓涓惈鏈塛indows Media Player錛堜笅鏂囩畝縐扳淲MP鈥濓級鎺т歡鐨勭獥鍙c?  WMP鎺т歡鐨勫鍣ㄧ被闄や簡IOleClientSite銆両OleInPlaceSite銆両OleInPlace...  <a href='http://www.shnenglu.com/Streamlet/archive/2012/09/04/189470.html'>闃呰鍏ㄦ枃</a><img src ="http://www.shnenglu.com/Streamlet/aggbug/189470.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Streamlet/" target="_blank">婧祦</a> 2012-09-04 22:16 <a href="http://www.shnenglu.com/Streamlet/archive/2012/09/04/189470.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>灞卞涓涓?ATL 鐨?COM_INTERFACEhttp://www.shnenglu.com/Streamlet/archive/2012/09/03/189321.html婧祦婧祦Mon, 03 Sep 2012 15:17:00 GMThttp://www.shnenglu.com/Streamlet/archive/2012/09/03/189321.htmlhttp://www.shnenglu.com/Streamlet/comments/189321.htmlhttp://www.shnenglu.com/Streamlet/archive/2012/09/03/189321.html#Feedback4http://www.shnenglu.com/Streamlet/comments/commentRss/189321.htmlhttp://www.shnenglu.com/Streamlet/services/trackbacks/189321.html闃呰鍏ㄦ枃

婧祦 2012-09-03 23:17 鍙戣〃璇勮
]]>
瀛︿範涓?ATL 鐨勭戶鎵塊摼澶勭悊http://www.shnenglu.com/Streamlet/archive/2012/09/02/189135.html婧祦婧祦Sun, 02 Sep 2012 05:56:00 GMThttp://www.shnenglu.com/Streamlet/archive/2012/09/02/189135.htmlhttp://www.shnenglu.com/Streamlet/comments/189135.htmlhttp://www.shnenglu.com/Streamlet/archive/2012/09/02/189135.html#Feedback1http://www.shnenglu.com/Streamlet/comments/commentRss/189135.htmlhttp://www.shnenglu.com/Streamlet/services/trackbacks/189135.html闃呰鍏ㄦ枃

婧祦 2012-09-02 13:56 鍙戣〃璇勮
]]>
鍒濇鎬ц兘嫻嬭瘯http://www.shnenglu.com/Streamlet/archive/2012/06/13/178704.html婧祦婧祦Wed, 13 Jun 2012 15:00:00 GMThttp://www.shnenglu.com/Streamlet/archive/2012/06/13/178704.htmlhttp://www.shnenglu.com/Streamlet/comments/178704.htmlhttp://www.shnenglu.com/Streamlet/archive/2012/06/13/178704.html#Feedback0http://www.shnenglu.com/Streamlet/comments/commentRss/178704.htmlhttp://www.shnenglu.com/Streamlet/services/trackbacks/178704.html鍥犱負鎺ヤ笅鍘昏鍋氫紭鍖栧伐浣滐紝鍦ㄦ涔嬪墠錛屽厛鍋氫笅綆鍗曠殑鎬ц兘嫻嬭瘯銆?/p>

姣旇緝鐨勫璞℃槸std::regex錛屾殏鏃跺彧姣旇緝涓ら」錛?/p>

1銆佽В鏋愭鍒欒〃杈懼紡鐨勯熷害

2銆佷嬌鐢ㄨВ鏋愬ソ鐨勬鍒欒〃杈懼紡鍘誨尮閰嶅瓧絎︿覆鐨勯熷害銆?/p>

嫻嬭瘯浠g爜濡備笅錛?span lang="EN-US"> 

SECTION_BEGIN(StdRegExParse100000);

PERFORMANCE_TEST_BEGIN(StdRegExParse100000);

for (int i = 0; i < 100000; ++i)

{

    wregex r;

    r.assign(L"http://([a-zA-Z0-9\\-]+.)+[a-zA-Z]+/");

}

PERFORMANCE_TEST_END(StdRegExParse100000);

SECTION_END();

 

SECTION_BEGIN(xlRegExpParse100000);

PERFORMANCE_TEST_BEGIN(xlRegExpParse100000);

for (int i = 0; i < 100000; ++i)

{

    RegExp r;

    r.Parse(L"http://([a-zA-Z0-9\\-]+.)+[a-zA-Z]+/");

}

PERFORMANCE_TEST_END(xlRegExpParse100000);

SECTION_END();

 

SECTION_BEGIN(StdRegExMatch100000);

{

    wregex r;

    r.assign(L"http://([a-zA-Z0-9\\-]+.)+[a-zA-Z]+/");

    PERFORMANCE_TEST_BEGIN(StdRegExMatch100000);

    for (int i = 0; i < 100000; ++i)

    {

        regex_match(L"http://w-1.w-2.w-3.streamlet.org/", r);

    }

    PERFORMANCE_TEST_END(StdRegExMatch100000);

}

SECTION_END();

 

SECTION_BEGIN(xlRegExpMatch100000);

{

    RegExp r;

    r.Parse(L"http://([a-zA-Z0-9\\-]+.)+[a-zA-Z]+/");

    PERFORMANCE_TEST_BEGIN(xlRegExpMatch100000);

    for (int i = 0; i < 100000; ++i)

    {

        r.Match(L"http://w-1.w-2.w-3.streamlet.org/");

    }

    PERFORMANCE_TEST_END(xlRegExpMatch100000);

}

SECTION_END();

 

鍓嶄袱鍒欐槸鍒嗗埆浣跨敤std::wregex鍜寈l::RegExp瑙f瀽"http://([a-zA-Z0-9\\-]+.)+[a-zA-Z]+/"鍗佷竾嬈★紝鍚庝袱鍒欐槸鎷挎潵鍖歸厤http://w-1.w-2.w-3.streamlet.org/鍗佷竾嬈°?/p>

緇撴灉濡備笅錛?/p>

image

鍖歸厤閫熷害宸緢澶氾紝瑙f瀽閫熷害宸笉澶氥?/p>

鑰冭檻鍒板湪瑙f瀽鈥?鈥濃?鈥濃?鈥濈殑鏃跺欙紝寮曞叆浜嗗緢澶毼佃竟錛屼簬鏄閭i儴鍒嗗仛鐐逛紭鍖栵紝鍘婚櫎涓嶅繀瑕佺殑蔚杈瑰拰鑺傜偣鏋勯狅紝鐒跺悗鍐嶆祴璇曪細

image

鍙互鐪嬪埌鏈夋墍鎻愰珮錛屼絾鏄В鏋愰熷害榪樻槸璺焥td:wregex鐨勫樊寰堝錛屽尮閰嶉熷害鏈夋槑鏄鵑鍏堛傜洰鍓嶅彧瑙f瀽鍒拔佃竟銆?NFA錛屽鏋滃啀鍋氱姸鎬佹満杞寲錛岃櫧鐒朵細鎻愰珮鍖歸厤閫熷害錛屽彲鏄В鏋愰熷害浼氳繘涓姝ヤ笅闄嶃傚洜姝わ紝涓寮濮嬪氨瑕佽冭檻浣跨敤涓縐嶆洿楂樻晥鐨勭姸鎬佹満瀛樺偍鏂規硶銆?/p>

榪欎袱澶╃潃鍑夌敓鐥呬簡錛屽ソ闅懼彈鍟娾︹?/p>

婧祦 2012-06-13 23:00 鍙戣〃璇勮
]]>
瑙f瀽姝e垯琛ㄨ揪寮忥紙涓夛級閲嶅http://www.shnenglu.com/Streamlet/archive/2012/06/08/178126.html婧祦婧祦Fri, 08 Jun 2012 15:35:00 GMThttp://www.shnenglu.com/Streamlet/archive/2012/06/08/178126.htmlhttp://www.shnenglu.com/Streamlet/comments/178126.htmlhttp://www.shnenglu.com/Streamlet/archive/2012/06/08/178126.html#Feedback2http://www.shnenglu.com/Streamlet/comments/commentRss/178126.htmlhttp://www.shnenglu.com/Streamlet/services/trackbacks/178126.html闃呰鍏ㄦ枃

婧祦 2012-06-08 23:35 鍙戣〃璇勮
]]>
瑙f瀽姝e垯琛ㄨ揪寮忥紙浜岋級瀛楃闆嗗悎http://www.shnenglu.com/Streamlet/archive/2012/06/04/177532.html婧祦婧祦Mon, 04 Jun 2012 14:19:00 GMThttp://www.shnenglu.com/Streamlet/archive/2012/06/04/177532.htmlhttp://www.shnenglu.com/Streamlet/comments/177532.htmlhttp://www.shnenglu.com/Streamlet/archive/2012/06/04/177532.html#Feedback0http://www.shnenglu.com/Streamlet/comments/commentRss/177532.htmlhttp://www.shnenglu.com/Streamlet/services/trackbacks/177532.html闃呰鍏ㄦ枃

婧祦 2012-06-04 22:19 鍙戣〃璇勮
]]>
瑙f瀽姝e垯琛ㄨ揪寮忥紙涓錛夋瑕?/title><link>http://www.shnenglu.com/Streamlet/archive/2012/06/03/177330.html</link><dc:creator>婧祦</dc:creator><author>婧祦</author><pubDate>Sun, 03 Jun 2012 07:16:00 GMT</pubDate><guid>http://www.shnenglu.com/Streamlet/archive/2012/06/03/177330.html</guid><wfw:comment>http://www.shnenglu.com/Streamlet/comments/177330.html</wfw:comment><comments>http://www.shnenglu.com/Streamlet/archive/2012/06/03/177330.html#Feedback</comments><slash:comments>7</slash:comments><wfw:commentRss>http://www.shnenglu.com/Streamlet/comments/commentRss/177330.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Streamlet/services/trackbacks/177330.html</trackback:ping><description><![CDATA[     鎽樿: 寮曡█ 鎯蟲悶姝e垯琛ㄨ揪寮忚В鏋愬櫒濂戒箙浜嗐傚墠闈㈢敱浜庝竴浜涘熀紜璁炬柦娌″噯澶囧ソ錛屾病娉曞紑濮嬪姩鎵嬨傜幇鍦?xlLib 閲屽ご鍑嗗鐨勫樊涓嶅浜嗭紝鍙互鐫鎵嬪疄鏂戒簡銆?  鍦ㄥ仛榪欎歡浜嬩箣鍓嶏紝璇諱簡濂藉嚑閬?@vczh 鐨勬枃绔犮婃瀯閫犲彲閰嶇疆璇嶆硶鍒嗘瀽鍣ㄣ嬨婃瀯閫犳鍒欒〃杈懼紡寮曟搸銆嬶紙http://www.shnenglu.com/vczh/archive/2008/05/22/50763.html錛夛紝緇欎簡寰堝ぇ鐨勫府鍔╁拰鍚彂錛屽湪榪欓噷琛ㄧず鎰熻阿銆傦紙...  <a href='http://www.shnenglu.com/Streamlet/archive/2012/06/03/177330.html'>闃呰鍏ㄦ枃</a><img src ="http://www.shnenglu.com/Streamlet/aggbug/177330.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Streamlet/" target="_blank">婧祦</a> 2012-06-03 15:16 <a href="http://www.shnenglu.com/Streamlet/archive/2012/06/03/177330.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>瑙f瀽姝e垯琛ㄨ揪寮忥紙涓錛夋瑕?/title><link>http://www.shnenglu.com/Streamlet/archive/2012/06/03/177330.html</link><dc:creator>婧祦</dc:creator><author>婧祦</author><pubDate>Sun, 03 Jun 2012 07:16:00 GMT</pubDate><guid>http://www.shnenglu.com/Streamlet/archive/2012/06/03/177330.html</guid><wfw:comment>http://www.shnenglu.com/Streamlet/comments/177330.html</wfw:comment><comments>http://www.shnenglu.com/Streamlet/archive/2012/06/03/177330.html#Feedback</comments><slash:comments>7</slash:comments><wfw:commentRss>http://www.shnenglu.com/Streamlet/comments/commentRss/177330.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Streamlet/services/trackbacks/177330.html</trackback:ping><description><![CDATA[     鎽樿: 寮曡█ 鎯蟲悶姝e垯琛ㄨ揪寮忚В鏋愬櫒濂戒箙浜嗐傚墠闈㈢敱浜庝竴浜涘熀紜璁炬柦娌″噯澶囧ソ錛屾病娉曞紑濮嬪姩鎵嬨傜幇鍦?xlLib 閲屽ご鍑嗗鐨勫樊涓嶅浜嗭紝鍙互鐫鎵嬪疄鏂戒簡銆?  鍦ㄥ仛榪欎歡浜嬩箣鍓嶏紝璇諱簡濂藉嚑閬?@vczh 鐨勬枃绔犮婃瀯閫犲彲閰嶇疆璇嶆硶鍒嗘瀽鍣ㄣ嬨婃瀯閫犳鍒欒〃杈懼紡寮曟搸銆嬶紙http://www.shnenglu.com/vczh/archive/2008/05/22/50763.html錛夛紝緇欎簡寰堝ぇ鐨勫府鍔╁拰鍚彂錛屽湪榪欓噷琛ㄧず鎰熻阿銆傦紙...  <a href='http://www.shnenglu.com/Streamlet/archive/2012/06/03/177330.html'>闃呰鍏ㄦ枃</a><img src ="http://www.shnenglu.com/Streamlet/aggbug/177330.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Streamlet/" target="_blank">婧祦</a> 2012-06-03 15:16 <a href="http://www.shnenglu.com/Streamlet/archive/2012/06/03/177330.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>瑙f瀽姝e垯琛ㄨ揪寮忥紙涓錛夋瑕?/title><link>http://www.shnenglu.com/Streamlet/archive/2012/06/03/177330.html</link><dc:creator>婧祦</dc:creator><author>婧祦</author><pubDate>Sun, 03 Jun 2012 07:16:00 GMT</pubDate><guid>http://www.shnenglu.com/Streamlet/archive/2012/06/03/177330.html</guid><wfw:comment>http://www.shnenglu.com/Streamlet/comments/177330.html</wfw:comment><comments>http://www.shnenglu.com/Streamlet/archive/2012/06/03/177330.html#Feedback</comments><slash:comments>7</slash:comments><wfw:commentRss>http://www.shnenglu.com/Streamlet/comments/commentRss/177330.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Streamlet/services/trackbacks/177330.html</trackback:ping><description><![CDATA[     鎽樿: 寮曡█ 鎯蟲悶姝e垯琛ㄨ揪寮忚В鏋愬櫒濂戒箙浜嗐傚墠闈㈢敱浜庝竴浜涘熀紜璁炬柦娌″噯澶囧ソ錛屾病娉曞紑濮嬪姩鎵嬨傜幇鍦?xlLib 閲屽ご鍑嗗鐨勫樊涓嶅浜嗭紝鍙互鐫鎵嬪疄鏂戒簡銆?  鍦ㄥ仛榪欎歡浜嬩箣鍓嶏紝璇諱簡濂藉嚑閬?@vczh 鐨勬枃绔犮婃瀯閫犲彲閰嶇疆璇嶆硶鍒嗘瀽鍣ㄣ嬨婃瀯閫犳鍒欒〃杈懼紡寮曟搸銆嬶紙http://www.shnenglu.com/vczh/archive/2008/05/22/50763.html錛夛紝緇欎簡寰堝ぇ鐨勫府鍔╁拰鍚彂錛屽湪榪欓噷琛ㄧず鎰熻阿銆傦紙...  <a href='http://www.shnenglu.com/Streamlet/archive/2012/06/03/177330.html'>闃呰鍏ㄦ枃</a><img src ="http://www.shnenglu.com/Streamlet/aggbug/177330.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Streamlet/" target="_blank">婧祦</a> 2012-06-03 15:16 <a href="http://www.shnenglu.com/Streamlet/archive/2012/06/03/177330.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍒╃敤宸叉湁鐨?bind 鏋勯?ScopeExithttp://www.shnenglu.com/Streamlet/archive/2012/05/20/175510.html婧祦婧祦Sun, 20 May 2012 15:07:00 GMThttp://www.shnenglu.com/Streamlet/archive/2012/05/20/175510.htmlhttp://www.shnenglu.com/Streamlet/comments/175510.htmlhttp://www.shnenglu.com/Streamlet/archive/2012/05/20/175510.html#Feedback7http://www.shnenglu.com/Streamlet/comments/commentRss/175510.htmlhttp://www.shnenglu.com/Streamlet/services/trackbacks/175510.html闃呰鍏ㄦ枃

婧祦 2012-05-20 23:07 鍙戣〃璇勮
]]>
璋冪敤綰﹀畾鎬葷粨http://www.shnenglu.com/Streamlet/archive/2012/05/12/174610.html婧祦婧祦Fri, 11 May 2012 17:36:00 GMThttp://www.shnenglu.com/Streamlet/archive/2012/05/12/174610.htmlhttp://www.shnenglu.com/Streamlet/comments/174610.htmlhttp://www.shnenglu.com/Streamlet/archive/2012/05/12/174610.html#Feedback0http://www.shnenglu.com/Streamlet/comments/commentRss/174610.htmlhttp://www.shnenglu.com/Streamlet/services/trackbacks/174610.html浠ュ墠鍋?Function 鐨勬椂鍊欐伆濂藉彇宸ч伩鍏嶆帀浜嗭紝榪欎簺澶╁湪鍋?Bind錛屼笉寰楀凡瑕佹妸姣忎釜璋冪敤綰﹀畾緗楀垪涓閬嶃傞『鎵嬫妸榪欎簺涓滆タ澶嶄範涓涓嬶紝鎬葷粨濡備笅鈥斺?/p>

錛堟墍鏈夊唴瀹歸拡瀵?VC 緙栬瘧騫沖彴錛?/p>

 

涓銆亁86

鍚嶇О 浼犲弬鏂瑰紡 鏍堟竻鐞?/td> C 璇█鍑芥暟閲嶅懡鍚嶏紙渚嬶細int func(int, double)錛?/td>
__cdecl 浠庡彸鑷沖乏鍘嬫爤 涓昏皟鍑芥暟 鍓嶉潰鍔犫淿鈥濓紙_func錛?/td>
__stdcall 浠庡彸鑷沖乏鍘嬫爤 琚皟鍑芥暟 鍓嶉潰鍔犫淿鈥濓紝鍚庨潰鍔犫淍鈥濆啀鍔犲弬鏁板崄榪涘埗瀛楄妭鏁幫紙_func@12錛?/td>
__fastcall 鍓嶄袱涓笉澶т簬DWORD闀垮害鐨勫弬鏁頒粠宸﹁嚦鍙沖垎鍒瓨鍒?ECX銆丒DX錛屽叾浣欎粠鍙寵嚦宸﹀帇鏍?/td> 琚皟鍑芥暟 鍓嶉潰鍔犫淍鈥濓紝鍚庨潰鍔犫淍鈥濆啀鍔犲弬鏁板崄榪涘埗瀛楄妭鏁幫紙@func@12錛?/td>
__thiscall ECX 瀛?this錛屽叾浣欎粠鍙寵嚦宸﹀帇鏍?/td> 琚皟鍑芥暟 浠呯敤浜?C++

 

浜屻亁64

鍚嶇О 浼犲弬鏂瑰紡 鏍堟竻鐞?/td>  
__fastcall 鍓嶅洓涓暣鏁?嫻偣鏁版斁鍦?RCX/XMM0銆丷DX/XMM1銆丷8/XMM2銆丷9/XMM3錛屽叾浣欏帇鏍堛?br>濡傛灉鍓?4 涓弬鏁板垎鍒負 int銆乫loat銆乴ong銆乨ouble錛屽畠浠皢鍒嗗埆琚瓨鍒?RCX銆乆MM1銆丷8銆乆MM3 琚皟鍑芥暟  

64浣嶇紪璇戠幆澧冧笅錛屽彲浠ユ寚瀹?__cdecl銆乢_stdcall銆乢_fastcall錛屼絾鏄紪璇戝櫒浼氬拷鐣ュ畠浠備袱涓樉紺烘寚瀹氫簡涓嶅悓璋冪敤綰﹀畾鐨勫嚱鏁頒笉鏋勬垚閲嶈澆錛岃屾瀯鎴愰噸瀹氫箟閿欒銆?/p>

婧祦 2012-05-12 01:36 鍙戣〃璇勮
]]>
C++ 鐨勫嚑縐?cast 榪愮畻絎﹀埌搴曟槸浠涔堬紵涓?C 椋庢牸鐨勭被鍨嬭漿鎹?(T)value 鏈変粈涔堝尯鍒拰鑱旂郴錛?/title><link>http://www.shnenglu.com/Streamlet/archive/2012/03/23/168690.html</link><dc:creator>婧祦</dc:creator><author>婧祦</author><pubDate>Fri, 23 Mar 2012 01:53:00 GMT</pubDate><guid>http://www.shnenglu.com/Streamlet/archive/2012/03/23/168690.html</guid><wfw:comment>http://www.shnenglu.com/Streamlet/comments/168690.html</wfw:comment><comments>http://www.shnenglu.com/Streamlet/archive/2012/03/23/168690.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/Streamlet/comments/commentRss/168690.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Streamlet/services/trackbacks/168690.html</trackback:ping><description><![CDATA[<p>緗戜笂鐨勬枃绔犱絾鍑℃湁鎻愬埌 static_cast銆乧onst_cast銆乺einterpret_cast銆乨ynamic_cast 鐨勶紝閮戒細璇噸蹇冮暱鐨勮錛屼粬浠厠鏈嶄簡 C 椋庢牸鐨勭被鍨嬭漿鎹㈢殑緙虹偣錛屽簲褰撲嬌鐢ㄥ畠浠?/p> <p>鍙槸錛孋 椋庢牸鐨勫埌搴曟湁浠涔堝潖澶勶紵C++鐨勮繖浜?cast 鍙堟湁浠涔堝ソ澶勫憿錛?/p> <p>鏄ㄥぉ浠ュ墠錛屾垜榪炶繖浜?cast 鏄粈涔堥兘涓嶇煡閬擄紙寰堟儹鎰э級銆傛槰澶╁洜涓哄悓浜嬩滑鎻愬埌榪欎歡浜嬶紝浜庢槸灝忓皬鐮旂┒浜嗕竴涓嬨備竴浜涘疄楠屼唬鐮佸涓嬶細</p> <p> </p> <p>1銆佹棤緇ф壙鐨勭被鍨嬭漿鎹?/p> <table style="border-collapse: collapse; mso-yfti-tbllook: 1184; mso-padding-alt: 0cm 0cm 0cm 0cm" class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes"> <td style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0cm; padding-left: 5.4pt; padding-right: 5.4pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0cm" valign="top" width="590"> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><font face="Consolas"><span style="font-family: ; color: " lang="EN-US"><font color="#0000ff"><font style="font-size: 9.5pt">class</font></font></span><span style="font-family: " lang="EN-US"><font style="font-size: 9.5pt"> A</font></span></font></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">{</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt"> </font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">};</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt"> </font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><font face="Consolas"><span style="font-family: ; color: " lang="EN-US"><font color="#0000ff"><font style="font-size: 9.5pt">class</font></font></span><span style="font-family: " lang="EN-US"><font style="font-size: 9.5pt"> B</font></span></font></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">{</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><font face="Consolas"><span style="font-family: ; color: " lang="EN-US"><font color="#0000ff"><font style="font-size: 9.5pt">public</font></font></span><span style="font-family: " lang="EN-US"><font style="font-size: 9.5pt">:</font></span></font></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    <span style="color: "><font color="#0000ff">operator</font></span> A()</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    {</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">        <span style="color: "><font color="#0000ff">return</font></span> A();</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    }</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">};</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt"> </font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><font face="Consolas"><span style="font-family: ; color: " lang="EN-US"><font color="#0000ff"><font style="font-size: 9.5pt">int</font></font></span><span style="font-family: " lang="EN-US"><font style="font-size: 9.5pt"> main()</font></span></font></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">{</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    B b;</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    A a = (A)b;                     <span style="color: "><font color="#008000">// </font></span></font></font></span><font color="#008000"><font style="font-size: 9.5pt"><span style="font-family: ; color: "><font face="瀹嬩綋">鎵ц</font></span></font><span style="font-family: ; color: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt"> operator A()</font></font></span></font><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    A a2 = <span style="color: "><font color="#0000ff">static_cast</font></span><A>(b);       <span style="color: "><font color="#008000">// </font></span></font></font></span><font color="#008000"><font style="font-size: 9.5pt"><span style="font-family: ; color: "><font face="瀹嬩綋">鎵ц</font></span></font><span style="font-family: ; color: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt"> operator A()</font></font></span></font><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    A a3 = <span style="color: "><font color="#0000ff">dynamic_cast</font></span><A>(b);      <span style="color: "><font color="#008000">// </font></span></font></font></span><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt" color="#008000">涓嶅厑璁?/font></font></span><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    A a4 = <span style="color: "><font color="#0000ff">reinterpret_cast</font></span><A>(b);  <span style="color: "><font color="#008000">// </font></span></font></font></span><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt" color="#008000">涓嶅厑璁?/font></font></span><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    A a5 = <span style="color: "><font color="#0000ff">const_cast</font></span><A>(b);        <span style="color: "><font color="#008000">// </font></span></font></font></span><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt" color="#008000">涓嶅厑璁?/font></font></span><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    </font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    <span style="color: "><font color="#0000ff">return</font></span> 0;</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">}</font></font></span></p></td></tr></tbody></table> <p> </p> <p>2銆乧onst_cast</p> <table style="border-collapse: collapse; mso-yfti-tbllook: 1184; mso-padding-alt: 0cm 0cm 0cm 0cm" class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes"> <td style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0cm; padding-left: 5.4pt; padding-right: 5.4pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0cm" valign="top" width="590"> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><font face="Consolas"><span style="font-family: ; color: " lang="EN-US"><font color="#0000ff"><font style="font-size: 9.5pt">struct</font></font></span><span style="font-family: " lang="EN-US"><font style="font-size: 9.5pt"> A</font></span></font></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">{</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    <span style="color: "><font color="#0000ff">int</font></span> m;</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt"> </font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    A(<span style="color: "><font color="#0000ff">int</font></span> m = 0) : m(m)</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    {</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt"> </font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    }</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">};</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt"> </font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><font face="Consolas"><span style="font-family: ; color: " lang="EN-US"><font color="#0000ff"><font style="font-size: 9.5pt">int</font></font></span><span style="font-family: " lang="EN-US"><font style="font-size: 9.5pt"> main()</font></span></font></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">{</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    <span style="color: "><font color="#0000ff">const</font></span> A a;</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt"> </font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    A a2 = (A)a;        <span style="color: "><font color="#008000">// </font></span></font></font></span><font color="#008000"><font style="font-size: 9.5pt"><span style="font-family: ; color: "><font face="瀹嬩綋">鍏佽錛?/font></span><span style="font-family: ; color: " lang="EN-US"><font face="Consolas">(A) </font></span><span style="font-family: ; color: "><font face="瀹嬩綋">鏈夋病鏈夐兘涓鏍鳳紝</font></span><span style="font-family: ; color: " lang="EN-US"><font face="Consolas">a2 </font></span></font><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt">鏄釜鏂板彉閲?/font></font></span></font><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    a2.m = 1;           <span style="color: "><font color="#008000">// a2 </font></span></font></font></span><font color="#008000"><font style="font-size: 9.5pt"><span style="font-family: ; color: "><font face="瀹嬩綋">鐨勬敼鍙樹笉褰卞搷</font></span></font><span style="font-family: ; color: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt"> a</font></font></span></font><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt"> </font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    A &a3 = (A &)a;     <span style="color: "><font color="#008000">// </font></span></font></font></span><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt" color="#008000">鍏佽</font></font></span><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    a3.m = 2;           <span style="color: "><font color="#008000">// </font></span></font></font></span><font color="#008000"><font style="font-size: 9.5pt"><span style="font-family: ; color: "><font face="瀹嬩綋">褰卞搷</font></span></font><span style="font-family: ; color: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt"> a</font></font></span></font><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><font color="#008000"><span style="font-family: ; color: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">//  A &a4 = a;          // </font></font></span><font style="font-size: 9.5pt"><span style="font-family: ; color: "><font face="瀹嬩綋">涓嶅厑璁革紝</font></span><span style="font-family: ; color: " lang="EN-US"><font face="Consolas">const </font></span></font><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt">闄愬畾璧蜂綔鐢ㄤ簡</font></font></span></font><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    A *pa5 = (A *)&a;   <span style="color: "><font color="#008000">// </font></span></font></font></span><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt" color="#008000">鍏佽</font></font></span><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    pa5->m = 3;         <span style="color: "><font color="#008000">// </font></span></font></font></span><font color="#008000"><font style="font-size: 9.5pt"><span style="font-family: ; color: "><font face="瀹嬩綋">褰卞搷</font></span></font><span style="font-family: ; color: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt"> a</font></font></span></font><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><font color="#008000"><span style="font-family: ; color: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">//  A *pa6 = &a;        // </font></font></span><font style="font-size: 9.5pt"><span style="font-family: ; color: "><font face="瀹嬩綋">涓嶅厑璁革紝</font></span><span style="font-family: ; color: " lang="EN-US"><font face="Consolas">const </font></span></font><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt">闄愬畾璧蜂綔鐢ㄤ簡</font></font></span></font><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt"> </font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><font color="#008000"><span style="font-family: ; color: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">//  A aa2 = const_cast<A>(a);       // </font></font></span><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt">涓嶅厑璁?/font></font></span></font><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt"> </font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    A &aa3 = <span style="color: "><font color="#0000ff">const_cast</font></span><A &>(a);    <span style="color: "><font color="#008000">// </font></span></font></font></span><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt" color="#008000">鍏佽</font></font></span><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    aa3.m = 2;                      <span style="color: "><font color="#008000">// </font></span></font></font></span><font color="#008000"><font style="font-size: 9.5pt"><span style="font-family: ; color: "><font face="瀹嬩綋">褰卞搷</font></span></font><span style="font-family: ; color: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt"> a</font></font></span></font><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    A *paa5 = <span style="color: "><font color="#0000ff">const_cast</font></span><A *>(&a);  <span style="color: "><font color="#008000">// </font></span></font></font></span><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt" color="#008000">鍏佽</font></font></span><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    paa5->m = 3;                    <span style="color: "><font color="#008000">// </font></span></font></font></span><font color="#008000"><font style="font-size: 9.5pt"><span style="font-family: ; color: "><font face="瀹嬩綋">褰卞搷</font></span></font><span style="font-family: ; color: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt"> a</font></font></span></font><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt"> </font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    <span style="color: "><font color="#0000ff">const</font></span> <span style="color: "><font color="#0000ff">int</font></span> i = 0;</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    <span style="color: "><font color="#0000ff">const</font></span> <span style="color: "><font color="#0000ff">int</font></span> &i2 = i;</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    <span style="color: "><font color="#0000ff">const</font></span> <span style="color: "><font color="#0000ff">int</font></span> *pi3 = &i;</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><font color="#008000"><span style="font-family: ; color: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">//  int j = const_cast<int>(i);         // </font></font></span><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt">涓嶅厑璁?/font></font></span></font><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    <span style="color: "><font color="#0000ff">int</font></span> &j2 = <span style="color: "><font color="#0000ff">const_cast</font></span><<span style="color: "><font color="#0000ff">int</font></span> &>(i2);    <span style="color: "><font color="#008000">// </font></span></font></font></span><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt" color="#008000">鍏佽</font></font></span><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    <span style="color: "><font color="#0000ff">int</font></span> *pj3 = <span style="color: "><font color="#0000ff">const_cast</font></span><<span style="color: "><font color="#0000ff">int</font></span> *>(pi3);  <span style="color: "><font color="#008000">// </font></span></font></font></span><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt" color="#008000">鍏佽</font></font></span><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt"> </font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    <span style="color: "><font color="#0000ff">return</font></span> 0;</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">}</font></font></span><span style="color: " lang="EN-US"></span></p></td></tr></tbody></table> <p>浠庣1鐐圭殑璇曢獙錛屽姞涓婂鐣岃祫鏂欑殑璇存槑錛岀湅涓婂幓const_case 鍙厑璁稿叿鏈変笉鍚宑v闄愬畾絎︾殑鍚岀被鍨嬩箣闂寸殑杞崲銆?<p>鍊煎緱娉ㄦ剰鐨勬槸錛屽鏋滅被鍨婣涓嶆槸鎸囬拡鎴栧紩鐢紝涓嶈兘浣跨敤const_cast錛堜嬌鐢ㄤ簡涔熸棤鎰忎箟錛岃 A a2 = (A)a 榪欎竴琛岋級 <p>鍦?const_cast 鍙互浣跨敤鐨勬儏褰紝(T)value 褰㈠紡閮藉彲浠ヤ嬌鐢紝(T)value 鍦ㄥ姛鑳戒笂瀹屽叏瑕嗙洊 const_cast銆?<p> </p> <p>2銆乺einterpret_cast</p> <table style="border-collapse: collapse; mso-yfti-tbllook: 1184; mso-padding-alt: 0cm 0cm 0cm 0cm" class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes"> <td style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0cm; padding-left: 5.4pt; padding-right: 5.4pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0cm" valign="top" width="590"> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><font face="Consolas"><span style="font-family: ; color: " lang="EN-US"><font color="#0000ff"><font style="font-size: 9.5pt">class</font></font></span><span style="font-family: " lang="EN-US"><font style="font-size: 9.5pt"> A</font></span></font></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">{</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><font face="Consolas"><span style="font-family: ; color: " lang="EN-US"><font color="#0000ff"><font style="font-size: 9.5pt">public</font></font></span><span style="font-family: " lang="EN-US"><font style="font-size: 9.5pt">:</font></span></font></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    <span style="color: "><font color="#0000ff">operator</font></span> <span style="color: "><font color="#0000ff">int</font></span> *()</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    {</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">        <span style="color: "><font color="#0000ff">return</font></span> <span style="color: "><font color="#0000ff">nullptr</font></span>;</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    }</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">};</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt"> </font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><font face="Consolas"><span style="font-family: ; color: " lang="EN-US"><font color="#0000ff"><font style="font-size: 9.5pt">int</font></font></span><span style="font-family: " lang="EN-US"><font style="font-size: 9.5pt"> main()</font></span></font></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">{</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    <span style="color: "><font color="#0000ff">int</font></span> i = 0;</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    <span style="color: "><font color="#0000ff">double</font></span> d = 1.0;</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    <span style="color: "><font color="#0000ff">int</font></span> *p = <span style="color: "><font color="#0000ff">nullptr</font></span>;</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    </font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><font color="#008000"><span style="font-family: ; color: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">//  int di = reinterpret_cast<int>(d);      // </font></font></span><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt">涓嶅厑璁?/font></font></span></font><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    <span style="color: "><font color="#0000ff">int</font></span> pi = <span style="color: "><font color="#0000ff">reinterpret_cast</font></span><<span style="color: "><font color="#0000ff">int</font></span>>(p);      <span style="color: "><font color="#008000">// </font></span></font></font></span><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt" color="#008000">鍏佽</font></font></span><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><font color="#008000"><span style="font-family: ; color: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">//  int pi2 = static_cast<int>(p);          // </font></font></span><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt">涓嶅厑璁?/font></font></span></font><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><font color="#008000"><span style="font-family: ; color: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">//  double id = reinterpret_cast<double>(i);// </font></font></span><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt">涓嶅厑璁?/font></font></span></font><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><font color="#008000"><span style="font-family: ; color: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">//  double pd = reinterpret_cast<double>(p);// </font></font></span><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt">涓嶅厑璁?/font></font></span></font><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    <span style="color: "><font color="#0000ff">int</font></span> *ip = <span style="color: "><font color="#0000ff">reinterpret_cast</font></span><<span style="color: "><font color="#0000ff">int</font></span> *>(i);   <span style="color: "><font color="#008000">// </font></span></font></font></span><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt" color="#008000">鍏佽</font></font></span><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><font color="#008000"><span style="font-family: ; color: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">//  int *ip2 = static_cast<int *>(i);       // </font></font></span><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt">涓嶅厑璁?/font></font></span></font><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><font color="#008000"><span style="font-family: ; color: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">//  int *dp = reinterpret_cast<int *>(d);   // </font></font></span><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt">涓嶅厑璁?/font></font></span></font><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt"> </font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    A a;</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    <span style="color: "><font color="#0000ff">int</font></span> *pa = (<span style="color: "><font color="#0000ff">int</font></span> *)a;                     <span style="color: "><font color="#008000">// </font></span></font></font></span><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt" color="#008000">鍏佽</font></font></span><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    <span style="color: "><font color="#0000ff">int</font></span> *pa2 = <span style="color: "><font color="#0000ff">static_cast</font></span><<span style="color: "><font color="#0000ff">int</font></span> *>(a);       <span style="color: "><font color="#008000">// </font></span></font></font></span><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt" color="#008000">鍏佽</font></font></span><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><font color="#008000"><span style="font-family: ; color: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">//  int *p2 = reinterpret_cast<int *>(a);   // </font></font></span><span style="font-family: ; color: "><font face="瀹嬩綋"><font style="font-size: 9.5pt">涓嶅厑璁?/font></font></span></font><span style="font-family: " lang="EN-US"></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt"> </font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">    <span style="color: "><font color="#0000ff">return</font></span> 0;</font></font></span></p> <p style="margin: 0cm 0cm 0pt; text-autospace: " class="MsoNormal"><span style="font-family: " lang="EN-US"><font face="Consolas"><font style="font-size: 9.5pt">}</font></font></span></p></td></tr></tbody></table> <p>鐪嬩笂鍘伙紝reinterpret_cast 鍙互鐞嗚В涓哄湪鎸囬拡鍜屾暟鍊間箣闂磋漿鎹㈢殑涓縐嶆柟寮忥紝鏃犲叧浠諱綍榪愮畻絎﹂噸杞斤紝浠呬粎鎶婃寚閽堣漿涓哄瓧闈㈠鹼紝鎴栬呮妸鏁板瓧杞負鎸囬拡錛岃漿鎹㈢殑榪囩▼涓兼病鏈変換浣曟敼鍙橈紝鍙槸鍛婅瘔緙栬瘧鍣ㄤ笉瑕佹姤綾誨瀷涓嶅尮閰嶈屽凡銆?<p>鍙﹀錛屽湪reinterpret_cast鍙互浣跨敤鐨勬儏褰紝static_cast 鏄笉鍙互浣跨敤鐨勶紝闄ら潪瀹氫箟浜嗙浉搴旂殑綾誨瀷杞崲榪愮畻絎︺?<p>鍦?reinterpret_cast 鍙互浣跨敤鐨勬儏褰紝(T)value 鐨勬柟寮忓悓鏍峰彲浠ュ畬鍏ㄨ儨浠伙紝(T)value 鍦ㄥ姛鑳戒笂瀹屽叏瑕嗙洊 reinterpret_cast銆?<p>  <p>dynamic_cast 鎴戣嚜璁や負榪樻槸鐞嗚В鐨勶紝灝變笉璇曚簡銆?<p>  <p><b>緇間笂錛屾垜鐨勭悊瑙e涓嬶細</b><b></b> <p><b>1</b><b>銆?/b><b>static_cast + const_cast + reinterpret_cast = (T)value</b> <p><b>C++ </b><b>鎶婂師鏉?/b><b>C</b><b>椋庢牸鐨勭殑榪欎笁涓?/b><b>cast</b><b>鎷嗗垎鎴愪簡涓変釜錛屼笁鑰呯浉浜掓浜ゃ傚ぇ澶氭暟鎯呭喌涓嬶紝搴旇鏄?/b><b> static_cast </b><b>鍦ㄥ彇浠g潃</b><b> (T)value</b><b>錛涘彧鏄湪鍘婚櫎</b><b> cv </b><b>闄愬畾絎︾殑鏃跺欙紝鎹㈢敤</b><b> const_cast</b><b>錛涘湪鍙栨寚閽堝瓧闈㈠肩殑鏃跺欙紝鎹㈢敤</b><b> reinterpret_cast</b><b>銆傜被鍨嬭漿鎹㈣繍綆楃 </b><b>operator T() </b><b>鐢?</b><b>static_cast </b><b>璐熻矗鎵ц銆?/b><b></b> <p><b>2</b><b>銆?/b><b>dynamic_cast </b><b>鏄?</b><b>C++ </b><b>鏂板鐨勶紝鐢ㄤ簬澶氭佺殑鎯呭艦錛屼笖鍙厑璁歌漿鎹㈠叿鏈夊鎬佸叧緋葷殑緇ф壙鏍戜笂鐨勭被鍨嬬殑鎸囬拡鍜屽紩鐢紝涓嶅厑璁歌漿鎹㈢被鍨嬫湰韜傚畠涓嶆槸閽堝</b><b> (T)value</b><b>鑰屽嚭鐜扮殑錛屼袱鑰呮病鏈変換浣曠珵浜夊叧緋伙紝鍙槸鍙栧喅浜庝笉鍚岀殑闇姹傘?/b><b></b> <p><b></b> <p>錛堜笉鐭ヨ繖鏍風悊瑙f槸鍚︽紜紝璇鋒壒璇勬寚姝錛?<p>鑷充簬緗戜笂鎺ㄥ磭鐢ㄦ柊鍐欐硶錛屾槸涓嶆槸涓轟簡鏇寸粏鍖栬屽鏄撶悊瑙o紵鏈夋病鏈変粈涔堟槸 (T)value 鍋氫笉鍒拌?*_cast 鑳藉仛鍒扮殑錛熸垨鑰呭弽榪囨潵錛?<img src ="http://www.shnenglu.com/Streamlet/aggbug/168690.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Streamlet/" target="_blank">婧祦</a> 2012-03-23 09:53 <a href="http://www.shnenglu.com/Streamlet/archive/2012/03/23/168690.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>緲昏瘧涓鑺?C++03 鏍囧噯鏂囨。錛?.10 宸﹀煎拰鍙沖鹼級錛岃鎵硅瘎鎸囨~http://www.shnenglu.com/Streamlet/archive/2012/02/29/166816.html婧祦婧祦Wed, 29 Feb 2012 14:50:00 GMThttp://www.shnenglu.com/Streamlet/archive/2012/02/29/166816.htmlhttp://www.shnenglu.com/Streamlet/comments/166816.htmlhttp://www.shnenglu.com/Streamlet/archive/2012/02/29/166816.html#Feedback0http://www.shnenglu.com/Streamlet/comments/commentRss/166816.htmlhttp://www.shnenglu.com/Streamlet/services/trackbacks/166816.html3.10 Lvalues and rvalues [basic.lval]

宸﹀煎拰鍙沖?/font>

1 Every expression is either an lvalue or an rvalue.

琛ㄨ揪寮忎笉鏄乏鍊煎氨鏄彸鍊箋?/font>

2 An lvalue refers to an object or function. Some rvalue expressions鈥攖hose of class or cv-qualified class type鈥攁lso refer to objects. 47)

宸﹀兼槸鎸囦竴涓璞℃垨鑰呭嚱鏁般傛煇浜涘彸鍊鹼紙閭d簺甯︽垨涓嶅甫cv闄愬畾絎︾殑綾葷被鍨嬶級涔熸槸瀵硅薄銆?/font>

3 [Note:
some built-in operators and function calls yield lvalues. [Example: if E is an expression of pointer type, then *E is an lvalue expression referring to the object or function to which E points. As another example, the function
int& f();
yields an lvalue, so the call f() is an lvalue expression. ] ]

[娉ㄦ剰錛氭煇浜涘唴緗繍綆楃浠ュ強涓浜涘嚱鏁拌皟鐢ㄤ細榪斿洖宸﹀箋俒渚?錛氬鏋?E 鏄竴涓寚閽堢被鍨嬬殑琛ㄨ揪寮忥紝閭d箞 *E 鏄竴涓乏鍊艱〃杈懼紡錛屾寚紺烘寚閽?E 鎵鎸囧悜鐨勯偅涓璞℃垨鑰呭嚱鏁般備緥2錛氬嚱鏁?br>int& f();
榪斿洖宸﹀鹼紝鎵浠ュ嚱鏁拌皟鐢?f() 鏄竴涓乏鍊艱〃杈懼紡銆俔 ]

4 [Note: some built-in operators expect lvalue operands. [Example: built-in assignment operators all expect their left hand operands to be lvalues. ] Other built-in operators yield rvalues, and some expect them. [Example: the unary and binary + operators expect rvalue arguments and yield rvalue results. ] The discussion of each built-in operator in clause 5 indicates whether it expects lvalue operands and whether it yields an lvalue. ]

[娉ㄦ剰錛氭煇浜涘唴緗繍綆楃闇瑕佸乏鍊兼搷浣滄暟銆俒渚嬶細鎵鏈夊唴緗殑璧嬪艱繍綆楃鐨勫乏鎿嶄綔鏁伴兘蹇呴』鏄乏鍊箋俔 鏈変簺鍐呯疆榪愮畻絎︿細榪斿洖鍙沖肩粨鏋滐紝鏈変簺浼氶渶瑕佸彸鍊兼搷浣滄暟銆俒渚嬶細涓鍏冭繍綆楃鈥?鈥濆拰浜屽厓榪愮畻絎︹?鈥濋兘闇瑕佸彸鍊兼搷浣滄暟錛屽茍涓旇繑鍥炲彸鍊肩粨鏋溿俔 鎴戜滑鍦ㄦ潯嬈?5 涓細瀵規墍鏈夊唴緗繍綆楃榪涜璁ㄨ錛屾寚鍑哄畠浠殑鎿嶄綔鏁板拰榪斿洖緇撴灉鏄乏鍊艱繕鏄彸鍊箋俔

5 The result of calling a function that does not return a reference is an rvalue. User defined operators are functions, and whether such operators expect or yield lvalues is determined by their parameter and return
types.

璋冪敤榪斿洖鍊間負闈炲紩鐢ㄧ被鍨嬬殑鍑芥暟錛岀粨鏋滄槸鍙沖箋傜敤鎴瘋嚜瀹氫箟鐨勮繍綆楃涔熸槸鍑芥暟錛岃繖浜涜繍綆楃鐨勬搷浣滄暟浠ュ強緇撴灉鏄乏鍊艱繕鏄彸鍊鹼紝鍙栧喅浜庯紙榪愮畻絎﹂噸杞斤級鍑芥暟鐨勫弬鏁板拰榪斿洖鍊肩被鍨嬨?/font>

6 An expression which holds a temporary object resulting from a cast to a nonreference type is an rvalue (this includes the explicit creation of an object using functional notation (5.2.3)).

瀵歸潪寮曠敤綾誨瀷鐨勮漿鎹㈣〃杈懼紡錛堝寘鎷嬌鐢ㄥ嚱鏁板紡鐨勮鍙瘋繘琛屾樉紺哄垱寤猴級鏄彸鍊鹼紝瀹冨皢榪斿洖涓涓復鏃跺璞°?/font>


__________________
47) Expressions such as invocations of constructors and of functions that return a class type refer to objects, and the implementation can invoke a member function upon such objects, but the expressions are not lvalues.

鏈変簺琛ㄨ揪寮忥紝姣斿璋冪敤鏋勯犲嚱鏁扮殑琛ㄨ揪寮忥紝浠ュ強璋冪敤榪斿洖綾葷被鍨嬬殑鍑芥暟鐨勮〃杈懼紡錛屽畠浠篃鏄璞★紝涓斿彲浠ュ瀹冧滑璋冪敤鎴愬憳鍑芥暟錛屼絾榪欑琛ㄨ揪寮忎笉鏄乏鍊箋?/font>

____________________________________鍗庝附鐨勫垎欏電____________________________________

 

7 Whenever an lvalue appears in a context where an rvalue is expected, the lvalue is converted to an rvalue; see 4.1, 4.2, and 4.3.

濡傛灉鍦ㄤ竴涓渶瑕佸彸鍊肩殑鍦哄悎鍑虹幇浜嗗乏鍊鹼紝榪欎釜宸﹀煎皢琚漿鎹㈡垚鍙沖箋?br>瑙?4.1銆?.2銆?.3銆?/font>

8 The discussion of reference initialization in 8.5.3 and of temporaries in 12.2 indicates the behavior of lvalues and rvalues in other significant contexts.

12.2 涓叧浜庡紩鐢ㄧ殑鍒濆鍖栧拰鍏充簬涓存椂瀵硅薄鐨勮璁猴紝涔熸寚鍑轟簡宸﹀彸鍊煎湪鍏朵粬閲嶈鍦哄悎鐨勮涓恒?/font>

9 Class rvalues can have cv-qualified types; non-class rvalues always have cv-unqualified types. Rvalues shall always have complete types or the void type; in addition to these types, lvalues can also have incomplete types.

綾葷被鍨嬬殑鍙沖煎彲浠ュ叿鏈?cv 闄愬畾絎︼紱闈炵被綾誨瀷鐨勫彸鍊間笉鑳借 cv 闄愬畾絎︿慨楗般傚彸鍊奸氬父鏄畬鏁寸被鍨嬫垨鑰?void 綾誨瀷錛岃屽浜庡乏鍊兼潵璇達紝闄や簡瀹屾暣綾誨瀷鍜?void 綾誨瀷澶栵紝榪樺彲浠ユ槸涓嶅畬鏁寸被鍨嬨?/font>

10 An lvalue for an object is necessary in order to modify the object except that an rvalue of class type can also be used to modify its referent under certain circumstances. [Example: a member function called for an object (9.3) can modify the object. ]

閫氬父鎯呭喌涓嬶紝濡傛灉瑕佷慨鏀逛竴涓璞★紝瀹冨繀欏繪槸宸﹀箋備絾鍦ㄦ煇浜涚壒瀹氱殑鍦哄悎錛屽彸鍊煎艦寮忕殑綾誨璞′篃鍙互琚慨鏀廣俒渚嬶細璋冪敤涓涓璞$殑鎴愬憳鍑芥暟錛?.3錛夛紝鍙互淇敼瀵硅薄鏈韓銆俔

11 Functions cannot be modified, but pointers to functions can be modifiable.

鍑芥暟錛堝璞★級涓嶈兘錛堝湪榪愯鏃訛級琚慨鏀癸紝浣嗘槸鍑芥暟鎸囬拡鍙互銆?/font>

12 A pointer to an incomplete type can be modifiable. At some point in the program when the pointed to type is complete, the object at which the pointer points can also be modified.

鎸囧悜涓涓笉瀹屾暣綾誨瀷鐨勬寚閽堝彲鑳芥槸鍙慨鏀圭殑銆傚綋榪欎釜琚寚鍚戠殑綾誨瀷鏌愭椂鏌愬埢鎴愪負瀹屾暣綾誨瀷鍚庯紝榪欎釜鎸囬拡鎵鎸囧悜鐨勯偅涓璞′篃鏄彲淇敼鐨勩?/font>

13 The referent of a const-qualified expression shall not be modified (through that expression), except that if it is of class type and has a mutable component, that component can be modified (7.1.5.1).

琚?const 闄愬畾鐨勮〃杈懼紡鎵瀵瑰簲鐨勫璞′笉鑳斤紙閫氳繃璇ヨ〃杈懼紡錛夎淇敼錛涢櫎闈炶繖涓璞℃槸綾葷被鍨嬪茍涓斿惈鏈?mutable 鎴愬憳錛屾鏃惰 mutable 鎴愬憳鍙互琚慨鏀廣?/font>

14 If an expression can be used to modify the object to which it refers, the expression is called modifiable. A program that attempts to modify an object through a nonmodifiable lvalue or rvalue expression is illformed.

濡傛灉涓涓〃杈懼紡鍙互琚敤鏉ヤ慨鏀規琛ㄨ揪寮忓搴旂殑瀵硅薄錛岄偅涔堣繖涓〃杈懼紡琚О涓哄彲淇敼鐨勩備紒鍥鵑氳繃涓涓笉鍙慨鏀圭殑宸﹀艱呭彸鍊艱〃杈懼紡鍘諱慨鏀逛竴涓璞★紝鏄潪娉曠殑銆?/font>

15 If a program attempts to access the stored value of an object through an lvalue of other than one of the following types the behavior is undefined 48):
鈥?the dynamic type of the object,
鈥?a cv-qualified version of the dynamic type of the object,
鈥?a type that is the signed or unsigned type corresponding to the dynamic type of the object,
鈥?a type that is the signed or unsigned type corresponding to a cv-qualified version of the dynamic type of
the object,
鈥?an aggregate or union type that includes one of the aforementioned types among its members (including,
recursively, a member of a subaggregate or contained union),
鈥?a type that is a (possibly cv-qualified) base class type of the dynamic type of the object,
鈥?a char or unsigned char type.

濡傛灉紼嬪簭閫氳繃涓嬪垪綾誨瀷涔嬪綾誨瀷鐨勫乏鍊艱闂竴涓璞$殑鍊鹼紝鍏惰涓烘槸鏈畾涔夌殑錛?/font>

鈥斺斿璞$殑鍔ㄦ佺被鍨嬶紱
鈥斺擟V 闄愬畾鐨勫璞″姩鎬佺被鍨嬶紱
鈥斺斿璞$殑鍔ㄦ佺被鍨嬪搴旂殑鏈夌鍙鋒垨鏃犵鍙風被鍨嬶紱
鈥斺擟V 闄愬畾鐨勫璞″姩鎬佺被鍨嬫湁絎﹀彿鎴栨棤絎﹀彿綾誨瀷錛?br>鈥斺斾竴涓垚鍛樹腑鍚湁鑱氬悎鎴栬呰仈鍚堢被鍨嬬殑鑱氬悎鎴栬呰仈鍚堢被鍨嬶紙鍖呮嫭閫掑綊褰㈠紡鐨勫畾涔変互鍙婃垚鍛樹腑鏈夊瓙鑱氬悎綾誨瀷鎴栬呭寘鍚竴涓仈鍚堬級
鈥斺斿璞$殑鍔ㄦ佺被鍨嬬殑鍩虹被綾誨瀷錛堝彲浠ヨ cv 闄愬畾絎︿慨楗幫級
鈥斺攃har 鎴?unsigned char 綾誨瀷


__________________
48) The intent of this list is to specify those circumstances in which an object may or may not be aliased.
緇欏嚭榪欎喚鍒楄〃鐨勭洰鐨勬槸鎸囨槑涓浜涚壒瀹氭儏褰紝鍦ㄨ繖浜涙儏褰笅瀵硅薄鍙兘琚噸鍙狅紝浣嗕篃鏈夊彲鑳戒笉鏄紝鎴戜滑鏃犳硶棰勭煡銆?/font>

____________________________________鍗庝附鐨勫垎闅旂____________________________________

 

浠ヤ笂錛屾眰鎸囨錛屽寘鎷悊瑙h鍖哄拰璇█緇勭粐涓嶅悎鐞嗙殑錛屾榪庢寚鍑簙 ^_^



婧祦 2012-02-29 22:50 鍙戣〃璇勮
]]>
濡傛灉瑕佹嫙瀹氫竴浠戒唬鐮佽鑼冿紝鍝簺鍐呭搴旇鍒楀叆錛?/title><link>http://www.shnenglu.com/Streamlet/archive/2011/07/12/150791.html</link><dc:creator>婧祦</dc:creator><author>婧祦</author><pubDate>Tue, 12 Jul 2011 14:22:00 GMT</pubDate><guid>http://www.shnenglu.com/Streamlet/archive/2011/07/12/150791.html</guid><wfw:comment>http://www.shnenglu.com/Streamlet/comments/150791.html</wfw:comment><comments>http://www.shnenglu.com/Streamlet/archive/2011/07/12/150791.html#Feedback</comments><slash:comments>17</slash:comments><wfw:commentRss>http://www.shnenglu.com/Streamlet/comments/commentRss/150791.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Streamlet/services/trackbacks/150791.html</trackback:ping><description><![CDATA[<p>濡傞錛屽ぇ鑷寸湅浜嗕笅緗戜笂鑳芥壘鍒扮殑涓浜涜鑼冿紝瑙夊緱澶т綋鏈夎繖涔堜笁涓柟闈㈠惂錛屼竴涓槸鎺掔増鏂歸潰鐨勶紝涓涓槸鍛藉悕鏂歸潰鐨勶紝涓涓槸涔﹀啓閫昏緫鏂歸潰鐨勩?/p> <p>鎺掔増鏂歸潰鐨勫ぇ姒傛湁錛屽浣曠緝榪涳紝濡備綍浣跨敤絀烘牸銆佹崲琛岋紝絳夌瓑銆傚懡鍚嶆柟闈㈢殑鍖呮嫭鍙橀噺銆佸嚱鏁般佺被銆佹枃浠剁殑鍙栧悕絳夌瓑銆備功鍐欓昏緫鏂歸潰鐨勫氨姣旇緝澶氫簡錛屽彲鑳藉寘鎷細<br>鏄惁鍏ㄩ潰浣跨敤寮傚父銆佸嚭閿欏鐞嗚祫婧愭竻鐞嗗浣曠粍緇囥佸浣曞埄鐢ㄧ紪璇戞彁紺洪槻姝㈠父瑙侀敊璇︹?/p> <p>涓鏃墮棿鍒椾笉鍏ㄣ傜綉涓婂父瑙佺殑鏂囨。鎴戜細鍙傝冪殑銆傞櫎姝や箣澶栵紝鎯充粠澶у榪欓噷寰佹眰涓嬶紝浠ヤ笂鍑犱釜澶ф柟闈箣澶栵紝榪樻湁娌℃湁姣旇緝閲嶈鐨勬柟闈紵澶у鏃ュ父宸ヤ綔涓湁娌℃湁閬囧埌涓浜涚壒鍒笇鏈涘埆浜轟篃浣跨敤鍜岃嚜宸變竴鏍風殑鏂瑰紡鍋氱殑浜嬶紵浠ュ強錛屽摢浜涜瀹氭瘮杈冨鏄撹鎺ㄥ姩錛熷摢浜涜瀹氫笉瀹規槗琚帹鍔紵濡傛灉鏈変竴涓鍒欏己鍔犲湪浣犲ご涓婏紝浣犱細鏈夋庢牱鐨勫績鐞嗭紵絳夌瓑鈥︹?/p> <p>濡傛灉鎮ㄦ湁鎯蟲硶錛岃鍥炲涓嬶紝鎴戜滑璁ㄨ璁ㄨ^_^</p> <p>----------</p> <p>欏轟究鍐嶉棶涓棶棰橈紝Windows 涓婄殑寮鍙戯紝澶у鍠滄鍔ㄦ侀摼鎺?CRT錛?MD銆?MDd錛?榪樻槸闈欐侀摼鎺?CRT錛?MT銆?MTd錛夛紵涓轟粈涔堬紵涓漢鍊懼悜浜庡摢縐嶏紵鍦ㄥ叕鍙擱噷鍙堟槸鎬庢牱鍋氱殑錛?/p><img src ="http://www.shnenglu.com/Streamlet/aggbug/150791.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Streamlet/" target="_blank">婧祦</a> 2011-07-12 22:22 <a href="http://www.shnenglu.com/Streamlet/archive/2011/07/12/150791.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>濡備綍鍐?鎵ц鑰楁椂浠誨姟鐨勩佸彲闅忔椂绔嬪嵆閫鍑虹殑鍑芥暟 鍛紵http://www.shnenglu.com/Streamlet/archive/2011/05/26/147133.html婧祦婧祦Wed, 25 May 2011 16:36:00 GMThttp://www.shnenglu.com/Streamlet/archive/2011/05/26/147133.htmlhttp://www.shnenglu.com/Streamlet/comments/147133.htmlhttp://www.shnenglu.com/Streamlet/archive/2011/05/26/147133.html#Feedback29http://www.shnenglu.com/Streamlet/comments/commentRss/147133.htmlhttp://www.shnenglu.com/Streamlet/services/trackbacks/147133.html濡傞銆?/p>

紼嶅井瑙i噴涓嬶紝鍥犱負鏈夊彲鑳芥湁浜轟細璇細錛氭斁鏂扮嚎紼嬮噷闈㈠幓涓嶅氨鍙互浜嗭紵榪欐病鏈夎В鍐抽棶棰樸傚姝ょ殑璇濓紝浣犻偅涓嚎紼嬪嚱鏁版庝箞鍐欙紵鎴栬呯嚎紼嬪嚱鏁伴噷璋冪敤鐨勬煇涓換鍔″嚱鏁版庝箞鍐欙紵鎬諱箣錛屽綰跨▼铏界劧鎬繪槸鍑虹幇鍦ㄨ繖浜涢棶棰樼殑瑙e喅鏂規涓紝浣嗕笉鏄綰跨▼瑙e喅浜嗚繖涓棶棰樸傚棷鈥︹︿笉鐭ラ亾璇存竻妤氫簡娌★紵

鐩墠鎴戝績閲岀殑絳旀鍙湁榪欎竴縐嶆ā寮忥細

bool DoTask(HANDLE hQuitSignal)
{
    while (!QuitCondition)
    {
        if (WaitForSingleObject(hQuitSignal, 0) == WAIT_OBJECT_0)
        {
            return false;
        }

        // Do something
    }

    return true;
}

鍏朵腑錛屸?/ Do something鈥濋儴鍒嗚緇嗗寲鍒扮灛闂存墽琛屽畬鎴愮殑緇嗗害銆?/p>

浣嗘槸鎴戝緢鍥版儜鐨勬槸錛屽鏋滆繖浜涗換鍔″緢綣侀噸錛岄毦閬撴垜蹇呴』姣忚繘琛屼竴浜涙搷浣滃氨 if (WaitForSingleObject(hQuitSignal, 0) == WAIT_OBJECT_0) 媯鏌ヤ笅鍚楋紵榪欐牱宀備笉鏄繖縐嶆嫻嬩唬鐮佸厖鏂ュ湪浠誨姟涓簡錛?/p>

涓嶇煡鍚勪綅鏈変綍緇忛獙鍜屼綋浼氾紝姹傛暀~



婧祦 2011-05-26 00:36 鍙戣〃璇勮
]]>
涓涓畝鍗曠殑 Tuple 瀹炵幇http://www.shnenglu.com/Streamlet/archive/2011/04/28/145249.html婧祦婧祦Thu, 28 Apr 2011 14:05:00 GMThttp://www.shnenglu.com/Streamlet/archive/2011/04/28/145249.htmlhttp://www.shnenglu.com/Streamlet/comments/145249.htmlhttp://www.shnenglu.com/Streamlet/archive/2011/04/28/145249.html#Feedback8http://www.shnenglu.com/Streamlet/comments/commentRss/145249.htmlhttp://www.shnenglu.com/Streamlet/services/trackbacks/145249.html鏍囬涓鐨?Tuple 鏄寚綾諱技 boost::tuple 榪欐牱鐨勮鏂姐?/p>

寰堝鏃跺欐垜浠渶瑕佽繑鍥?浼犲叆涓鍫嗗弬鏁幫紝鎵浠ヤ笉寰椾笉姣忔瀹氫箟涓浜涗負浜嗘暟鎹紶杈撶殑緇撴瀯銆俆uple 灝辨槸鐢ㄦ潵瑙e喅榪欎竴闂鐨勶紝瀹冩彁渚涘嵆鏃舵瀯閫犱竴涓繖鏍風殑緇撴瀯浣撶殑鍔熻兘銆傝屾墍浠樺嚭鐨勪唬浠鋒槸錛屼撫澶卞悇涓垚鍛樼殑鏄庣‘鍚箟錛屽彧鐣欎笅鎴愬憳鐨勫簭鍙楓?/p>

涓や釜鍏冪礌鐨?Tuple 灝辨槸 Pair錛屽 std::pair銆備笅闈㈡垜浠潵寤虹珛閽堝鏈夐檺涓厓绱犵殑 Tuple銆傚浜庝竴涓厓绱犮佷袱涓厓绱犮佷笁涓厓绱狅紝鎴戜滑鍙互鍒嗗埆濡備笅瀹炵幇錛?/p>

template <typename T0>
struct Tuple
{
    T0 _0;
};

template <typename T0, typename T1>
struct Tuple
{
    T0 _1;
    T1 _1;
};

template <typename T0, typename T1, typename T2>
struct Tuple
{
    T0 _1;
    T1 _1;
    T2 _2;
};

浣嗘槸榪欎笁涓啓鍦ㄤ竴璧鳳紝灝變細鍑洪敊銆備負姝わ紝鎴戜滑鍙互鍏堝畾涔変竴涓惈瓚沖澶氭ā鐗堝弬鏁扮殑 Tuple錛岀劧鍚庝笂闈笁涓垎鍒綔涓哄亸鐗瑰寲鐗堟湰錛?/p>

template <typename T0 = NullType, typename T1= NullType, typename T2= NullType, typename T3= NullType, typename T4= NullType>
struct Tuple;

template <typename T0>
struct Tuple<T0>
{
    T0 _0;
};

template <typename T0, typename T1>
struct Tuple<T0, T1>
{
    T0 _1;
    T1 _1;
};

template <typename T0, typename T1, typename T2>
struct Tuple<T0, T1, T2>
{
    T0 _1;
    T1 _1;
    T2 _2;
};

濡傛灉鎵嬪啓鐨勮瘽錛岃繖涔熷彲浠ャ傚鏋滀笉鎵嬪啓錛屾垜浠彲浠ョ戶緇敤涔嬪墠銆?a href="http://www.shnenglu.com/Streamlet/archive/2011/01/17/138693.html" target="_blank">C++ 涓?Function 瀵硅薄鐨勫疄鐜幫紙涓嬶級銆嬩腑鐨勫畯寰幆鏂規銆傛鏂規鐨勪竴涓寮忕増鏈 xlMacros.h銆?/p>

瀹氫箟甯﹂粯璁ゅ?NullType 鐨勬ā鐗堝弬鏁板0鏄庡簭鍒楀涓嬶細

#define XL_TUPLE_TYPENAME_DECLARE_NT_PATTERN(n)     typename T##n = NullType
#define XL_TUPLE_TYPENAME_DECLARE_NT(n)             XL_REPZ(XL_TUPLE_TYPENAME_DECLARE_NT_PATTERN, n, XL_COMMA)

瀹冨皢琚睍寮涓猴細 typename T0 = NullType, typename T1 = NullType, typename T2 = NullType, 鈥? typename Tn = NullType

瀹氫箟涓嶅甫榛樿鍊肩殑妯$増鍙傛暟澹版槑搴忓垪濡備笅錛?/p>

#define XL_TUPLE_TYPENAME_DECLARE_PATTERN(n)        typename T##n
#define XL_TUPLE_TYPENAME_DECLARE(n)                XL_REPZ(XL_TUPLE_TYPENAME_DECLARE_PATTERN, n, XL_COMMA)

瀹冨皢琚睍寮涓猴細typename T0, typename T1, typename T2, 鈥? typename Tn

瀹氫箟妯$増鍙傛暟浣跨敤搴忓垪濡備笅錛?/p>

#define XL_TUPLE_TYPENAME_LIST_PATTERN(n)           T##n
#define XL_TUPLE_TYPENAME_LIST(n)                   XL_REPZ(XL_TUPLE_TYPENAME_LIST_PATTERN, n, XL_COMMA)

瀹冨皢琚睍寮涓?T0, T1, T2, 鈥? Tn

瀹氫箟鎴愬憳鍙橀噺澹版槑搴忓垪濡備笅錛?/p>

#define XL_TUPLE_MEMBER_DECLARE_PATTERN(n)          T##n _##n;
#define XL_TUPLE_MEMBER_DECLARE(n)                  XL_REPZ(XL_TUPLE_MEMBER_DECLARE_PATTERN, n, XL_NIL)

瀹冨皢琚睍寮涓猴細T0 _0; T1 _1; T2 _2; 鈥?Tn _n;

鐜板湪鎴戜滑寮濮嬬粍瑁咃細

#ifndef XL_TUPLE_DEFINE_MAX
#define XL_TUPLE_DEFINE_MAX  20
#endif

template <XL_TUPLE_TYPENAME_DECLARE_NT(XL_INC(XL_TUPLE_DEFINE_MAX))>
struct Tuple;

template <XL_TUPLE_TYPENAME_DECLARE(n)>
struct Tuple<XL_TUPLE_TYPENAME_LIST(n)>
{
    XL_TUPLE_MEMBER_DECLARE(n)
};

鍏朵腑鍚庝竴涓繕甯︽湁瀹忓弬鏁?n銆傛垜浠皢榪欐暣涓涓畾涔夋垚瀹忥紝鐒跺悗榪涜瀹忓驚鐜細

#define XL_TUPLE_IMPLEMENT_PATTERN(n)   \
                                        \
template <XL_TUPLE_TYPENAME_DECLARE(n)> \
struct Tuple<XL_TUPLE_TYPENAME_LIST(n)> \
{                                       \
    XL_TUPLE_MEMBER_DECLARE(n)          \
};                                      \

#define XL_TUPLE_IMPLEMENT(n)    XL_REPY(XL_TUPLE_IMPLEMENT_PATTERN, n, XL_NIL)

涔嬪悗鍐嶄嬌鐢ㄨ繖涓畯錛?/p>

XL_TUPLE_IMPLEMENT(XL_TUPLE_DEFINE_MAX)

鍒版涓烘錛屼笂鏂囦竴寮濮嬫彁鍑虹殑 Tuple 宸茬粡瀹炵幇錛屽茍鏀寔鍒版渶澶х害 20 涓厓绱犲乏鍙熾?/p>

鐒跺悗鎴戜滑鍙互鑰冭檻澧炲姞鍚勭鏂逛究浣跨敤鐨勫姛鑳姐?/p>

  1. 榛樿鏋勯犲嚱鏁般?br>
  2. 甯︽湁 n 涓弬鏁扮殑鏋勯犲嚱鏁般傜浉鍏沖畯瀹氫箟錛?br>#define XL_TUPLE_INITIALIZE_LIST_PATTERN(n)         _##n(_##n)
    #define XL_TUPLE_INITIALIZE_LIST(n)                 XL_REPZ(XL_TUPLE_INITIALIZE_LIST_PATTERN, n, XL_COMMA)
  3. 鎷瘋礉鏋勯犲嚱鏁般傜浉鍏沖畯瀹氫箟錛?br>#define XL_TUPLE_INITIALIZE_LIST_COPY_PATTERN(n)    _##n(that._##n)
    #define XL_TUPLE_INITIALIZE_LIST_COPY(n)            XL_REPZ(XL_TUPLE_INITIALIZE_LIST_COPY_PATTERN, n, XL_COMMA)
  4. 璧嬪煎嚱鏁幫細
    #define XL_TUPLE_ASSIGN_PATTERN(n)                  this->_##n = that._##n;
    #define XL_TUPLE_ASSIGN(n)                          XL_REPZ(XL_TUPLE_ASSIGN_PATTERN, n, XL_NIL)
  5. 鍚勭姣旇緝鍑芥暟銆傝娉ㄦ剰瀵瑰悇鍏冪礌鐨勭浉搴旀瘮杈冭繍綆楃鐨勪緷璧栥傝繖閲屽畾涔夋垚錛孴uple 鐨?< 鍙緷璧栦簬鍚勫厓绱犵殑 <錛孴uple 鐨?!= 涔熷彧渚濊禆浜庡悇鍏冪礌鐨?!=錛屽姝ょ被鎺ㄣ?br>
    #define XL_TUPLE_EQUAL_PATTERN(n)                   this->_##n == that._##n
    #define XL_TUPLE_EQUAL(n)                           XL_REPZ(XL_TUPLE_EQUAL_PATTERN, n, &&)
  6. #define XL_TUPLE_NOT_EQUAL_PATTERN(n)               this->_##n != that._##n
    #define XL_TUPLE_NOT_EQUAL(n)                       XL_REPZ(XL_TUPLE_NOT_EQUAL_PATTERN, n, ||)

    #define XL_TUPLE_LITTER_PATTERN(n)                  if (this->_##n < that._##n)         \
                                                        {                                   \
                                                            return true;                    \
                                                        }                                   \
                                                        else if (that._##n < this->_##n)    \
                                                        {                                   \
                                                            return false;                   \
                                                        }
    #define XL_TUPLE_LITTER(n)                          XL_REPZ(XL_TUPLE_LITTER_PATTERN, n, XL_NIL)

    #define XL_TUPLE_GREATER_PATTERN(n)                 if (this->_##n > that._##n)         \
                                                        {                                   \
                                                            return true;                    \
                                                        }                                   \
                                                        else if (that._##n > this->_##n)    \
                                                        {                                   \
                                                            return false;                   \
                                                        }
    #define XL_TUPLE_GREATER(n)                         XL_REPZ(XL_TUPLE_GREATER_PATTERN, n, XL_NIL)

鍚屾椂 Tuple 涓篃澧炲姞鐩稿簲鐨勫嚱鏁幫紝鍗沖彲銆?/p>

鏈緇堜唬鐮佽 xlTuple.h錛岃繖閲屼笉璐翠簡銆?/p>

璇峰澶氭寚姝c?/p>

婧祦 2011-04-28 22:05 鍙戣〃璇勮
]]>
濡備綍瀹炵幇涓涓敮鎸佷笉鍚岀被鍨嬬殑 max/min 鍑芥暟錛?/title><link>http://www.shnenglu.com/Streamlet/archive/2011/03/29/142974.html</link><dc:creator>婧祦</dc:creator><author>婧祦</author><pubDate>Tue, 29 Mar 2011 13:27:00 GMT</pubDate><guid>http://www.shnenglu.com/Streamlet/archive/2011/03/29/142974.html</guid><wfw:comment>http://www.shnenglu.com/Streamlet/comments/142974.html</wfw:comment><comments>http://www.shnenglu.com/Streamlet/archive/2011/03/29/142974.html#Feedback</comments><slash:comments>16</slash:comments><wfw:commentRss>http://www.shnenglu.com/Streamlet/comments/commentRss/142974.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Streamlet/services/trackbacks/142974.html</trackback:ping><description><![CDATA[<p>鏈変釜闇姹傦紝鑳藉惁鍋氬埌瀹炵幇涓涓被浼艱繖鏍風殑鍑芥暟錛?/p> <p><font face="Consolas">template <typename T1, typename T2><br>XXX Min(T1 t1, T2 t2)<br>{<br>    return (t1 < t2 ? t1 : t2);<br>}</font> <p>鍏朵腑 XXX 鏄垜浠鎺ㄥ鍑虹殑綾誨瀷銆? <p>浠ヤ笅鏄竴涓け璐ョ殑灝濊瘯銆? <p>鎴戣寰?Loki 閲屾湁鍏充簬濡備綍鍒ゆ柇鏌愪釜綾誨瀷鑳藉惁闅愬紡杞崲涓哄彟涓涓被鍨嬬殑涓滆タ錛屽ぇ鎰忓涓嬶細 <p><font face="con">template <typename T, typename U><br>class Conversion<br>{<br>private:<br>    typedef char Small;<br>    class Big { char XXX[2]; };<br>    static Small Test(U);<br>    static Big Test(...);<br>    static T MakeT();<br>public:<br>    enum<br>    {<br>        Exists = (sizeof(Test(MakeT())) == sizeof(Small)),<br>    };<br>};</font> <p>濡傛錛孋onversion<T, U>::Exists 灝辮兘鍒ゆ柇 T 鍒?U 鐨勮漿鎹㈡槸鍚﹀瓨鍦ㄤ簡銆? <p>鐒跺悗鍐嶆悶涓夋嫨錛? <p><font face="Consolas">template <bool Condition, typename TypeIfTrue, typename TypeIfFalse><br>struct Select<br>{<br>    typedef TypeIfFalse Type;<br>}; </font> <p><font face="Consolas">template <typename TypeIfTrue, typename TypeIfFalse><br>struct Select<true, TypeIfTrue, TypeIfFalse><br>{<br>    typedef TypeIfTrue Type;<br>};</font> <p>鏈鍚庯紝鍐嶆潵涓細 <p>struct NullType; <p>template <typename T, typename U><br>struct CommonType<br>{<br>    typedef typename Select<Conversion<T, U>::exists, <br>                                        U,<br>                                        typename Select<Conversion<U, T>::exists,<br>                                                                T,<br>                                                                NullType>::Type<br>                                       >::Type Type;<br>}; <p>閭d箞 CommonType<T1, T2> 灝辨槸 T1 鍜?T2 涔嬮棿鍝釜鏄粬浠殑鍏辨湁綾誨瀷浜嗐? <p>嫻嬭瘯錛? <p>int main()<br>{<br>    CommonType<int, double>::Type m = 0; <p>    return 0;<br>} <p>璋冭瘯錛岀‘璁?m 鏄?double 鐨勩備絾鏄弽榪囨潵鍐?CommonType<double, int>::Type m = 0;錛宮 鍗存槸 int 鐨勩? <p>榪欒鏄庤繖濂楁満鍒朵竴寮濮嬪氨鏈夐棶棰橈紝Test(U) 鍜?Test(鈥? 涓や釜閲嶈澆鍑芥暟涓紝Test(鈥? 涓嶄細鍦ㄩ渶瑕?double 杞?int 鏃惰儨鍑恒傝繖鏄涓涓棶棰樸? <p>絎簩涓棶棰橈紝褰撳啓涓嬪涓嬩唬鐮佺殑鏃跺欙細 <p>template <typename T1, typename T2><br>CommonType<T1, T2>::Type Min(T1 t1, T2 t2)<br>{<br>    return (t1 < t2 ? t1 : t2);<br>} <p>緙栬瘧鏃犳硶閫氳繃銆?u>鍘熷洜鏄繑鍥炵被鍨嬩腑鐨?CommonType 涓殑妯℃澘鍙傛暟 T銆乁 鏃犳硶鎺ュ彈姝ゆ椂榪樹笉鑳界‘瀹氱殑 T1銆乀2銆?/u></p> <p><font color="#ff0000">(鏇存錛氫笉鏄繖涓師鍥狅紝榪斿洖綾誨瀷鍓嶅姞 typename 鍗沖彲銆傜幇鍦ㄩ棶棰樿繕鏄涓涓棶棰樸?</font></p> <p>璇鋒暀鍚勪綅錛屾湁娌℃湁浠涔堟柟娉曞仛鍒幫紵嬈㈣繋鎸囨暀~</p> <p>C++ 0x 涓氨鑳藉緢鏂逛究鍋氬埌浜嗭細</p> <p>template <typename T1, typename T2><br>auto Min(T1 t1, T2 t2) -> decltype(t1 + t2)<br>{<br>    return (t1 < t2 ? t1 : t2);<br>} <p>int main()<br>{<br>    int a = 2;<br>    double b = 1.0;<br>    auto m = Min(a, b); <p>    return 0;<br>}</p><img src ="http://www.shnenglu.com/Streamlet/aggbug/142974.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Streamlet/" target="_blank">婧祦</a> 2011-03-29 21:27 <a href="http://www.shnenglu.com/Streamlet/archive/2011/03/29/142974.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>瑙夊緱 Loki::ScopeGuard 浼間箮涓嶈鍦ㄥ畠鑷繁閲岄潰 try &hellip; catch &hellip;http://www.shnenglu.com/Streamlet/archive/2011/03/23/142543.html婧祦婧祦Wed, 23 Mar 2011 01:39:00 GMThttp://www.shnenglu.com/Streamlet/archive/2011/03/23/142543.htmlhttp://www.shnenglu.com/Streamlet/comments/142543.htmlhttp://www.shnenglu.com/Streamlet/archive/2011/03/23/142543.html#Feedback6http://www.shnenglu.com/Streamlet/comments/commentRss/142543.htmlhttp://www.shnenglu.com/Streamlet/services/trackbacks/142543.htmlScopeGuard 鍙槸甯垜浠皟鐢ㄤ竴涓嚱鏁拌屽凡錛岃嚦浜庤繖涓嚱鏁版槸鍚︽湁寮傚父鍑烘潵錛屽畠涓嶈鎮勬倓鍦版妸瀹冨悶浜嗭紝鑰屽簲璇ヨ繕鎴戜滑鏈潵闈㈢洰錛屼笉鐭ラ亾鏄笉鏄紵鍙槸涓轟粈涔堝嚑涔庢墍鏈変粙緇?ScopeGuard 鐨勬枃绔犻兘璇磋繖 try 鈥?catch 鈥?鐢ㄥ緱濂藉憿錛?/p>

婧祦 2011-03-23 09:39 鍙戣〃璇勮
]]>
涓涓ソ鐜╃殑鐜╂剰鍎匡細VS 鐨?autoexp.txthttp://www.shnenglu.com/Streamlet/archive/2011/02/27/140742.html婧祦婧祦Sun, 27 Feb 2011 09:10:00 GMThttp://www.shnenglu.com/Streamlet/archive/2011/02/27/140742.htmlhttp://www.shnenglu.com/Streamlet/comments/140742.htmlhttp://www.shnenglu.com/Streamlet/archive/2011/02/27/140742.html#Feedback22http://www.shnenglu.com/Streamlet/comments/commentRss/140742.htmlhttp://www.shnenglu.com/Streamlet/services/trackbacks/140742.html鍡紝鍐欑瘒鏂囩珷鐨勭洰鐨勬槸涓轟簡鎶婃垜鏈鏂幫紙鐜板湪鏄鏂幫級鐨勯偅綃囨枃绔犵粰鍒蜂笅鍘燴斺旀垜涓嶆兂姣忔鐪嬭瀹冧簡銆?/p>

涓嶇煡澶у鏈夋病鏈夊彂鐜幫紝褰撲嬌鐢?VS 鏉ヨ皟璇曚唬鐮佺殑鏃跺欙紝閭d簺 STL 瀹瑰櫒鐨勪俊鎭細浠ユ瘮杈冪湅寰楁噦鐨勬柟寮忔樉紺哄嚭鏉ワ細

image

 

鑰屾垜浠嚜宸卞啓鐨勶紝瀹冨彧鑳芥寜鐓ф暟鎹垚鍛樻潵鏄劇ず錛屽鏋滄暟鎹粨鏋勭◢寰鏉傜偣錛岀湅榪欎簺鐩存帴鏄劇ず鐨勫唴瀹瑰緱鍒扮殑鏈夌敤淇℃伅灝變細寰堝皯浜嗭細

image

 

閭d箞錛屾槸鍚︽湁鍔炴硶鑳借 IDE 鎸夌収鎴戜滑璁炬兂鐨勬柟寮忔潵鏄劇ず鏁版嵁鍛紵絳旀鏄偗瀹氱殑銆傝繖涓厤緗氨浣嶄簬 autoexp.txt 涓紙鍏蜂綋璺緞涓?X:\Program Files\Microsoft Visual Studio 10.0\Common7\Packages\Debugger\autoexp.dat錛屽鏋滄槸 VS 涓嶅悓鐗堟湰錛屸淢icrosoft Visual Studio 10.0鈥濅腑鐨勭増鏈彿鎹㈡垚鍏朵粬鐨勫嵆鍙紝VS 2005 浠ヤ笂鐗堟湰閮芥敮鎸侊級銆?/p>

鍦ㄩ噷闈㈡悳绱?vector錛屽彲浠ユ壘鍒頒綔鐢ㄤ簬 vector 鐨勮皟璇曚俊鎭樉紺烘柟寮忕殑璇彞錛?/p>

std::vector<*>{
    preview (
        #(
            "[",
            $e._Mylast - $e._Myfirst,
            "](",
            #array(
                expr: $e._Myfirst[$i],
                size: $e._Mylast - $e._Myfirst
            ),
            ")"
        )
    )

    children (
        #(
            #([size] : $e._Mylast - $e._Myfirst),
            #([capacity] : $e._Myend - $e._Myfirst),
            #array(
                expr: $e._Myfirst[$i],
                size: $e._Mylast - $e._Myfirst
            )
        )
    )
}

榪欎釜璇硶鐨勮緇嗗畼鏂硅鏄庡ソ鍍忔病鏈夛紝涓嶈繃澶т綋涓婂彲浠ョ寽鍑烘潵銆?/p>

絎竴琛?std::vector<*> 鏄被鍨嬶紝璇存槑涓嬮潰鐨勫唴瀹歸拡瀵?std::vector錛屽茍涓旈傜敤浜庝換鎰忔ā鐗堝弬鏁般傜揣鎺ョ潃鏄竴涓ぇ鎷彿鎷搗鏉ョ殑孌佃惤銆?/p>

preview 寮濮嬬殑閭d竴孌佃〃紺哄綋璇ュ彉閲忓崟琛屾樉紺虹殑鏃跺欒濡備綍鏄劇ず錛屼篃灝辨槸涓嬪浘絎簩鍒楃殑鏍峰瓙錛?br>image

IDE 浼氫緷嬈℃樉紺?preview(#( 鈥?)) 鎷彿鍐呯殑浠ラ楀彿鍒嗛殧鐨勫唴瀹癸紝鍔犲紩鍙風殑浼氬師鏍鋒樉紺猴紝鍙橀噺鐢?$e 寮曠敤錛堝皢 $e 瑙嗕負璇ョ被鍨嬬殑涓涓彉閲忥級銆?/p>

闄や簡鐩存帴寮曞彿錛屽彉閲忕殑榪愮畻緇撴灉澶栵紝榪欓噷榪樺彲浠ュ啓涓浜涢珮綰х偣鐨勭帺鎰忓効錛屽 #array錛?list錛?tree銆?/p>

#array 鐨勬牸寮忎負錛?br>#array(
    expr: 鈥?,
    size:  鈥?br>)
鍏朵腑 expr 閲屽彲浠ヤ嬌鐢?$i錛?i 涓哄厓绱?index錛宻ize 琛ㄧず鍏冪礌涓暟銆傛渶緇堢殑緇撴灉涓猴細
$i=0鏃剁殑expr, $i=1鏃剁殑expr, 鈥? $i=size鏃剁殑expr銆?/p>

鍋囪鏈変竴涓粨鏋勶細
struct Vector
{
    int *pData;
    int nCount;
};
鍏朵腑 p 鏄寚鍚戜竴鍧?count 涓?int 鐨勫唴瀛樸傚鏋滆渚濇鏄劇ず榪?count 涓暟瀛楋紝preview 涓簲璇ュ啓錛?br>preview (
    #(
        #array(
            expr: $e.pData[$i],
            size: $e.nCount
        )
    )
)

#list 鐨勬牸寮忎負錛?br>#list(
    head: 鈥?,
    size: 鈥?,
    next: 鈥?br>) : 鈥?br>鍏朵腑 head 鏄寚鍚戠涓涓?Node 鐨勬寚閽堬紝size 琛ㄧず鍏冪礌涓暟錛宯ext 琛ㄧず Node 涓寚鍚戜笅涓涓?Node 鐨勫垎閲忓悕錛屾渶鍚庡啋鍙峰悗闈㈣繕瑕佸啓涓涓?Node 涓殑鍊煎垎閲忥紝涔熷氨鏄鏄劇ず鐨勯偅涓彉閲忋?/p>

鍋囪鏈夌粨鏋勶細
struct ListNode
{
    int nData;
    ListNode *pNext;
};
struct List
{
    ListNode *pHead錛?br>    int nCount;
};
preview 鐨勫啓娉曚負錛?br>preview (
    #(
        #list(
            head: $e.pHead,
            size: $e.nCount,
            next: pNext
        ) : $e.nData    // 娉ㄦ剰錛岃繖閲岀殑 $e 浠h〃 ListNode錛屼笂闈袱涓?$e 閮戒唬琛?List
    )
)

#tree鐨勬牸寮忎負
#tree(
    head: 鈥?
    left: 鈥?
    right: 鈥?
    size: 鈥?br>) : 鈥?br>鍏朵腑 head 鏄寚鍚戞牴鑺傜偣鐨勬寚閽堬紝left 鍜?right 鍒嗗埆鏄寚鍚戝乏鍙沖瓙鏍戠殑鍒嗛噺鍚嶏紝size 琛ㄧず鍏冪礌涓暟錛屾渶鍚庡啋鍙峰悗闈㈠啓鑺傜偣涓殑鍊煎垎閲忋侷DE浼氬鏁存5鏍戝仛涓簭閬嶅巻銆?/p>

鍋囪鏈夌粨鏋勶細
struct TreeNode
{
    int nData;
    TreeNode *pLeft;
    TreeNode *pRight;
};
struct Tree
{
    TreeNode *pRoot;
    int nCount;
};
preview 鐨勫啓娉曚負錛?br>preview (
    #(
    #tree(
        head: $e.pRoot,
        left: pLeft,
        right: Right,
        size: $e.nCount
        ) : $e.nData // 娉ㄦ剰錛岃繖閲岀殑 $e 浠h〃 TreeNode錛屼笂闈袱涓?$e 閮戒唬琛?Tree
    )
)


preview 鐨勬牸寮忓氨鍒版銆傛帴涓嬫潵鏄?children錛屽畠鐢ㄤ簬鎻忚堪鐐瑰嚮鍙橀噺宸﹁竟鐨勫姞鍙峰悗錛屽睍寮鐨勫唴瀹規庝箞鏄劇ず錛屽鍥撅細

image

IDE 浼氫緷嬈℃樉紺?children(#( 鈥?)) 鎷彿鍐呯殑浠ラ楀彿鍒嗛殧鐨勫唴瀹癸紝姣忎釜鏄劇ず涓轟竴琛屻傚垰鎵嶇殑 #array, #list, #tree 閮藉彲浠ョ敤錛屼細鏄劇ず鎴愮涓鍒楃儲寮曠浜屽垪鍊肩殑鏍峰瓙銆?br>鍙﹀鍙互鐢?#(first, second) 鐨勬牸寮忥紝first 浼氬師鏍鋒樉紺哄湪絎竴鍒楋紝second 浼氭眰鍊兼樉紺哄湪絎簩鍒椼?/p>

 

浜嗚В浠ヤ笂榪欎簺鍐呭錛屾垜浠凡緇忓彲浠ラ拡瀵?STL 鐨勯偅浜涙暟鎹粨鏋勫仛鑷畾涔夋樉紺轟簡錛屽涓浜涘埆鐨勬暟鎹粨鏋勪綔綆鍗曠殑鑷畾涔夋樉紺轟篃涓嶉毦銆?/p>

 

鏈鍚庣粰涓晥鏋滃浘錛屽畾涔変簡鎴戣嚜宸辯殑閭d簺瀹瑰櫒鐨勬樉紺烘柟寮忋傛庝箞鏍鳳紝鐪嬩笂鍘諱竴瀹氭瘮寮澶寸粰鍑虹殑閭d釜鍐峰啺鍐扮殑鏍峰瓙濂藉緢澶氬惂錛?/p>

image



婧祦 2011-02-27 17:10 鍙戣〃璇勮
]]>
C++ 涓?Function 瀵硅薄鐨勫疄鐜幫紙涓嬶級http://www.shnenglu.com/Streamlet/archive/2011/01/17/138693.html婧祦婧祦Mon, 17 Jan 2011 13:59:00 GMThttp://www.shnenglu.com/Streamlet/archive/2011/01/17/138693.htmlhttp://www.shnenglu.com/Streamlet/comments/138693.htmlhttp://www.shnenglu.com/Streamlet/archive/2011/01/17/138693.html#Feedback5http://www.shnenglu.com/Streamlet/comments/commentRss/138693.htmlhttp://www.shnenglu.com/Streamlet/services/trackbacks/138693.html鐩綍錛?/p>

C++ 涓?Function 瀵硅薄鐨勫疄鐜幫紙涓婏級
C++ 涓?Function 瀵硅薄鐨勫疄鐜幫紙涓嬶級

涓婄瘒涓紝鎴戜滑瀹炵幇浜嗕竴涓敮鎸?R () 鍨嬪嚱鏁扮殑 Function銆傝ˉ鍏呰鏄庝竴涓嬶紝鍦ㄦ垜浠鎴愬憳鍑芥暟鐨勬敮鎸佷腑錛屾垜浠槸榪欐牱瀹氫箟鐨勶細

template <typename R, typename T>
class MemberFunction0 : public FunctionBase0<R>
{

private:
    R (T::*m_pMemFun)();
    T *m_pObj;
};

Loki 鐗規剰鍦ㄨ憲浣滀腑鎻愰啋鎴戜滑錛岃繖閲岀殑 T 鏈濂戒笉瑕佹槸鍑芥暟綾誨瀷錛屾敼涓哄嚱鏁版寚閽堢被鍨嬶紝濡傛璇ョ被鐨勬敮鎸佽寖鍥村皢鎵╁ぇ銆傚涓嬶細

template <typename R, typename P, typename T>
class MemberFunction0 : public FunctionBase0<R>
{
public:
    R Invoke()
    {
        return (m_pObj->*m_pMemFun)();
    }

public:
    MemberFunction0(P pObj, R (T::*pMemFun)())
        : m_pObj(pObj), m_pMemFun(pMemFun)
    {

    }

private:
    R (T::*m_pMemFun)();
    P m_pObj;
};

浜庢槸錛孭 鍜?T 鐨勫叧緋諱笉閭d箞绱у瘑浜嗭紝P 涓嶄竴瀹氶潪瑕?T* 涓嶅彲錛屼篃鍙互鏄濡?SmartPtr<T> 涔嬬被鐨勭帺鎰忓効銆傚師鏈彧鏀寔浼犲叆涓涓璞″拰璇ュ璞$殑鎴愬憳鍑芥暟鐨勶紝鐜板湪鍙樻垚浼犲叆涓涓叿鏈夋寚閽堟蹇電殑涓滀笢鍜屼竴涓垚鍛樺嚱鏁幫紝鍙榪欎釜鈥滄寚閽堚濅嬌鐢ㄨ繍綆楃 鈥?gt; 鍘昏皟鐢ㄩ偅涓垚鍛樺嚱鏁板悎涔庤娉曞嵆鍙?/p>

鎺ヤ笅鏉ワ紝鎴戜滑鏉ユ墿灞曡繖涓?Function錛屼互鏀寔鎷ユ湁鏁扮洰鍦ㄧ粰瀹氫笂闄愬唴鐨勪換鎰忓弬鏁扮殑鍑芥暟銆?/p>

鎴戜滑鍏堟潵鎵嬪伐鍐欎竴涓嬶紝鐪嬬湅濡備綍鏀寔甯︿竴涓弬鏁扮殑鍑芥暟銆傞鍏堝畾涔変竴涓櫄鍩虹被錛?/p>

template <typename R, typename T0>
class FunctionBase1
{
public:
    virtual R Invoke(T0) = 0;
    virtual ~FunctionBase1() {}
};

瀹炵幇涓や釜鐗堟湰錛屽垎鍒敮鎸侀潪鎴愬憳鍑芥暟鍜屾垚鍛樺嚱鏁幫細

template <typename R, typename T0, typename T>
class Function1 : public FunctionBase1<R, T0>
{
public:
    R Invoke(T0 v0)
    {
        return m_Fun(v0);
    }

public:
    Function1(const T &fun)
        : m_Fun(fun)
    {

    }

private:
    T m_Fun;
};

template <typename R, typename P, typename T, typename T0>
class MemberFunction1 : public FunctionBase1<R, T0>
{
public:
    R Invoke(T0 v0)
    {
        return (m_pObj->*m_pMemFun)(v0);
    }

public:
    MemberFunction1(P pObj, R (T::*pMemFun)(T0))
        : m_pObj(pObj), m_pMemFun(pMemFun)
    {

    }

private:
    R (T::*m_pMemFun)(T0);
    P m_pObj;
};

澧炲姞涓涓嚱鏁板紩鐢ㄨ悆鍙栫殑鍋忕壒鍖栫増鏈細

template <typename RetType, typename T0>
struct FunctionTraits<RetType (T0)>
{
    typedef RetType (&ParamType)(T0);
};

澧炲姞涓涓?Function 綾葷殑鍋忕壒鍖栫増鏈細

template <typename R, typename T0>
class Function<R (T0)>
{
public:
    template <typename T>
    Function(const T &fun)
        : m_pFunBase(new Function1<R, T0, typename FunctionTraits<T>::ParamType>(fun))
    {
       
    }

    template <typename P, typename T>
    Function(P pObj, R (T::*pMemFun)(T0))
        : m_pFunBase(new MemberFunction1<R, P, T, T0>(pObj, pMemFun))
    {

    }

    ~Function()
    {
        delete m_pFunBase;
    }

    R operator ()(T0 v0)
    {
        return m_pFunBase->Invoke(v0);
    }

private:
    FunctionBase1<R, T0> *m_pFunBase;
};

鐜板湪錛屾垜浠彲浠ヨ窇涓涓嬫祴璇曚唬鐮佷簡錛?/p>

Function<int (int)> f1(&intfun1);
Function<int (int)> f1_(intfun1);
Function<int (int)> f2(intfunctor1);
Function<int (int)> f3(&test, &Test::intmem1);

f1(1);
f1_(1);
f2(2);
f3(3);

褰撶劧錛寁oid 鍑芥暟涔熸槸鏀寔鐨勩?/p>

瑙傚療涓婇潰鐨勮繖浜涗唬鐮侊紝鍜屾垜浠湪涓婁竴綃囦腑鐨勪唬鐮侀珮搴︿竴鑷達紝涓嶅悓鐨勬槸閭d簺妯$増鍙傛暟銆佸亸鐗瑰寲鍙傛暟銆佸嚱鏁拌皟鐢ㄥ弬鏁扮瓑鍦版柟銆?/p>

鍋囧鏈夎繖涔堜竴緇勫畯錛?br>TYPENAME_DECLARE(n) 琚畾涔変負 typename T0, typename T1, 鈥? typename Tn
TYPENAME_LIST(n) 琚畾涔変負 T0, T1, 鈥? Tn
TYPENAME_VARIABLE(n) 琚畾涔変負 T0 v0, T1 v1, 鈥? Tn vn
VARIABLE_LIST(n) 琚畾涔変負 v0, v1, 鈥? vn

閭d箞鎴戜滑鍙互浣跨敤涓涓?n 灝卞啓鍑烘敮鎸佹墍鏈夊叿鏈夊弬鏁扮殑鍑芥暟鐨?Function 浜嗐傛垜浠姏寮冩帀涓婇潰鐨?1 緋誨垪鐨勬墍鏈夌被錛屼粎淇濇寔涓婄瘒鐣欎笅鏉ョ殑浠g爜錛岀劧鍚庡埄鐢ㄤ笂闈?4 涓畯灝嗘墍鏈夋暟瀛楀熬宸村幓鎺夛紝浜庢槸浠g爜鍙樻垚錛?/p>

template <typename R, TYPENAME_DECLARE(n)>
class FunctionBase_##n
{
public:
    virtual R Invoke(TYPENAME_LIST(n)) = 0;
    virtual ~FunctionBase_##n() {}
};


template <typename R, TYPENAME_DECLARE(n), typename T>
class Function_##n : public FunctionBase_##n<R, TYPENAME_LIST(n)>
{
public:
    R Invoke(TYPENAME_VARIABLE(n))
    {
        return m_Fun(VARIABLE_LIST(n));
    }

public:
    Function_##n(const T &fun)
        : m_Fun(fun)
    {

    }

private:
    T m_Fun;
};

template <typename R, typename P, typename T, TYPENAME_DECLARE(n)>
class MemberFunction_##n : public FunctionBase_##n<R, TYPENAME_LIST(n)>
{
public:
    R Invoke(TYPENAME_VARIABLE(n))
    {
        return (m_pObj->*m_pMemFun)(VARIABLE_LIST(n));
    }

public:
    MemberFunction_##n(P pObj, R (T::*pMemFun)(TYPENAME_LIST(n)))
        : m_pObj(pObj), m_pMemFun(pMemFun)
    {

    }

private:
    R (T::*m_pMemFun)(TYPENAME_LIST(n));
    P m_pObj;
};

template <typename RetType, TYPENAME_DECLARE(n)>
struct FunctionTraits<RetType (TYPENAME_LIST(n))>
{
    typedef RetType (&ParamType)(TYPENAME_LIST(n));
};

template <typename R, TYPENAME_DECLARE(n)>
class Function<R (TYPENAME_LIST(n))>
{
public:
    template <typename T>
    Function(const T &fun)
        : m_pFunBase(new Function_##n<R, TYPENAME_LIST(n), typename FunctionTraits<T>::ParamType>(fun))
    {
       
    }

    template <typename P, typename T>
    Function(P pObj, R (T::*pMemFun)(TYPENAME_LIST(n)))
        : m_pFunBase(new MemberFunction_##n<R, P, T, TYPENAME_LIST(n)>(pObj, pMemFun))
    {

    }

    ~Function()
    {
        delete m_pFunBase;
    }

    R operator ()(TYPENAME_VARIABLE(n))
    {
        return m_pFunBase->Invoke(VARIABLE_LIST(n));
    }

private:
    FunctionBase_##n<R, TYPENAME_LIST(n)> *m_pFunBase;
};

褰撶劧涓婇潰榪欐牱瀛愮殑浠g爜鏄病娉曡窇鐨勫挴銆傚鏋滄垜浠皢鏁存浠g爜瀹氫箟涓轟竴涓畯 BODY(n)錛岀劧鍚庣敤綾諱技鍒氭墠鍥涗釜瀹忕殑鏂瑰紡瀹氫箟瀹?FUNCTION_IMPLEMENT(n)錛屼嬌寰楀畠鐨勫惈涔変負 BODY(0), BODY(1), 鈥? BODY(n)錛屾墍鏈夊伐浣滃氨閮藉畬鎴愪簡銆傛渶鍚庡彧闇瑕佷涪涓嬩竴鍙?FUNCTION_IMPLEMENT(20)錛屽氨鍙互鏀寔 0 鍒?21 涓弬鏁頒簡銆?/p>

鏈鍚庡綊緇撲負錛屽浣曚嬌鐢ㄥ畯鎼炲嚭鈥淭0, T1, 鈥? Tn鈥?鐨勫艦寮忋?/p>

鏆村姏鐐癸紝鎴戜滑鍙互榪欐牱錛?/p>

#define T_0 T0
#define T_1 T_0, T1
#define T_2 T_1, T2
#define T_3 T_2, T3
#define T_4 T_3, T4
#define T_5 T_4, T5
#define T_6 T_5, T6
#define T_7 T_6, T7
#define T_8 T_7, T8
#define T_9 T_8, T9

#define T(n) T_##n

榪欐牱瀛愶紝瀵逛簬涓婇潰鍥涗釜瀹忓彲浠ワ紝浣嗘槸瀵逛簬鏈鍚庣殑 X(n)錛屼漢宸ヤ唬鐮侀噺榪樻槸澶ぇ浜嗐傚棷錛焁(n)錛熷錛岃繖涓?X錛屽繀欏誨湪 _1銆乢2銆乢3 緋誨垪瀹忛噷闈㈠崰鎹竴涓弬鏁板湴浣嶏紝榪欐牱鎵嶆湁閭d箞涓鐐圭偣鎵╁睍鎬с傝冭檻鎹㈡垚榪欐牱錛?/p>

#define REP_0(macro, n) macro(0)
#define REP_1(macro, n) REP_0(macro, n), macro(1)
#define REP_2(macro, n) REP_1(macro, n), macro(2)
#define REP_3(macro, n) REP_2(macro, n), macro(3)
#define REP_4(macro, n) REP_3(macro, n), macro(4)
#define REP_5(macro, n) REP_4(macro, n), macro(5)
#define REP_6(macro, n) REP_5(macro, n), macro(6)
#define REP_7(macro, n) REP_6(macro, n), macro(7)
#define REP_8(macro, n) REP_7(macro, n), macro(8)
#define REP_9(macro, n) REP_8(macro, n), macro(9)

#define REP(macro, n)   REP_##n(macro, n)

鐒跺悗錛?/p>

#define TYPENAME_LIST_PATTERN(n)    T##n
#define TYPENAME_LIST(n)            REP(TYPENAME_LIST_PATTERN, n)

榪欎釜 TYPENAME_LIST 灝辨槸絎﹀悎涓婃枃瑕佹眰鐨勫畯銆傛帴涓嬫潵濡傛硶鐐埗鍏朵綑涓変釜錛?/p>

#define TYPENAME_DECLARE_PATTERN(n)     typename T##n
#define TYPENAME_DECLARE(n)             REP(TYPENAME_DECLARE_PATTERN, n)

#define TYPENAME_VARIABLE_PATTERN(n)    T##n v##n
#define TYPENAME_VARIABLE(n)            REP(TYPENAME_VARIABLE_PATTERN, n)

#define VARIABLE_LIST_PATTERN(n)        v##n
#define VARIABLE_LIST(n)                REP(VARIABLE_LIST_PATTERN, n)

鏈鍚庯紝鎴戜滑鍦?#define FUNCTION_IMPLEMENT(n)  REP(BODY, n) 涓繕瀛樺湪涓鐐圭偣闂銆傚洜涓?BODY 涓細鍚湁 TYPENAME_DECLARE 涔嬬被鐨勫畯鐨勪嬌鐢紝鑰?TYPENAME_DECLARE 姝f槸浣跨敤 REP 瀹氫箟鐨勩傝繖娑夊強鍒板畯鐨勯掑綊灞曞紑錛孋++棰勫鐞嗗櫒鐨勮鍒欐槸錛岄亣鍒拌繖鏍風殑鎯呭喌灝卞仠姝㈠睍寮銆傛瘮濡傦紝鎴戜滑 瀹氫箟 BODY(n) 涓?TYPENAME_DECLARE(n)錛屼簬鏄?FUNCTION_IMPLEMENT(2) 浼氳灞曟垚錛?/p>

REP(TYPENAME_DECLARE_PATTERN, 0), REP(TYPENAME_DECLARE_PATTERN, 1), REP(TYPENAME_DECLARE_PATTERN, 2)

涓婇潰鐨?REP 涓嶄細琚戶緇睍寮浜嗐?/p>

涓烘錛屼竴涓笉澶仾鏄庣殑鍔炴硶灝辨槸錛屽啀瀹氫箟涓緇?REP2銆傚棷錛屾槸涓姙娉曪紝灝辮繖涔堝姙鍚с傚彟澶栨垜浠垰鎵嶇殑 REP 緋誨垪娌℃湁灝嗗垎闅旂浣滀負鍙傛暟錛岄粯璁や嬌鐢ㄩ楀彿錛岃屾渶鍚庝竴涓嶇殑 FUNCTION_IMPLEMENT 鐨勯噸澶嶄腑鏄笉鑳界敤閫楀彿鐨勩傝冭檻鎻愬彇鍑烘潵浣滀負鍙傛暟銆傛渶鍚庢垜浠殑鎵闇瑕佺殑瀹忕郴緇熸槸錛?/p>

#define NIL
#define COMMA ,

#define REP_0(macro, splitter, n) macro(0)
#define REP_1(macro, splitter, n) REP_0(macro, splitter, n) splitter macro(1)
#define REP_2(macro, splitter, n) REP_1(macro, splitter, n) splitter macro(2)
#define REP_3(macro, splitter, n) REP_2(macro, splitter, n) splitter macro(3)
#define REP_4(macro, splitter, n) REP_3(macro, splitter, n) splitter macro(4)
#define REP_5(macro, splitter, n) REP_4(macro, splitter, n) splitter macro(5)
#define REP_6(macro, splitter, n) REP_5(macro, splitter, n) splitter macro(6)
#define REP_7(macro, splitter, n) REP_6(macro, splitter, n) splitter macro(7)
#define REP_8(macro, splitter, n) REP_7(macro, splitter, n) splitter macro(8)
#define REP_9(macro, splitter, n) REP_8(macro, splitter, n) splitter macro(9)

#define REP(macro, splitter, n)   REP_##n(macro, splitter, n)

#define REP2_0(macro, splitter, n) macro(0)
#define REP2_1(macro, splitter, n) REP2_0(macro, splitter, n) splitter macro(1)
#define REP2_2(macro, splitter, n) REP2_1(macro, splitter, n) splitter macro(2)
#define REP2_3(macro, splitter, n) REP2_2(macro, splitter, n) splitter macro(3)
#define REP2_4(macro, splitter, n) REP2_3(macro, splitter, n) splitter macro(4)
#define REP2_5(macro, splitter, n) REP2_4(macro, splitter, n) splitter macro(5)
#define REP2_6(macro, splitter, n) REP2_5(macro, splitter, n) splitter macro(6)
#define REP2_7(macro, splitter, n) REP2_6(macro, splitter, n) splitter macro(7)
#define REP2_8(macro, splitter, n) REP2_7(macro, splitter, n) splitter macro(8)
#define REP2_9(macro, splitter, n) REP2_8(macro, splitter, n) splitter macro(9)

#define REP2(macro, splitter, n)   REP2_##n(macro, splitter, n)

#define TYPENAME_DECLARE_PATTERN(n)     typename T##n
#define TYPENAME_DECLARE(n)             REP(TYPENAME_DECLARE_PATTERN, COMMA, n)

#define TYPENAME_LIST_PATTERN(n)        T##n
#define TYPENAME_LIST(n)                REP(TYPENAME_LIST_PATTERN, COMMA, n)

#define TYPENAME_VARIABLE_PATTERN(n)    T##n v##n
#define TYPENAME_VARIABLE(n)            REP(TYPENAME_VARIABLE_PATTERN, COMMA, n)

#define VARIABLE_LIST_PATTERN(n)        v##n
#define VARIABLE_LIST(n)                REP(VARIABLE_LIST_PATTERN, COMMA, n)

#define FUNCTION_IMPLEMENT(n)  REP2(BODY, NIL, n)

鏈鍚庯紝瀹氫箟涓涓?FUNCTION_IMPLEMENT(5)錛屽氨鍙互鏀寔鍒?6 涓弬鏁頒簡銆備負浜嗘敮鎸佹洿澶氬弬鏁幫紝鎶婁笂闈㈢殑 REP 浠ュ強 REP2 緋誨垪澶氬畾涔変竴鐐癸紝姣斿鍒?50錛岄偅涔?FUNCTION_IMPLEMENT 鐨勬嫭鍙蜂腑灝卞彲浠ュ~ 50 浠ュ唴鐨勪換鎰忔暟浜嗐傝冭檻鍒板畯灞曞紑瀵圭紪璇戦熷害鐨勫獎鍝嶏紝浠ュ強瀹為檯搴旂敤涓嚱鏁板弬鏁扮殑涓暟錛屽畾涓?20 宸﹀彸姣旇緝鍚堥傘?/p>

鍒拌繖閲岋紝鎴戜滑鐨凢unction宸茬粡瀹炵幇浜嗛鏈熺洰鏍囥傛帴涓嬫潵鎴戞湰鏉ユ兂璇磋 TypeList 鐨勩傚彲鏄幇鍦ㄥ彂鐜版病鏈?TypeList錛孎unction 璺戠殑閫氾紱鏈変簡 TypeList錛孎unction 涔熶笉鑳藉啓鐨勬紓浜灝戯紝铏借閭d簺閲嶅閮ㄥ垎鏈変竴瀹氱殑鍑忓皯銆侺oki 鐨?Functor 鐨勫弬鏁扮被鍨嬫槸涓涓繑鍥炲肩被鍨嬪姞涓婁竴涓?TypeList錛屾槸鐢辯敤鎴風洿鎺ヤ紶鍏?TypeList 鐨勶紝涓嶇敤鐢辨暎鐨勭被鍨嬬粍鍚堝嚭涓涓猅ypeList錛堜絾榪樻槸瑕佷粠TypeList涓悆鍙栧悇涓弬鏁扮被鍨嬶級錛屽洜姝ょ敤鍦ㄤ粬閭i噷鐪嬩笂鍘葷編濡欎竴鐐圭偣銆傚綋鐒訛紝Loki 涔熷湪 Functor 澶栧ご鍖呬簡涓灞?Function錛屼互鏀寔鍑芥暟絳懼悕浣滀負妯$増鍙傛暟鐨勪嬌鐢ㄦ柟寮忋傛湁涓鐐逛笉綆楁敼瑙傜殑鏀硅鏄紝鐢ㄤ簡 TypeList 浠ュ悗錛屽氨涓嶄細鍐嶆湁 FunctionBase_1, FunctionBase_2 榪欐牱鐨勭帺鎰忓効浜嗭紝鍙栬屼唬涔嬬殑鏄竴涓粺涓鐨?FunctionBase 澶栧姞璁稿鍋忕壒鍖栫増鏈紝Function* 鍜?MemberFunction* 鍙互鍒嗗埆緇熶竴涓轟竴涓紝浣嗘槸姣忎竴涓噷澶撮兘闇瑕佸疄鐜?N 涓?Invoke銆傚姞涓婄瘒騫呭叧緋伙紝鎴戞兂榪欓噷灝變笉璇磋繖涓?TypeList 浜嗐?/p>

浠g爜娓呭崟澶暱浜嗭紝灝變笉璐翠簡錛屾湁鎰忚呰嚜鐒惰兘鍑戣搗鏉ャ傛垜鐩墠鍦?xlLib 涓殑鏈緇堝疄鐜拌 xlFunction.h銆?/p>

鍏充簬瀹忥紝鎴戜笉鐭ラ亾鍙互鎬庢牱鏀硅繘銆侭OOST_PP_REPEAT 璨屼技鍙互璋冪敤鑷韓錛熶笉鐭ラ亾濡備綍瀹炵幇鐨勶紝姹傛寚鏁欍傚彟澶?a href="http://www.shnenglu.com/vczh" target="_blank">@vczh璨屼技璇粹滃疄鐜頒簡涓闂ㄥ彲浠ヨ嚜宸遍掑綊鑷繁鍜屽唴緗垪琛ㄥ鐞嗙殑鍙︿竴涓畯鈥濓紝姹傚垎浜憖姹傚垎浜?/p>

2010-01-18 琛ュ厖錛氬皢鏈澶栧眰 Function 鐨勬瀯閫犲嚱鏁頒腑鐨?const T & 鐩存帴鏀逛負 T錛屽茍涓旀姏寮?FunctionTraits錛屽嚱鏁板疄浣撶被鍨嬪皢鍦ㄤ紶閫掕繃紼嬩腑鐩存帴閫鍖栦負鍑芥暟鎸囬拡錛岃繖鏍峰氨鑳界壒鍖栧嚭姝g‘鐨?FunctionHandler銆傚悓鏃跺甫鏉ュ彟涓鐐瑰獎鍝嶏細濡傛灉浼犲叆 Functor錛屽瓧闈笂灝嗗涓嬈℃嫹璐濆姩浣溿傛姏寮榪欎竴鐐瑰井灝忕殑鎬ц兘鏉ヨ錛岃繖姣斿垰鎵嶇殑 FunctionTraints 瑕佸ソ寰楀浜嗐?/strong>



婧祦 2011-01-17 21:59 鍙戣〃璇勮
]]>
C++ 涓?Function 瀵硅薄鐨勫疄鐜幫紙涓婏級http://www.shnenglu.com/Streamlet/archive/2011/01/16/138615.html婧祦婧祦Sun, 16 Jan 2011 14:17:00 GMThttp://www.shnenglu.com/Streamlet/archive/2011/01/16/138615.htmlhttp://www.shnenglu.com/Streamlet/comments/138615.htmlhttp://www.shnenglu.com/Streamlet/archive/2011/01/16/138615.html#Feedback55http://www.shnenglu.com/Streamlet/comments/commentRss/138615.htmlhttp://www.shnenglu.com/Streamlet/services/trackbacks/138615.html鐩綍錛?/p>

C++ 涓?Function 瀵硅薄鐨勫疄鐜幫紙涓婏級
C++ 涓?Function 瀵硅薄鐨勫疄鐜幫紙涓嬶級

璧峰洜鍦?a href="http://www.shnenglu.com/Streamlet/archive/2011/01/16/138609.html" target="_blank">涓婁竴綃?/a>宸茬粡璇磋繃浜嗐傜幇鍦ㄨ鎴戜滑鐩存帴榪涘叆涓婚銆傛湰鏂囩殑鐩爣鏄紝璁╀互涓嬩唬鐮佽兘欏哄埄璺戣搗鏉ワ細

int intfun0()
{
    return 1;
}

struct _intfunctor0
{
    int operator()()
    {
        return 2;
    }

} intfunctor0;

struct Test
{
    int intmem0()
    {
        return 3;
    }

} test;

int main()
{
    Function<int ()> f1(&intfun0);
    Function<int ()> f1_(intfun0);
    Function<int ()> f2(intfunctor0);
    Function<int ()> f3(&test, &Test::intmem0);

    f1();
    f1_();
    f2();
    f3();

    return 0;
}

闄や簡涓婅堪渚嬪瓙涓樉紺虹殑錛岃繕瑕佹敮鎸佹湁榪斿洖鍊肩殑鍑芥暟鍜屾病榪斿洖鍊肩殑鍑芥暟錛屼互鍙婃湁0涓?涓?涓佲︹︺丮AX 涓弬鏁扮殑鍑芥暟錛屽弬鏁扮被鍨嬫棤闄愬埗銆傛渶鍚庡疄鐜扮殑 Function 瀵硅薄浠呬粎鍙互鎵ц灝卞ソ銆傦紙鑷充簬鏄惁鍙嫹璐濄佹槸鍚﹀彲鍒ゆ柇鐩哥瓑 絳夐棶棰橈紝閮芥槸灝忎簨錛屾湰鏂囨殏涓嶈冭檻銆傦級鏈鍚庯紝Bind 姒傚康涔熶笉鍦ㄦ湰鏂囪璁鴻寖鍥翠箣鍐呫?/p>

瀵逛簬榪欎釜闂錛屾垜浠竴寮濮嬭冭檻鐨勫彲鑳芥槸鎬庢牱緇熶竴涓夌涓嶅悓褰㈠紡銆傛湁涓や釜閫夋嫨錛岀涓錛屼嬌鐢?C++ 鐨勫鎬佹満鍒訛紝鏈鍚庣粺涓鍒板熀綾繪寚閽堢殑綾誨瀷錛涚浜岋紝鍏佽綾誨唴閮ㄦ湁鍐椾綑鍙橀噺浠ュ強蹇呰鐨?Flag錛岀敤浜庡垽鏂槸鍝褰㈠紡鐨勫嚱鏁幫紝瑕佸浣曟墽琛屻傝繖鏍風湅璧鋒潵錛岀涓縐嶆柟妗堟瘮絎簩縐嶇埥涓鐐廣備簬鏄紝鏈鍒濇兂鍒扮殑瀹炵幇鏈夊彲鑳芥槸榪欐牱鐨勶細

鍏堝畾涔変竴涓櫄鍩虹被錛?/p>

template <typename R>
class FunctionBase0
{
public:
    virtual R Invoke() = 0;
    virtual ~FunctionBase0() {}
};

鐒跺悗瀹炵幇涓涓櫘閫氬嚱鏁?浠垮嚱鏁扮殑鐗堟湰錛?/p>

template <typename R, typename T>
class Function0 : public FunctionBase0<R>
{
public:
    R Invoke()
    {
        return m_Fun();
    }

public:
    Function0(const T &fun)
        : m_Fun(fun)
    {

    }

private:
    T m_Fun;
};

榪欓噷闇瑕佽鏄庣殑鏄紝濡傛灉鏄櫘閫氬嚱鏁幫紝T浼氳鐗瑰寲鎴?R() 鎴栬?R (&)() 鎴栬?R(*)()錛屽彇鍐充簬浣跨敤鐨勬椂鍊欎紶鍏?fun 榪樻槸浼犲叆 &fun銆傛墍浠ヤ笉蹇呭彟澶栧疄鐜伴拡瀵?R(*)() 鐨勭増鏈侺oki 錛堝涓斿氨浠ヤ綔鍝佸悕縐頒箮 Loki 鐨勪綔鑰呭惂錛屼粬閭d釜鐪熷悕瀹炲湪鏄お闀匡級鍦ㄤ粬鐨勪功涓О涔嬩負鈥?font face="Consolas">鍋氫竴涓紝閫佷竴涓?/font>鈥濄備笉榪囧浜庝粬涔︿腑鎵璇寸殑錛屾垜鏈変竴涓枒鎯戙侺oki 璇翠紶鍏?fun錛屾ā鐗堝弬鏁?T 浼氳鐗瑰寲鎴?R (&)()錛屼簬鏄竴鍒囬『鍒┿傚彲鏄垜鍦ㄦ搷浣滆繃紼嬩腑鍙戠幇 T 涓鐩磋鐗瑰寲鎴?R ()錛屼簬鏄笂榪?class 涓殑 m_Fun 琚涓烘槸鎴愬憳鍑芥暟鑰屼笉鏄垚鍛樺彉閲忋備笉鐭ラ亾鏄負浠涔堬紝鏈夌煡閬撹呰涓嶅悵鎸囨暀鍝堛傚洜涓轟互涓婂師鍥狅紝鏈枃涓垜涓鐩寸敤 &fun 鐨勫艦寮忓寰呮櫘閫氬嚱鏁般?/p>

鍐嶅疄鐜頒竴涓垚鍛樺嚱鏁扮殑鐗堟湰錛?/p>

template <typename R, typename T>
class MemberFunction0 : public FunctionBase0<R>
{
public:
    R Invoke()
    {
        return (m_pObj->*m_pMemFun)();
    }

public:
    MemberFunction0(T *pObj, R (T::*pMemFun)())
        : m_pObj(pObj), m_pMemFun(pMemFun)
    {

    }

private:
    R (T::*m_pMemFun)();
    T *m_pObj;
};

鏈鍚庢槸涓涓寘瑁呯被銆傚鏋滀綘鍙互鎺ュ彈 Function<int> 琛ㄧず int()錛?Function<int, int> 琛ㄧず int (int)錛屸︼紝閭d箞榪欓噷娌℃湁澶氬皯鎶宸у彲璦銆俠oost 鐨勯偅涓?function 浣跨敤鐨勬槸鍑芥暟絳懼悕浣滀負妯$増鍙傛暟錛屽嵆 Function<int()>錛孎unction<int (int)> 絳夊艦寮忋傚鏋滀笉澶爺絀惰娉曪紝鍙兘浼氬儚鎴戜竴鏍鳳紝涓寮濮嬩細瀵瑰皷鎷彿閲岀殑 int (int) 涔嬬被鐨勭帺鎰忓効涓嶅お鐔熸倝錛岃寰楀緢鐗涢箋傚彲鏄簡瑙d簡浠ュ悗錛屼笉榪囨槸涓嚱鏁扮被鍨嬭屽凡錛屾病浠涔堝ぇ涓嶄簡鐨勩侺oki 鐨?Functor 鐨勪嬌鐢ㄦ柟寮忔槸 Functor<int, TYPELIST_0()>錛孎unctor<int, TYPELIST_1(int)>銆傚叾涓涓涓ā鐗堝弬鏁板緇堟槸榪斿洖鍊鹼紝絎簩涓ā鐗堝弬鏁版槸鍙傛暟綾誨瀷鍒楄〃錛孡oki 浣跨敤浜嗕粬鍒涢犵殑鐜╂剰鍎?TypeList 浣垮緱鎵鏈夊嚱鏁板弬鏁板彧鍗犱竴涓潙錛岃繖鍦ㄧ瓑涓嬬殑鏀寔澶氬弬鏁扮殑鎵╁睍涓兘澶熷甫鏉ヤ竴浜涚編瑙傘傛垜姣旇緝鍠滄 boost 鐨勪嬌鐢ㄦ柟寮忥紝璁╀嬌鐢ㄨ呯洿鎺ヤ互璇█瑙勫畾鐨勫艦寮忓~鍏ュ嚱鏁扮鍚嶏紝鑰屼笉鏄竴浜涢澶栫殑綰﹀畾錛堚滅涓涓ā鐗堝弬鏁拌〃紺鴻繑鍥炲尖濓紝鈥滅浜屼釜鍒版渶鍚庣殑妯$増鍙傛暟琛ㄧず鍙傛暟鈥濓紝鈥滅浜屼釜妯$増鍙傛暟浠?TypeList 褰㈠紡琛ㄧず鍑芥暟鍙傛暟鈥濈瓑錛夈?/p>

涓轟簡杈懼埌榪欎釜鐩爣錛屾垜浠鐜╀竴浜涘亸鐗瑰寲鎶宸с傚叧浜庡亸鐗瑰寲錛屾垜涓鐩翠互鏉ョ殑鑲ゆ祬璁よ瘑閮芥槸閿欒鐨勩傛垜鍘熶互涓猴紝瀵逛簬妯$増綾伙細

template <typename T0, typename T1>
class Foo;

鎴戝鏋滅壒鍖栧叾涓竴涓弬鏁?T1錛?/p>template <typename T0>
class Foo<T0, int>
{

}

鎴戜互涓哄彧鏈夎繖鏍鋒墠鍙亸鐗瑰寲錛屼互涓哄亸鐗瑰寲鐨勮繃紼嬫繪槸鍑忓皯妯$増鍙傛暟鐨勩傝屽疄闄呬笂錛屽彧瑕佺敤鏌愪釜/浜涚被鍨嬪崰鎹師濮嬫ā鐗堝弬鏁扮殑浣嶇疆錛屽氨鍙互浜嗐傛瘮濡傦紝瀵逛簬涓婅堪 Foo錛屾垜鍙互鐗瑰寲涓涓?class<T0, std::map<U0, U1>>錛屾秷鍘諱竴涓?T1錛岃屾柊澧?U0銆乁1錛?/p>template <typename T0, typename U0, typename U1>
class Foo<T0, std::map<U0, U1>>
{

}

鍘熸潵 T1 鐨勪綅緗 std::map<U0, U1> 鍗犳嵁浜嗭紝榪欎篃鏄亸鐗瑰寲銆傚綋鐒舵渶鍚庣殑妯$増鍙傛暟鏁伴噺涔熷彲浠ヤ笉鍙橈紝濡傦細

template <typename T0, typename U>
class Foo<T0, std::vector<U>>
{

}

浠ュ強

template <typename T0, typename U>
class Foo<T0, U*>
{

}

鍏朵腑鍚庤呮槸瀹炵幇綾誨瀷钀冨彇鐨勪富瑕佹柟寮忋傚彧瑕佺壒鍖栦互鍚庯紝榪欎釜綾諱緷鐒跺甫鏈夎嚦灝戜竴涓ā鐗堝弬鏁幫紝灝辨槸鍋忕壒鍖栥傚鏋滄渶鍚庝駭鐢熶簡 template<> 鐨勫艦寮忥紝閭e氨鏄畬鍏ㄧ壒鍖栥?/p>

鍥炲埌鎴戜滑鍒氭墠鐨勪富棰橈紝鎴戜滑瑕佹彁渚涚粰鐢ㄦ埛鐨勬槸榪欐牱涓涓被錛?/p>

template <typename Signature>
class Function;

鍏朵腑鍙傛暟 Signature 浼氳瀹為檯鐨勫嚱鏁扮被鍨嬫墍鐗瑰寲銆備絾鏄垜浠彧鐭ラ亾鏁翠綋鐨勪竴涓?Signature 騫舵病鏈夌敤錛屾垜浠繀欏葷煡閬撹鍒嗚В寮鏉ョ殑榪斿洖鍊肩被鍨嬨佸弬鏁扮被鍨嬨備簬鏄紝寮曞叆涓涓亸鐗瑰寲鐗堟湰錛?/p>

template <typename R>
class Function<R ()>

榪欓噷浣跨敤 R () 鐗瑰寲鍘熷鐨?Signature錛屽紩鍏ヤ竴涓柊鐨勫弬鏁?R銆備簬鏄繑鍥炲肩被鍨?R 灝辮钀冨彇鍑烘潵浜嗐傚疄鐜板涓嬶細

template <typename R>
class Function<R ()>
{
public:
    template <typename T>
    Function(const T &fun)
        : m_pFunBase(new Function0<R, T>(fun))
    {
       
    }

    template <typename T>
    Function(T *pObj, R (T::*pMemFun)())
        : m_pFunBase(new MemberFunction0<R, T>(pObj, pMemFun))
    {

    }

    ~Function()
    {
        delete m_pFunBase;
    }

    R operator ()()
    {
        return m_pFunBase->Invoke();
    }

private:
    FunctionBase0<R> *m_pFunBase;
};

濡傛灉瀵逛笂闈㈣鐨勨滄櫘閫氬嚱鏁扮殑浣跨敤鏂瑰紡蹇呴』鏄嚱鏁版寚閽堣屼笉鏄嚱鏁版湰韜濊胯夸簬鎬錛屽彲浠ュ啀寮曞叆涓涓殑鏋勯犲嚱鏁幫細

typedef R (FunctionType)();

Function(const FunctionType &fun)
    : m_pFunBase(new Function0<R, FunctionType &>(fun))
{

}

榪欓噷 FunctionType 鏄?R(&)() 綾誨瀷錛屽己鍒朵嬌鐢ㄥ畠鏉ョ壒鍖?Function0 涓殑 T銆傝鏋勯犲嚱鏁板湪閲嶈澆鍐寵涓細鍙栧緱浼樺厛鏉冧粠鑰屼嬌鏅氬嚱鏁版湰韜殑浼犲叆鎴愪負鍙兘銆備笉榪囷紝浠ュ嚱鏁版湰韜艦寮忎紶鍏ョ殑鏅氬嚱鏁頒細涓уけ涓浜涚壒鎬э紝姣斿 Function<int()> 鍙兘鎺ュ彈 int() 綾誨瀷鐨勬櫘閫氬嚱鏁拌屼笉鑳芥帴鍙?char () 鍨嬬殑鏅氬嚱鏁幫紝鍥犱負榪欑鎯呭喌涓嬩笉浼氳蛋鎴戜滑鍒氭墠鏂板畾涔夌殑鏋勯犲嚱鏁般?/p>

榪樻湁涓縐嶅仛娉曪紝灝辨槸閽堝鍏ㄥ眬鍑芥暟錛屽己鍒剁壒鍖栧嚭妯$増鍙傛暟涓哄叾寮曠敤綾誨瀷鐨勭被銆傚畾涔夊涓嬪厓鍑芥暟錛?/p>

template <typename Signature>
struct FunctionTraits
{
    typedef Signature ParamType;
};
   
template <typename RetType>
struct FunctionTraits<RetType ()>
{
    typedef RetType (&ParamType)();
};

鐒跺悗鏋勯犲嚱鏁版敼涓猴細

    template <typename T>
    Function(const T &fun)
        : m_pFunBase(new Function0<R, typename FunctionTraits<T>::ParamType>(fun))
    {
       
    }

鐢ㄤ互涓婃柟娉曪紝鎵鏈夌殑鐗規ч兘涓嶄細涓㈠け銆?/p>

鍒拌繖鍎匡紝鎴戜滑鐨?Function 宸茬粡鍙互灝忚瘯鐗涘垁浜嗭細

Function<int ()> f1(&intfun0);

Function<int ()> f1_(intfun0);
Function<int ()> f2(intfunctor0);
Function<int ()> f3(&test, &Test::intmem0);

f1();
f1_();
f2();
f3();

涓婇潰榪欐浠g爜宸茬粡鑳藉姝e父榪愯浜嗐?/p>

鏉ワ紝緇х畫鍋氫竴涓紝閫佷竴涓?/strong>銆備笅闈㈢殑浠g爜灞呯劧涔熻兘璺戯紙voidfun0銆乿oidfunctor0銆乀est::voidmem0綾諱技int鐗堟湰瀹氫箟錛夛細

Function<void ()> f4(&voidfun0);
Function<void ()> f4_(voidfun0);
Function<void ()> f5(voidfunctor0);
Function<void ()> f6(&test, &Test::voidmem0);

f4();
f4_();
f5();
f6();

榪欒鏄庝簡錛屽湪綾婚噷闈㈠啓涓涓繑鍥炲間負璇ョ被鍨嬬殑鍑芥暟錛屽茍鍦ㄩ噷闈㈠啓涓?return XXX; 鐒跺悗浠?void 涓烘ā鐗堝弬鏁頒紶鍏ヨ妯$増綾伙紝鏄鍚堣娉曠殑銆傞獙璇佷竴涓嬶細

template <typename T>
class Foo
{
public:
    T Bar()
    {
        printf("%s invoked\n", __FUNCTION__);
        return T();
    }
};

int main()
{
    Foo<void> f1;
    f1.Bar();

    Foo<int> f2;
    int i = f2.Bar();

    return 0;
}

榪愯緇撴灉錛?/p>

Foo<void>::Bar invoked
Foo<int>::Bar invoked

鍒版涓烘錛屾垜浠凡緇忓疄鐜頒簡 0 涓弬鏁扮殑鍑芥暟鏀寔錛屼篃鍗?R () 綾誨瀷鐨勬墍鏈夊嚱鏁扮殑鏀寔銆傛帴涓嬫潵榪樿瀹炵幇瀵瑰叿鏈?1 涓? 涓? 涓洿鑷充換鎰忔湁闄愪釜鍙傛暟鐨勫嚱鏁版敮鎸併備篃璁告偍涔熷彂鐜頒簡錛屾帴涓嬫潵鐨勫伐浣滃彲浠ユ槸浣撳姏媧伙紝鎴戜滑鍙互鐓ц懌鑺︾敾鐡紝鎼炲嚭涓鍫?FunctionBaseN銆丗unctionN銆丮emberFunctionN錛屽茍鍦ㄦ渶鍚庣殑 Function 涓啀瀹炵幇 N 涓亸鐗瑰寲鐗堟湰銆傛槸錛屼笉閿欙紝澶ц嚧涓婂師鐞嗗氨鏄繖鏍楓傞檺浜庣瘒騫咃紝鎴戞兂鏆傛椂鍐欏埌榪欓噷錛屼笅綃囧皢緇х畫璋堣皥瀹忋乀ypeList錛屼互鍙婃庢牱灝戣姳鐐瑰姏姘斿疄鐜板叾浣?N 涓増鏈傛渶緇堣揪鍒扮殑鏁堟灉鏄紝鍙鏀逛竴涓畯瀹氫箟錛屽氨鍙互鎻愰珮鍙傛暟涓婇檺銆?/p>

鍦ㄦ湰鏂囨墍娑夊強鐨勫唴瀹逛腑錛屾垜姣旇緝綰犵粨鐨勬槸錛屽彲鍚﹀湪涓嶇敤澶氭佹満鍒剁殑鎯呭喌涓嬭揪鍒版瘮杈冧紭闆呯殑褰㈠紡緇熶竴錛?/p>

嬈㈣繋璁ㄨ銆?/p>

婧祦 2011-01-16 22:17 鍙戣〃璇勮
]]>
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
      <noscript id="pjuwb"></noscript>
            <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
              <dd id="pjuwb"></dd>
              <abbr id="pjuwb"></abbr>
              中文精品视频| 亚洲人成精品久久久久| 亚洲综合成人在线| 国产麻豆视频精品| 久久久另类综合| 久久天堂精品| 亚洲毛片在线看| 99re8这里有精品热视频免费 | 美女脱光内衣内裤视频久久网站| 亚洲第一精品电影| 亚洲精品久久久久久久久久久久 | 亚洲图片欧美一区| 午夜亚洲一区| 亚洲欧洲视频在线| 中文亚洲字幕| 亚洲福利在线视频| 一区二区三区四区五区视频| 国产欧美综合一区二区三区| 欧美福利专区| 国产精品麻豆欧美日韩ww| 久久婷婷人人澡人人喊人人爽| 欧美 日韩 国产在线| 亚洲一区在线视频| 久久婷婷成人综合色| 亚洲在线一区二区| 久久伊人亚洲| 欧美一区二区在线| 欧美激情一区二区三级高清视频| 欧美一区二区三区在| 欧美国产日韩一区| 久久天天躁狠狠躁夜夜爽蜜月| 欧美日韩国产在线播放| 另类亚洲自拍| 国产精品一页| 中文日韩电影网站| 99国产精品视频免费观看| 久久se精品一区二区| 亚洲影院高清在线| 欧美成在线观看| 久久夜色精品国产欧美乱极品| 欧美日韩午夜在线视频| 欧美99在线视频观看| 国产视频精品免费播放| 亚洲午夜久久久久久尤物| 日韩网站在线观看| 美女主播精品视频一二三四| 久久久久久亚洲精品中文字幕| 欧美色视频在线| 亚洲国产精品久久| 伊伊综合在线| 久久蜜桃香蕉精品一区二区三区| 欧美特黄一区| 亚洲精品美女在线| 99国产精品99久久久久久| 欧美成va人片在线观看| 欧美.com| 亚洲人被黑人高潮完整版| 久久伊人精品天天| 欧美成人免费网站| 亚洲精品1区2区| 欧美高清不卡在线| 亚洲激情偷拍| 在线亚洲一区| 欧美亚州一区二区三区| 一区二区三区日韩| 午夜日韩在线| 国产日韩在线亚洲字幕中文| 午夜天堂精品久久久久| 久久aⅴ乱码一区二区三区| 国产欧美精品一区aⅴ影院| 亚洲自拍16p| 久久伊人免费视频| 亚洲国产影院| 欧美精品色网| 亚洲午夜羞羞片| 久久激情五月婷婷| 在线精品国产成人综合| 欧美ab在线视频| 一区二区电影免费观看| 欧美一区二区三区另类| 国产主播一区二区| 女女同性精品视频| 亚洲伦理在线观看| 久久av二区| 亚洲欧洲一区二区三区| 欧美视频中文在线看| 欧美一区二区三区四区在线| 欧美成人免费全部| 中国亚洲黄色| 国内久久精品| 欧美日韩国产麻豆| 欧美一区二区三区视频| 欧美激情国产日韩| 西瓜成人精品人成网站| 在线成人激情黄色| 欧美性理论片在线观看片免费| 羞羞色国产精品| 亚洲国产乱码最新视频| 午夜性色一区二区三区免费视频| 永久久久久久| 国产精品久久一级| 美日韩精品免费| 亚洲欧美精品在线| 亚洲国产一区二区三区青草影视 | 亚洲欧美激情四射在线日 | 欧美大色视频| 欧美一区二区三区婷婷月色| 亚洲电影免费观看高清| 欧美亚洲在线播放| 日韩视频永久免费| 黄色成人片子| 国产精品日韩欧美综合| 欧美不卡一区| 久久免费视频在线| 亚洲制服av| 99国产麻豆精品| 性欧美超级视频| 久久亚洲国产精品日日av夜夜| 久久久久www| 国产精品每日更新| 99re6这里只有精品视频在线观看| 久久精品成人| 亚洲男人天堂2024| 欧美亚男人的天堂| 亚洲在线一区二区| 亚洲欧美日韩国产综合精品二区| 欧美国产一区二区三区激情无套| 欧美激情视频给我| 午夜在线观看免费一区| 久久亚洲美女| 欧美在线二区| 亚洲影院在线观看| 一区二区三区**美女毛片| 欧美激情一区二区久久久| 另类天堂av| 美日韩免费视频| 蜜月aⅴ免费一区二区三区| 久久久91精品国产一区二区三区 | 一本一本久久a久久精品综合妖精| 欧美电影免费观看高清| 久久综合色8888| 老司机免费视频久久| 久久三级福利| 免费亚洲电影| 亚洲电影免费在线观看| 欧美高清在线一区二区| 欧美国产一区二区在线观看| 欧美激情一区二区三区在线视频观看 | 国产日韩久久| 国产一区香蕉久久| 在线日韩欧美视频| 亚洲精品欧洲精品| 亚洲最新在线视频| 亚洲欧美日韩精品久久亚洲区| 午夜精品剧场| 久久久久国产一区二区| 欧美不卡在线视频| 最新中文字幕一区二区三区| 99精品热6080yy久久 | 一区二区三区日韩| 亚洲欧美日韩国产另类专区| 久久成人在线| 欧美成人免费小视频| 欧美日韩小视频| 国产日韩精品一区二区三区在线| 激情综合中文娱乐网| 亚洲精品乱码视频| 欧美一区二区三区在线免费观看| 久久影院午夜片一区| 亚洲国产精品电影| 亚洲在线网站| 麻豆久久久9性大片| 国产精品国产馆在线真实露脸| 国产欧美精品日韩| 亚洲伦理在线免费看| 欧美一区成人| 亚洲人成啪啪网站| 欧美亚洲一区在线| 欧美日韩久久精品| 欧美一区二区三区四区在线观看| 国产精品爽爽爽| 亚洲国产精品综合| 亚洲女性裸体视频| 欧美福利网址| 亚洲欧美在线观看| 欧美精品午夜| 精品二区视频| 午夜久久资源| 亚洲精品中文字幕在线| 久久国产免费看| 国产精品国产| 日韩一区二区精品葵司在线| 久久久亚洲国产美女国产盗摄| 亚洲精品久久久久久久久久久久久| 亚洲欧美日韩在线综合| 欧美日韩久久不卡| 亚洲欧洲日本一区二区三区| 久久久久久夜| 亚洲欧美在线观看| 国产精品美女www爽爽爽视频|