public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* Code style enforcement
@ 2021-12-24 10:44 Tejasvi Singh
  2021-12-24 12:18 ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: Tejasvi Singh @ 2021-12-24 10:44 UTC (permalink / raw)
  To: libstdc++

Hi,

While going through include/bits/stl-algo.h I noticed the return type is indented after template declaration. See below the indentation of return type _Function. The code formatting is enforced by clang-formatter (config at /contrib/clang-format) which does not indent the return type after template declaration. Is the inconsistency due to limitation of clang-format or a missing config option?

template<typename _InputIterator, typename _Function>
  _Function
  for_each(_InputIterator __first, _InputIterator __last, _Function __f)
  {
    // concept requirements
    __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
    __glibcxx_requires_valid_range(__first, __last);
    for (; __first != __last; ++__first)
  __f(*__first);
    return __f; // N.B. [alg.foreach] says std::move(f) but it's redundant.
  }

Tejasvi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Code style enforcement
  2021-12-24 10:44 Code style enforcement Tejasvi Singh
@ 2021-12-24 12:18 ` Jonathan Wakely
  2021-12-24 12:21   ` Jonathan Wakely
  2021-12-24 12:21   ` Jonathan Wakely
  0 siblings, 2 replies; 4+ messages in thread
From: Jonathan Wakely @ 2021-12-24 12:18 UTC (permalink / raw)
  To: Tejasvi Singh; +Cc: libstdc++

On Fri, 24 Dec 2021, 10:45 Tejasvi Singh via Libstdc++, <
libstdc++@gcc.gnu.org> wrote:

> Hi,
>
> While going through include/bits/stl-algo.h I noticed the return type is
> indented after template declaration. See below the indentation of return
> type _Function. The code formatting is enforced by clang-formatter (config
> at /contrib/clang-format)



No it isn't.

That file is for the compiler code, and is not used for libstdc++ code. I
don't think the tool supports the libstdc++ formatting style. Last I heard,
it has no way to do that indentation.


which does not indent the return type after template declaration. Is the
> inconsistency due to limitation of clang-format or a missing config option?
>
> template<typename _InputIterator, typename _Function>
>   _Function
>   for_each(_InputIterator __first, _InputIterator __last, _Function __f)
>   {
>     // concept requirements
>     __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
>     __glibcxx_requires_valid_range(__first, __last);
>     for (; __first != __last; ++__first)
>   __f(*__first);
>     return __f; // N.B. [alg.foreach] says std::move(f) but it's redundant.
>   }
>
> Tejasvi
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Code style enforcement
  2021-12-24 12:18 ` Jonathan Wakely
@ 2021-12-24 12:21   ` Jonathan Wakely
  2021-12-24 12:21   ` Jonathan Wakely
  1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2021-12-24 12:21 UTC (permalink / raw)
  To: Tejasvi Singh; +Cc: libstdc++

On Fri, 24 Dec 2021, 12:18 Jonathan Wakely, <jwakely.gcc@gmail.com> wrote:

>
>
> On Fri, 24 Dec 2021, 10:45 Tejasvi Singh via Libstdc++, <
> libstdc++@gcc.gnu.org> wrote:
>
>> Hi,
>>
>> While going through include/bits/stl-algo.h I noticed the return type is
>> indented after template declaration. See below the indentation of return
>> type _Function. The code formatting is enforced by clang-formatter (config
>> at /contrib/clang-format)
>
>
>
> No it isn't.
>
> That file is for the compiler code, and is not used for libstdc++ code. I
> don't think the tool supports the libstdc++ formatting style. Last I heard,
> it has no way to do that indentation.
>
>
> which does not indent the return type after template declaration. Is the
>> inconsistency due to limitation of clang-format or a missing config option?
>>
>> template<typename _InputIterator, typename _Function>
>>   _Function
>>   for_each(_InputIterator __first, _InputIterator __last, _Function __f)
>>   {
>>     // concept requirements
>>     __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
>>     __glibcxx_requires_valid_range(__first, __last);
>>     for (; __first != __last; ++__first)
>>   __f(*__first);
>>     return __f; // N.B. [alg.foreach] says std::move(f) but it's
>> redundant.
>>   }
>>
>> Tejasvi
>>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Code style enforcement
  2021-12-24 12:18 ` Jonathan Wakely
  2021-12-24 12:21   ` Jonathan Wakely
@ 2021-12-24 12:21   ` Jonathan Wakely
  1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2021-12-24 12:21 UTC (permalink / raw)
  To: Tejasvi Singh; +Cc: libstdc++

On Fri, 24 Dec 2021, 12:18 Jonathan Wakely, <jwakely.gcc@gmail.com> wrote:

>
>
> On Fri, 24 Dec 2021, 10:45 Tejasvi Singh via Libstdc++, <
> libstdc++@gcc.gnu.org> wrote:
>
>> Hi,
>>
>> While going through include/bits/stl-algo.h I noticed the return type is
>> indented after template declaration. See below the indentation of return
>> type _Function. The code formatting is enforced by clang-formatter (config
>> at /contrib/clang-format)
>
>
>
> No it isn't.
>
> That file is for the compiler code, and is not used for libstdc++ code. I
> don't think the tool supports the libstdc++ formatting style. Last I heard,
> it has no way to do that indentation.
>


I use https://github.com/mattkretz/vim-gnuindent to indent libstdc++ code.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-12-24 12:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-24 10:44 Code style enforcement Tejasvi Singh
2021-12-24 12:18 ` Jonathan Wakely
2021-12-24 12:21   ` Jonathan Wakely
2021-12-24 12:21   ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).