Project

General

Profile

Actions

Task #2529

open

code-style: line continuation

Added by Junxiao Shi about 9 years ago. Updated almost 2 years ago.

Status:
New
Priority:
Low
Assignee:
-
Category:
Docs
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

Update rule 1.12 to specify how line continuation should be aligned in the following cases.

Case 1: beginning of expression on previous line is too close to right edge

// style 1
std::unordered_map<int, int> someLongUnorderedMapName = someLongFunctionName(1,
    yetAnotherLongFunctionNameThatIsNotGoingToFitOnTheSameLine());

// style 2
std::unordered_map<int, int> someLongUnorderedMapName = someLongFunctionName(1,
  yetAnotherLongFunctionNameThatIsNotGoingToFitOnTheSameLine());

// style 3
std::unordered_map<int, int> someLongUnorderedMapName = someLongFunctionName(
  1, yetAnotherLongFunctionNameThatIsNotGoingToFitOnTheSameLine());

Case 2: alignment of lambda body

// style 1
this->someMethodName(firstArgument, [captured] (const std::pair<int, int>& pair) -> int {
  if (pair.first < 0) {
    return pair.second;
  }
  else {
    return captured;
  }
}, thirdArgument);

// style 2
this->someMethodName(firstArgument,
                     [captured] (const std::pair<int, int>& pair) -> int {
                       if (pair.first < 0) {
                         return pair.second;
                       }
                       else {
                         return captured;
                       }
                     }, thirdArgument);

// style 3
this->someMethodName(firstArgument, [captured] (const std::pair<int, int>& pair) -> int {
    if (pair.first < 0) {
      return pair.second;
    }
    else {
      return captured;
    }
  }, thirdArgument);

// style 4
this->someMethodName(firstArgument, [captured] (const std::pair<int, int>& pair) -> int {
                                      if (pair.first < 0) {
                                        return pair.second;
                                      }
                                      else {
                                        return captured;
                                      }
                                    }, thirdArgument);

// style 5
this->someMethodName(firstArgument, [captured] (const std::pair<int, int>& pair) -> int {
  if (pair.first < 0) {
    return pair.second;
  }
  else {
    return captured;
  }
},
thirdArgument);

// style 6
this->someMethodName(firstArgument,
                     [captured] (const std::pair<int, int>& pair) -> int {
                       if (pair.first < 0) {
                         return pair.second;
                       }
                       else {
                         return captured;
                       }
                     },
                     thirdArgument);

// style 7
this->someMethodName(firstArgument, [captured] (const std::pair<int, int>& pair) -> int {
    if (pair.first < 0) {
      return pair.second;
    }
    else {
      return captured;
    }
  },
  thirdArgument);
Actions #1

Updated by Spyros Mastorakis over 8 years ago

  • Status changed from New to Code review
  • Assignee set to Spyros Mastorakis
  • % Done changed from 0 to 90
Actions #2

Updated by Junxiao Shi over 8 years ago

  • Status changed from Code review to New
  • % Done changed from 90 to 0

There hasn't been a consensus on which style to pick, so it's premature to create the rule and enter CodeReview stage.

Actions #3

Updated by Alex Afanasyev over 8 years ago

  • Target version changed from v0.4 to v0.5
Actions #4

Updated by Davide Pesavento about 6 years ago

  • Target version deleted (v0.5)
Actions #5

Updated by Davide Pesavento almost 2 years ago

  • Assignee deleted (Spyros Mastorakis)
  • Priority changed from Normal to Low
  • Start date deleted (02/16/2015)
Actions

Also available in: Atom PDF