Navigation Menu

Skip to content

Commit

Permalink
doc coding-style: add about increment
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Mar 16, 2012
1 parent a9f322b commit 3ef9d87
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions doc/source/developer/coding_style.rst
Expand Up @@ -520,3 +520,21 @@ C++では真偽値に ``bool`` を使うためこのような状況は発生し
name_ = std::string(name);
}
インクリメント・デクリメント
---------------------------

前置形式を用いる
^^^^^^^^^^^^^^^^

後置形式ではオブジェクトのコピーをしなければいけないため非効率である。そのため、できるだけ前置形式を用いる。

よい例( ``int`` だと効率は変わらないので本当はあんまりよい例ではない):

for (int i = 0; i < 10; ++i) {
}

悪い例(後置形式を用いている):

for (int i = 0; i < 10; ++i) {
}

0 comments on commit 3ef9d87

Please sign in to comment.