2016-03-19 9 views
0

次は私の打ち鳴らす形式クラン形式のアラインメントが壊れていますか?

--- 
AccessModifierOffset: '-4' 
AlignConsecutiveAssignments: 'true' 
AlignOperands: 'true' 
AlignTrailingComments: 'true' 
AllowShortCaseLabelsOnASingleLine: 'false' 
AllowShortIfStatementsOnASingleLine: 'true' 
AllowShortLoopsOnASingleLine: 'false' 
AlwaysBreakTemplateDeclarations: 'true' 
BinPackArguments: 'true' 
BinPackParameters: 'true' 
BreakBeforeBraces: Allman 
BreakConstructorInitializersBeforeComma: 'true' 
ColumnLimit: '80' 
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true' 
Cpp11BracedListStyle: 'true' 
IndentCaseLabels: 'false' 
IndentWidth: '4' 
MaxEmptyLinesToKeep: '2' 
NamespaceIndentation: All 
PointerAlignment: Left 
SpaceAfterCStyleCast: 'true' 
SpaceBeforeAssignmentOperators: 'true' 
SpaceBeforeParens: ControlStatements 
SpacesBeforeTrailingComments: '1' 
SpacesInParentheses: 'false' 
SpacesInSquareBrackets: 'false' 
Standard: Auto 
TabWidth: '4' 
UseTab: Always 

... 

あるしかし、私は、私は以下のような結果を得る++ファイルCでそれを実行したときに非整列の割り当ての問題領域は逐語的なコピーですが(コードは、ちんぷんかんぷんコピー&ペーストであります)私のコードで壊れたように私が見るものの

template <class X> 
void prettyPrint(std::ostream& o, const X* x) 
{ 
    o << "*{"; 
    if (x) 
    { 
     prettyPrint(o, *x); 
    } 
    else 
    { 
     o << "NULL"; 
    } 
    // I wanted the following assignments to align !!!! 
    using value_type   = std::decay_t<decltype(state)>; 
    using difference_type = std::ptrdiff_t; 
    using reference   = value_type&; 
    using pointer    = value_type*; 
    using iterator_category = std::input_iterator_tag; 

    o << "}"; 
} 

は、私は上記の動作が誤っ見つける

AlignConsecutiveAssignments: 'true' 

を設定したのsomethinがありますgの残りの部分で私の.clang-formatが結果を乱すか、これをバグとして報告すべきですか?

答えて

1

私は.clang形式でラインUseTab: Alwaysを削除することによって、あなたが望む方法をフォーマットすることができましたが、あなたが投稿スニペット:、私は...

を推測することができなかった理由として

template <class X> 
void prettyPrint(std::ostream& o, const X* x) 
{ 
    o << "*{"; 
    if (x) 
    { 
     prettyPrint(o, *x); 
    } 
    else 
    { 
     o << "NULL"; 
    } 
    // I wanted the following assignments to align !!!! 
    using value_type  = std::decay_t<decltype(state)>; 
    using difference_type = std::ptrdiff_t; 
    using reference   = value_type&; 
    using pointer   = value_type*; 
    using iterator_category = std::input_iterator_tag; 

    o << "}"; 
} 

編集:あなたは、少なくとも一つのタブストップから次へとまたがる空白を埋めるために必要があるときも動作しますUseTab: ForIndentationまたはNeverUseTab: Alwaysを使用してのみAlways休憩それを

1

は、タブを使用しています1。しかし、これらのタブは、それらの前にあるステートメントが長さが異なり、異なるタブストップに移動するタブを印刷するため、整列しません。

適切な代替手段は、名前が示唆するように、字下げにのみタブを使用するUseTab: ForIndentationを使用することです。

さらにはタブを使用しないUseTab: Neverです。

関連する問題