The C++0x “Remove Concepts” Decision
Posted on August 9th, 2009 at 19:24 by fr3@K

懶人包 + Bjarne on DDJ (翻譯), from Paramecium.

Great job! Thanks, Keiko.

del.icio.us:The C++0x  digg:The C++0x  spurl:The C++0x  newsvine:The C++0x  furl:The C++0x  Y!:The C++0x  黑米共享書籤:The C++0x  推推王:The C++0x
C++0x – Concepts Rejected
Posted on July 21st, 2009 at 10:17 by fr3@K

大件事, Concepts否決了.

del.icio.us:C++0x - Concepts Rejected digg:C++0x - Concepts Rejected spurl:C++0x - Concepts Rejected newsvine:C++0x - Concepts Rejected furl:C++0x - Concepts Rejected Y!:C++0x - Concepts Rejected 黑米共享書籤:C++0x - Concepts Rejected 推推王:C++0x - Concepts Rejected
STL Performance Boost in VS2010
Posted on June 27th, 2009 at 22:18 by fr3@K

幾個月前曾在一篇文字裡寫道: 正確的運用 Rvalue References, 有可能帶來可觀的 performance gain. 前幾天看到 Visual C++ Team Blog 新貼出對 STL (VS2010 vs. VS2008) 的 performance benchmark. 在一個程度上, 該篇文字可以說驗證了這個不只我一個人獨有的看法與對 C++0x 的期待.

Rvalue-References 帶來的 performance boost 或許比不上 Multi-Core STL 來得那麼 “方便”, 但絕對是你不會想要錯過的 low hanging fruit.

C++0x 的巨浪就要來了, 你準備好了嗎?

del.icio.us:STL Performance Boost in VS2010 digg:STL Performance Boost in VS2010 spurl:STL Performance Boost in VS2010 newsvine:STL Performance Boost in VS2010 furl:STL Performance Boost in VS2010 Y!:STL Performance Boost in VS2010 黑米共享書籤:STL Performance Boost in VS2010 推推王:STL Performance Boost in VS2010
I Like to Move It
Posted on May 19th, 2009 at 12:03 by fr3@K

喜愛 C++ 並關心 C++0x 標準的朋友一定會知道, C++0x 引進了許多新的元素. 不但對 Standard Library 有為數眾多的 addition 與 enhancement, 連 core language 都新增了不少東西. 而其中最重要的, 在我看來, 就是 Rvalue References. 即便不理會 C++0x 其他的新玩意 Rvalue References 依然是一個職業 C++ programmer 該要掌握的新 feature. 原因很簡單, 正確的運用 Rvalue References, 有可能帶來可觀的 performance gain.
(more…)

del.icio.us:I Like to Move It digg:I Like to Move It spurl:I Like to Move It newsvine:I Like to Move It furl:I Like to Move It Y!:I Like to Move It 黑米共享書籤:I Like to Move It 推推王:I Like to Move It
Re: Domain-Specific Language (DSL)
Posted on March 26th, 2009 at 15:09 by fr3@K

Keiko 寫了篇 討論 DSL 的文字. 這篇文字不短, 有層次. 有他說的 “學院派式” 的格調. 讓我有一種在看一份探討輪胎直徑與胎壓以及胎壁厚度之間關係的 paper 的 feel. 相形之下, 這裡寫的東西看起來更像是黑手示範如何補胎換胎的 howto.

好了, 細節不多談, 建議看官移架拜讀. 重點是, 本要在 comment 裏寫 code, 但這該死的 blogger 超難用, 讓我想起當年 從 blogger 離家出走 的原因. 又扯遠了, 回到我想回應給 Keiko 的東西.
(more…)

del.icio.us:Re: Domain-Specific Language (DSL) digg:Re: Domain-Specific Language (DSL) spurl:Re: Domain-Specific Language (DSL) newsvine:Re: Domain-Specific Language (DSL) furl:Re: Domain-Specific Language (DSL) Y!:Re: Domain-Specific Language (DSL) 黑米共享書籤:Re: Domain-Specific Language (DSL) 推推王:Re: Domain-Specific Language (DSL)
C++0x: More on Rvalue References
Posted on November 16th, 2008 at 22:57 by fr3@K

上一篇 的主題是 Rvalue References 的語意/語法與功能, 這篇要補完同樣是關於 Rvalue References, 但較為瑣碎的細節.
(more…)

del.icio.us:C++0x: More on Rvalue References digg:C++0x: More on Rvalue References spurl:C++0x: More on Rvalue References newsvine:C++0x: More on Rvalue References furl:C++0x: More on Rvalue References Y!:C++0x: More on Rvalue References 黑米共享書籤:C++0x: More on Rvalue References 推推王:C++0x: More on Rvalue References
C++0x: Rvalue References
Posted on November 16th, 2008 at 19:00 by fr3@K

Intro

Rvalue-References 是 C++0x 規範的新 language feature, 也是繼 Templates 後, IMO, C++ 語言最重要的 language feature. 其目的是為了支持 Move Semantics — 將 resource 從一個 instance 轉移到另一個 instance.

Rvalue — 這個聽起來饒舌的新名詞 — 說穿了其實就是 un-named instance (i.e. temporary), 反之, 有名字的 (named) 則為 lvalue. 而 const/volatile 與否則是額外的修飾. 也就是說, 一個 rvalue reference 其實就是 reference to a temporary.
(more…)

