dice-group / tentris-cpp-coding-guidelines

0 stars 0 forks source link

Possible unintented formatting styles #11

Open nkaralis opened 2 months ago

nkaralis commented 2 months ago

I have compiled a list of formatting styles that we might not want to follow.

A:

template<typename T, typename U>
concept DummyConcept
    =  Dummy1<T>
    && Dummy1<U>
    && Expr1 == Expr2
    && Expr3 == Expr4

is formatted to a single line

@bigerl: this can probably be prevented with an // at the end of each line. Is it still wrapped if lines get too long?

B:

static_assert(Expr1
              && Expr 2)

is formatted to a single line

@bigerl: same as A

C:

template<typename T> requires Dummy1<T> or Dummy2<T>

is formatted to multiple lines. I do not think that it is an issue, but I wanted to double check if it intended

@bigerl: how does it look then?

D:

std::variant<Type1,
             Type2,
             Type3> data;

`data` is pushed to a new line.

@bigerl: I think that should not happen.

E:

{ T::func(arg1, arg2) } -> Type;

in concepts, such definitions are formatted to multiple lines (example below)
{ 
    T::func(arg1, arg2)
    } -> Type;

@bigerl: I think that should not happen but I am afraid that clang-format might not allow us to configure that.

F:

if {
    ...
}
// comment
else {

}

the brace next to `else` is pushed to a new line

@bigerl: I would suggest to put the comment to the bracket like: } else { // comment

G:

auto val = []() -> auto {
    ...
}();
the parenthesis `()` for calling the lambda are pushed to a new line

@bigerl: I think that should not happen

H:

DICE_DEFER { tentris_solution_generator_free(q); };

is formatted to multiple lines

@bigerl: I think that should not happen but here I am also not sure if we can prevent clang-format to do that.

H:

function_call(
    "..."
    "..."
).another_function_call();

.anothert_function_call is pushed to a new line

@bigerl: I think that should not happen.

bigerl commented 2 months ago

I've added my comments above

nkaralis commented 2 months ago

By "I think that should not happen.", do you mean that we need to find a way to prevent it?

Regarding A and B: Yes, it happens even in long lines.

Regarding C, it is written as follows

template<typename T>
requires Dummy1<T> or Dummy2<T>
bigerl commented 2 months ago

By "I think that should not happen.", do you mean that we need to find a way to prevent it?

yes. I was not sure how to formulate it :)

mcb5637 commented 1 month ago

Paradoxically i have found a solution for E and not for D, G and both Hs.

C: There is a setting for that, i can change it, if you prefer.