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.
The issue with boost::decay documentation that I blogged about 10 days ago has been fixed in trunk.
Would you trust someone who had not seen a patient for years to teach surgery? What would you think of a piano teacher who never touched the keyboard? A CS education must bring a student beyond the necessary book learning to a mastery of its application in complete systems and an appreciation of aesthetics in code.
這句話說得真好.
via: What Should We Teach New Software Developers? Why? – Bjarne Stroustrup.
前陣子看了 Hubert 的 一個 boost::exception 的例子, 猛然注意到自己不確定 boost::decay 的作用.
Did you know, for x is an integer, that -~x yields x + 1 and ~-x yields x - 1?
加入現在服務的公司約 20 個月了, 當然不是 (也不可能會) 所有的事情都是令人開心的. Nevertheless, I am glad that I work here. IMHO, 如果要留在台灣認真搞 software R&D 與 engineering, 這裡絕對是最好的環境之一.
(more…)
elleryq 的 這篇 blog post 談到的 ctor (換成 dtor 也一樣) 呼叫 virtual function 狀況 (或說是 problem) 會是很好的 C++ programmer 面試題目. 可在口試時用以窺探 interviewee 對 C++ object model 的了解.
(more…)
Very well put
當你發現回傳的是一個 char *,又沒有要求你特別 free 他,你是不是就該猜測他是回傳 function 內部的一個 static buffer 了呢?
When you lie to your compiler, don’t be surprised to get results those differ from what you expect.
In this case, the coder promised his/her compiler the value of “value” won’t be changed, as it was declared const.
Therefore our best friend (yes, the compiler) who trusted the coder, thought “hey, I could cache this value in a register and not fetch it from RAM every time I reference it”, i.e. optimization.
If we change the code in the link slightly, so that function funcC would print *value before the assignment, one would see that the value of *value had actually been modified by function funcA. However, the modification was not visible in main, because the compiler was lied to as the coder explicitly told it that there would be no modification to value.
In the body of function funcC, though value was declared as a pointer to const instance, the compiler was smart enough to know it was lied to. There was a const_cast and a assignment, therefore, the modification to *value was reflected in the output.
It is true that C++ provides programming constructs those consume more CPU cycles than it would when done without higher level of abstractions. But, hey, that’s the cost of abstractions, why pay when they are not needed?
Stop laying out your C++ design like Java. Avoid inheritance when possible. Don’t make every member function and destructor virtual without really thinking. They not only increase your run time overhead, they boost the complexity (read coupling) of your code like nothing else.
C++ does every C-style stuff the same way as C does. Not to mention it is capable of more compile time computation than C. I just fail to see how C++ could be slower than C in run time, seriously.
Except where otherwise noted, COdE fr3@K by
fr3@K is licensed under a
Creative Commons Attribution-Share Alike 3.0 License.