Did You Know, “new (nothrow) T” Throws?
Posted on August 1st, 2010 at 20:08 by fr3@K

可能會出乎不少人的意料, 下面的 code snip 可能會拋出 exception.

    Listing-1.

    C++:
    1. using namespace std;
    2. T* new_t_nothrow()
    3. {
    4.   return new (nothrow) T;
    5. }

(more...)

del.icio.us:Did You Know,  digg:Did You Know,  spurl:Did You Know,  newsvine:Did You Know,  furl:Did You Know,  Y!:Did You Know,  黑米共享書籤:Did You Know,  推推王:Did You Know,
You Don’t Have to Resort to Goto
Posted on June 19th, 2010 at 22:35 by fr3@K

你一定看過這樣的 code:

    C:
    1. int do_something(size_t n)
    2. {
    3.   int result = ERROR;
    4.   char* buf;
    5.  
    6.   if(n)
    7.   {
    8.     buf =  malloc(n);
    9.     if(buf != 0)
    10.     {
    11.       if(do_foo(buf, n) == OKAY)
    12.       {
    13.         if(do_bar(buf, n) == OKAY)
    14.           result = OKAY;
    15.       }
    16.       free(buf);
    17.     }
    18.   }
    19.  
    20.   return result;
    21. }

可讀性差的巢狀 if block, 只為了堅持由一處 return.
(more...)

del.icio.us:You Don't Have to Resort to Goto digg:You Don't Have to Resort to Goto spurl:You Don't Have to Resort to Goto newsvine:You Don't Have to Resort to Goto furl:You Don't Have to Resort to Goto Y!:You Don't Have to Resort to Goto 黑米共享書籤:You Don't Have to Resort to Goto 推推王:You Don't Have to Resort to Goto
re: 解读google C++ code style谈对C++的理解
Posted on May 30th, 2010 at 16:11 by fr3@K

Screenshot-解读google C++ code style谈对C++的理解 - 那谁的技术博客 - C++博客 - Mozilla Firefox
想加入這篇 解读google C++ code style谈对C++的理解 的討論. 不幸由於不明原因, 一直被系統認為是廣告 (圖中紅字部份):

先留個底, 再看看該/能怎麼辦吧.

ps. cppblog 帳號申請中, 也許有帳號就沒這問題了吧? 不過, 看起來申請帳號要經過人工審核...
(more...)

del.icio.us:re: 解读google C++ code style谈对C++的理解 digg:re: 解读google C++ code style谈对C++的理解 spurl:re: 解读google C++ code style谈对C++的理解 newsvine:re: 解读google C++ code style谈对C++的理解 furl:re: 解读google C++ code style谈对C++的理解 Y!:re: 解读google C++ code style谈对C++的理解 黑米共享書籤:re: 解读google C++ code style谈对C++的理解 推推王:re: 解读google C++ code style谈对C++的理解
後方, 起浪了
Posted on May 4th, 2010 at 23:54 by fr3@K

後方的浪.

del.icio.us:後方, 起浪了 digg:後方, 起浪了 spurl:後方, 起浪了 newsvine:後方, 起浪了 furl:後方, 起浪了 Y!:後方, 起浪了 黑米共享書籤:後方, 起浪了 推推王:後方, 起浪了
Quiz on C++ Object Model
Posted on March 4th, 2010 at 0:07 by fr3@K

這幾個月忙於工作, 這個部落格都快被我給荒廢掉了. 昨晚終於花了時間完成了一篇積了一兩個月, 說明 virtual function 在執行時期的 override 過程以及 virtual function 與 constructor/destructor 混搭結果 的文字.

今天我準備了個題目給花了時間看了它的朋友, 當作對小弟的說明能力來個測驗. 請問, 下面的 code snip 的輸出結果是什麼?
(more...)

del.icio.us:Quiz on C++ Object Model digg:Quiz on C++ Object Model spurl:Quiz on C++ Object Model newsvine:Quiz on C++ Object Model furl:Quiz on C++ Object Model Y!:Quiz on C++ Object Model 黑米共享書籤:Quiz on C++ Object Model 推推王:Quiz on C++ Object Model
當 Constructor 遇上 Virtual Function
Posted on March 3rd, 2010 at 0:19 by fr3@K

Background

不知道你有沒有過這樣的經驗 - 想要在父類的 constructor 裏面呼叫被子類 override (或是 implement) 的 (pure) virtual function?
(more...)

del.icio.us:當 Constructor 遇上 Virtual Function digg:當 Constructor 遇上 Virtual Function spurl:當 Constructor 遇上 Virtual Function newsvine:當 Constructor 遇上 Virtual Function furl:當 Constructor 遇上 Virtual Function Y!:當 Constructor 遇上 Virtual Function 黑米共享書籤:當 Constructor 遇上 Virtual Function 推推王:當 Constructor 遇上 Virtual Function
[Update] boost::decay documentation issue
Posted on January 14th, 2010 at 17:35 by fr3@K

The issue with boost::decay documentation that I blogged about 10 days ago has been fixed in trunk.

del.icio.us:[Update] boost::decay documentation issue digg:[Update] boost::decay documentation issue spurl:[Update] boost::decay documentation issue newsvine:[Update] boost::decay documentation issue furl:[Update] boost::decay documentation issue Y!:[Update] boost::decay documentation issue 黑米共享書籤:[Update] boost::decay documentation issue 推推王:[Update] boost::decay documentation issue
boost::decay documentation issue
Posted on January 4th, 2010 at 20:48 by fr3@K

前陣子看了 Hubert 的 一個 boost::exception 的例子, 猛然注意到自己不確定 boost::decay 的作用.

去看了它的 文件, 才發現文件不盡然正確... 已 submit 了一個 ticket 給 Boost, 希望早日修正.

del.icio.us:boost::decay documentation issue digg:boost::decay documentation issue spurl:boost::decay documentation issue newsvine:boost::decay documentation issue furl:boost::decay documentation issue Y!:boost::decay documentation issue 黑米共享書籤:boost::decay documentation issue 推推王:boost::decay documentation issue
Bit-fu
Posted on January 3rd, 2010 at 11:40 by fr3@K

Did you know, for x is an integer, that -~x yields x + 1 and ~-x yields x - 1?

via: Advanced bit manipulation-fu.

del.icio.us:Bit-fu digg:Bit-fu spurl:Bit-fu newsvine:Bit-fu furl:Bit-fu Y!:Bit-fu 黑米共享書籤:Bit-fu 推推王:Bit-fu
Another Good Interview Question in C++
Posted on January 2nd, 2010 at 17:10 by fr3@K

elleryq 這篇 blog post 談到的 ctor (換成 dtor 也一樣) 呼叫 virtual function 狀況 (或說是 problem) 會是很好的 C++ programmer 面試題目. 可在口試時用以窺探 interviewee 對 C++ object model 的了解.
(more...)

del.icio.us:Another Good Interview Question in C++ digg:Another Good Interview Question in C++ spurl:Another Good Interview Question in C++ newsvine:Another Good Interview Question in C++ furl:Another Good Interview Question in C++ Y!:Another Good Interview Question in C++ 黑米共享書籤:Another Good Interview Question in C++ 推推王:Another Good Interview Question in C++

Page 1 of 9[ 1 ]2345»...Oldest