Thread overview
Style guide for indentation of template restrictions
Aug 22, 2020
Per Nordlöw
Aug 22, 2020
MoonlightSentinel
Aug 23, 2020
Per Nordlöw
August 22, 2020
Is there code convention for the indentation of template restrictions?

Should a restriction be indented as

    void f(U)(U a, ref U b)
        if (isUnsigned!U)

or not as in

    void f(U)(U a, ref U b)
    if (isUnsigned!U)

?
August 22, 2020
On Saturday, 22 August 2020 at 20:26:40 UTC, Per Nordlöw wrote:
> Is there code convention for the indentation of template restrictions?
>
> Should a restriction be indented as
>
>     void f(U)(U a, ref U b)
>         if (isUnsigned!U)
>
> or not as in
>
>     void f(U)(U a, ref U b)
>     if (isUnsigned!U)
>
> ?

The D Style suggests the latter, see https://dlang.org/dstyle.html#phobos_declarations
August 23, 2020
On Saturday, 22 August 2020 at 22:15:04 UTC, MoonlightSentinel wrote:
> On Saturday, 22 August 2020 at 20:26:40 UTC, Per Nordlöw wrote:
>> Is there code convention for the indentation of template restrictions?
>>
>> Should a restriction be indented as
>>
>>     void f(U)(U a, ref U b)
>>         if (isUnsigned!U)
>>
>> or not as in
>>
>>     void f(U)(U a, ref U b)
>>     if (isUnsigned!U)
>>
>> ?
>
> The D Style suggests the latter, see https://dlang.org/dstyle.html#phobos_declarations

If so, dfmt's `dfmt_template_constraint_style` [1] should default to

   conditional_newline

or

   always_newline

instead of

   conditional_newline_indent

[1] https://github.com/dlang-community/dfmt#dfmt-specific-properties