Top > C++ > コーディングスタイルの悩み

コーディングスタイルの悩み Edit

シンプルなルールでコーディングスタイルを定義したいのだけども中々シンプルにできない。
そんな悩みをつらつらと書いておくだけのページ。

中括弧の位置を統一したい Edit

中括弧を後ろに統一したら...

Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 
-
!
 
-
!
 
 
 
-
!
 
 
 
 
 
 
 
-
!
 
 
 
 
 
 
 
 
-
!
 
// これはいい
class Hoge {
};
 
Vector3::Vector3() {
}
 
void Vector3::func(
    const float aParam
    ) {
}
 
// これは...
Vector3::Vector3( 
    const float aX
    , const float aY
    )
: x( aX )
, y( aY ) {
}
 
// こう考えると少し救われるか
Vector3::Vector3( 
    const float aX
    , const float aY
    )
    : x( aX )
    , y( aY ) 
    {
}

namespaceの括弧の位置 Edit

気持ち悪いのよ。

Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 
-
-
!
|
|
-
!
|
|
-
-
!
!
|
|
-
!
|
// 開きは二行,閉じは一行,気持ち悪い。でも見やすい。
namespace root { 
namespace foo {
}}
 
// 開きも閉じも一行。見づらい。
namespace root { namespace foo {
}}
 
// 閉じ二行にするか!?
namespace root {
namespace foo {
}
}
 
// こう書けたらどれだけ幸せか
namespace root.foo {
}

括弧とその後の式の位置 Edit

引数リストとそれ以外と区別しちゃえばいいっちゃいいんだけどね

Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 
 
 
 
 
 
 
 
 
 
-
!
 
// 一行で収まらないときは改行したい
hoge.longlonglonglongFunc(
    longlonglonglonglonglongParam
    , longlonglonglonglonglongParam
    );
 
// でもこれだとなんか気持ち悪いのよねぇ
if ( 
    longlonglonglonglonglonglonglongParam 
    && longlonglonglonglonglonglonglongParam 
    ) {
}

Reload   New Lower page making Edit Freeze Diff Upload Copy Rename   Front page List of pages Search Recent changes Backup Referer   Help   RSS of recent changes
Last-modified: (3952d)