del.icio.us:C++0x: Rvalue References digg:C++0x: Rvalue References spurl:C++0x: Rvalue References newsvine:C++0x: Rvalue References furl:C++0x: Rvalue References Y!:C++0x: Rvalue References 黑米共享書籤:C++0x: Rvalue References 推推王:C++0x: Rvalue References
C++0x 風暴, 即將來襲
Posted on October 29th, 2008 at 15:49 by fr3@K

今天從 Sutter’s Mill 知道 最新的 C++0x draft (n2798) 已經正式 publish 以被 review 與 comment. Sutter 稱這 draft 為 feature complete.

也是今天, 在 Visual C++ Team Blog 看到 Visual Studio 2010 的 Community Technology Preview (CTP) 版本也 release 了 (按此前往下載頁面. Warning: 11 個 split 過的 rar, 約 7350 MB). 其中最令人興奮的正是對 C++0x 的支持:

  • Lambda Expressions (functional programming 來了, C++ 請接招)
  • Rvalue References (opportunity for major performance boost)
  • void foo()
    {
      list<string> strings;
      // strings.push_back("bar");
      strings.push_back(string("bar"));
    }
    

    這段 code 將只需要兩次 memory allocation, 一次在 list, 一次在 string. 因 "bar" string("bar") (note: see comment from icek) 而產生的 string 暫時物件的 resource 將直接轉移到 list 內部新創建的 element 身上 (move-construct). 不再是把該暫時物件 copy 到新創建的 element 身上 (copy-construct).

    Note: 雖然 VS10 的 C++ compiler 已經支援 Rvalue-References, 但由於 VS10 所 ship 的 STL (by Dinkumware) 尚未實現 Rvalue-References 的部份, 因此, 在 VC10 的 STL 改善之前, 上面的 code snip 仍然會觸發 string 的 copy-construction, 換句話說會引發三次 allocation.

  • static_assert (compile time 即可 assert 的不再需要等到 run time)
  • auto Keyword (懶人好幫手)
  • template <class Container>
    void bar(const Container& cont)
    {
      for(auto first = cont.begin(); first != cont.end(); ++first)
      {
        // do meaningful things here...
      }
    }
    

    別把用在此處的 auto 與 variant 混為一談, 兩者完全不同. 後者 (variant) 的型別 (或者說意義) 是 runtime 決定的 (可參考 Boost.VariantCOM 的 variant). 前者 (auto) 則是在 compile time 就決定了. 簡單的說, 是 compiler 在 compile 時藉由後面的敘述 (例中的 cont.begin()) 推導出 auto 定義的變數 (first ) 的 type.

另外, FOSS 陣營的王道 compiler, GCC, 則是一直有在 C++0x 的支持方面持續加強 (GCC 4.3/4.4). 不過 (就我所知) 還沒進入主流的 GNU/Linux distro.

del.icio.us:C++0x 風暴, 即將來襲 digg:C++0x 風暴, 即將來襲 spurl:C++0x 風暴, 即將來襲 newsvine:C++0x 風暴, 即將來襲 furl:C++0x 風暴, 即將來襲 Y!:C++0x 風暴, 即將來襲 黑米共享書籤:C++0x 風暴, 即將來襲 推推王:C++0x 風暴, 即將來襲
C++0x, Near Feature-Complete
Posted on July 8th, 2008 at 19:48 by fr3@K

From Sutter’s Mill:

… we already had a nearly-complete C++0x internal working draft — most features that will be part of C++0x had already been “checked in.” Only a few were still waiting to become stable enough to vote in, including initializer lists, range-based for loops, and concepts.

del.icio.us:C++0x, Near Feature-Complete digg:C++0x, Near Feature-Complete spurl:C++0x, Near Feature-Complete newsvine:C++0x, Near Feature-Complete furl:C++0x, Near Feature-Complete Y!:C++0x, Near Feature-Complete 黑米共享書籤:C++0x, Near Feature-Complete 推推王:C++0x, Near Feature-Complete
Strong Guarantee using Transaction
Posted on April 29th, 2008 at 23:24 by fr3@K

Abrahams Guarantees

在 C++ 的世界裡, 正確的 exception handling 是專業的 C++ programmer 不可或缺的技巧. 雖然它的概念並不困難, 但實作起來卻常不見得那麼容易.

要做到正確的 exception handling, 首先必須要了解什麼是 exception safety. 一個需要與 exception 打交道的 component 可在其介面實作人稱 Abrahams guarantees 的三種 exception safety 保證之一:

  1. The basic guarantee
  2. 允許操作失敗時改變物件的狀態, 但不能有 resource leak. 且該物件的狀態必須是可靠的仍然可以被解構, 操作失敗後該物件的狀態可以是不完全能被預測的.

  3. The strong guarantee
  4. 操作後的狀態只能是成功完成, 或是將該物件回復到操作之前的狀態並拋出一個 exception.

  5. The no-throw guarantee
  6. 操作不會拋出 exception.

(more…)

del.icio.us:Strong Guarantee using Transaction digg:Strong Guarantee using Transaction spurl:Strong Guarantee using Transaction newsvine:Strong Guarantee using Transaction furl:Strong Guarantee using Transaction Y!:Strong Guarantee using Transaction 黑米共享書籤:Strong Guarantee using Transaction 推推王:Strong Guarantee using Transaction

Page 1 of 2[ 1 ]2»