Project

General

Profile

Task #2529

code-style: line continuation

Added by Junxiao Shi over 5 years ago. Updated over 2 years ago.

Status:
New
Priority:
Normal
Category:
Docs
Target version:
-
Start date:
02/16/2015
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);
#1

Updated by Spyros Mastorakis almost 5 years ago

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

Updated by Junxiao Shi almost 5 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.

#3

Updated by Alex Afanasyev over 4 years ago

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

Updated by Davide Pesavento over 2 years ago

  • Target version deleted (v0.5)

Also available in: Atom PDF