- Nov 07 Fri 2014 20:33
-
Practical Vim - chap 4 Visual Mode
- Nov 07 Fri 2014 11:52
-
Practical Vim - chap 3 Insert Mode
Tip 13. Make Corrections Instantly from Insert Mode
在插入模式下:
<C-h> 刪除前一個字符
<C-w> 刪除前一個 world
<C-u> 刪除至行首
- Nov 07 Fri 2014 11:28
-
Practical Vim - chap 2 Normal Mode
- Nov 07 Fri 2014 10:52
-
Practical Vim - chap 1 The Vim Way
- Jun 10 Tue 2014 19:33
-
C++ template: 3, Class Templates
3, Class Templates
相同於 function templates,class templates 也可藉由參數化手段,來表現一整個族群的 classes。
3.2
必須將具體型別當作 template arguments 傳入,才能使用 class template;接著該 class template 會以被指定的那些型別,由 compiler 加以 instantiate。
在 class template 中,只有被實際呼叫使用的 function,才會被 instantiate。
相同於 function templates,class templates 也可藉由參數化手段,來表現一整個族群的 classes。
3.2
必須將具體型別當作 template arguments 傳入,才能使用 class template;接著該 class template 會以被指定的那些型別,由 compiler 加以 instantiate。
在 class template 中,只有被實際呼叫使用的 function,才會被 instantiate。
- Jun 10 Tue 2014 19:31
-
C++ template: 2, Function Templates
2, Function Templates
所謂 function templates,是指藉由參數化手段,來表現一整個族群的 functions。
2.1.2
一般而言,templates 不會被 compile 成能夠處理任意型別的單一 entity,而是為每個特定型別,被 compile 成多個個別 instance。
以具體型別替代 template parameters 的過程,稱為 instantiation。
所謂 function templates,是指藉由參數化手段,來表現一整個族群的 functions。
2.1.2
一般而言,templates 不會被 compile 成能夠處理任意型別的單一 entity,而是為每個特定型別,被 compile 成多個個別 instance。
以具體型別替代 template parameters 的過程,稱為 instantiation。
- May 21 Wed 2014 17:52
-
Effective C++: Overview
一、Accustoming Yourself to C++
01、 View C++ as a federation of language.
將 C++ 視為一個由相關語言組成的聯邦語言,其主要的次語言有四種:
C、Object-Oriented C++、Template C++、STL。
02、 Prefer const, enum and inline to #define.
01、 View C++ as a federation of language.
將 C++ 視為一個由相關語言組成的聯邦語言,其主要的次語言有四種:
C、Object-Oriented C++、Template C++、STL。
02、 Prefer const, enum and inline to #define.
- Aug 31 Sat 2013 21:31
-
Effective C++:九、Miscellany
九、Miscellany
本章的第一個條款,強調不可輕忽 compiler warning messages。
第二個條款綜覽 C++ standard library,其中涵蓋由 TR1 引進的重大新機能。
第三個條款則綜覽 Boost,它是一個重要的 C++ 泛用型網站。
53、Pay attention to compiler warnings.
本章的第一個條款,強調不可輕忽 compiler warning messages。
第二個條款綜覽 C++ standard library,其中涵蓋由 TR1 引進的重大新機能。
第三個條款則綜覽 Boost,它是一個重要的 C++ 泛用型網站。
53、Pay attention to compiler warnings.
- Jul 13 Sat 2013 15:06
-
Effective C++:八、Customizing new and delete
八、Customizing new and delete
對比於 Java 和 .NET 的內建「垃圾回收能力」,C++ 對記憶體管理的純手工法看起來有點老氣,但許多苛刻的系統程式開發人員之所以選擇 C++,就是因為它允許手工管理記憶體,這樣的開發人員研究並學習軟體使用記憶體的行為特徵,然後修改配置和歸還工作,以求獲得其所建置的系統最佳效率。
這麼做的前提是,瞭解 C++ 記憶體管理常式的行為,兩個主角是 allocation and deallocation routines,也就是 operator new 和 operator delete,配角是 new-handler,這是當 operator new 無法滿足的記憶體需求的所喚起的 function。
multi-thread 的記憶體管理下,由於 heap 是一個可被改動的全域性資源,因此充斥著發狂存取這一類資源的 race condition 出現機會,本章中多個條款提及使用可改動之 static 資料,這總是會令 thread-aware programmer 高度警戒如坐針氈,因為如果沒有適當的 synchronization,一旦使用 lock-free algorithm,或沒有精心防止 concurrent access 時,呼叫記憶體常式可能很容易導致管理 heap 的資料結構內容敗壞。
另外,operator new 和 operator delete 只適合用來配置單一物件, Arrays 所用的記憶體由 operator new[] 配置出來,並由 operator delete[] 歸還,而除非特別表示,否則本章中每件關於 operator new 和 operator delete 的事,也都適用於 operator new[] 和 operator delete[]。
對比於 Java 和 .NET 的內建「垃圾回收能力」,C++ 對記憶體管理的純手工法看起來有點老氣,但許多苛刻的系統程式開發人員之所以選擇 C++,就是因為它允許手工管理記憶體,這樣的開發人員研究並學習軟體使用記憶體的行為特徵,然後修改配置和歸還工作,以求獲得其所建置的系統最佳效率。
這麼做的前提是,瞭解 C++ 記憶體管理常式的行為,兩個主角是 allocation and deallocation routines,也就是 operator new 和 operator delete,配角是 new-handler,這是當 operator new 無法滿足的記憶體需求的所喚起的 function。
multi-thread 的記憶體管理下,由於 heap 是一個可被改動的全域性資源,因此充斥著發狂存取這一類資源的 race condition 出現機會,本章中多個條款提及使用可改動之 static 資料,這總是會令 thread-aware programmer 高度警戒如坐針氈,因為如果沒有適當的 synchronization,一旦使用 lock-free algorithm,或沒有精心防止 concurrent access 時,呼叫記憶體常式可能很容易導致管理 heap 的資料結構內容敗壞。
另外,operator new 和 operator delete 只適合用來配置單一物件, Arrays 所用的記憶體由 operator new[] 配置出來,並由 operator delete[] 歸還,而除非特別表示,否則本章中每件關於 operator new 和 operator delete 的事,也都適用於 operator new[] 和 operator delete[]。
- Jul 01 Mon 2013 17:08
-
Function Pointer and Function Object
Function Pointer and Function Object
Function Pointer
函式指標的宣告方式如下所示:
傳回值型態 (*指標名稱) (傳遞參數)
ex: int (*func)(int, float, string); or int (*func)(int, int, int); ...
Function Pointer
函式指標的宣告方式如下所示:
傳回值型態 (*指標名稱) (傳遞參數)
ex: int (*func)(int, float, string); or int (*func)(int, int, int); ...
- Jun 29 Sat 2013 01:06
-
Effective C++:七、Templates and Generic Programming
七、Templates and Generic Programming
C++ template 的最初發展動機是:
建立「type-safe」的容器,如 vector, list 和 map。
後來發現 C++ template 有能力完成愈多可能的變化,容器當然很好,但 generic programming 寫出的程式碼和其所處理的物件型別彼此獨立 - 則更好。
最終發現 C++ template 機制本身是一部完整的 Turning-complete:
C++ template 的最初發展動機是:
建立「type-safe」的容器,如 vector, list 和 map。
後來發現 C++ template 有能力完成愈多可能的變化,容器當然很好,但 generic programming 寫出的程式碼和其所處理的物件型別彼此獨立 - 則更好。
最終發現 C++ template 機制本身是一部完整的 Turning-complete:
- Jun 20 Thu 2013 12:49
-
Static vs. Shared vs. Dynamic Loaded Library
Static vs. Shared vs. Dynamic Loaded Library
What is a Static Library?
The contents of this library are usually machine code files that are not readable by humans.
These machine code files are normally generated from code compilation or a similar process.
A static library is more flexible than a dynamic library becuase its exact path is irrelevant to the executable that uses it:
What is a Static Library?
A static library is more flexible than a dynamic library becuase its exact path is irrelevant to the executable that uses it: