<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - [feature request] requires clause in class templates (Concepts TS)"
href="https://bugs.llvm.org/show_bug.cgi?id=32165">32165</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[feature request] requires clause in class templates (Concepts TS)
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Formatter
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>gonzalobg88@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>The following code:
template <class T, class U, class... Rest>
requires CommonReference<T, U>()
struct common_reference<T, U, Rest...>
: common_reference<common_reference_t<T, U>, Rest...> {};
is reformatted to
template <class T, class U, class... Rest>
requires CommonReference<T, U>() struct common_reference<T, U, Rest...>
: common_reference<common_reference_t<T, U>, Rest...> {};
because clang-format does not understand the requires keyword in class
templates.
It should either be formatted to
// A: requires clause in its own line:
template <class T, class U, class... Rest>
requires CommonReference<T, U>()
struct common_reference<T, U, Rest...>
: common_reference<common_reference_t<T, U>, Rest...> {};
// B: small require clause in line with template arguments
template <class T, class U, class... Rest> requires CommonReference<T, U>()
struct common_reference<T, U, Rest...>
: common_reference<common_reference_t<T, U>, Rest...> {};
Also, long requires clauses are not handled properly
template <class T, class U, class... Rest>
requires CommonReference<T, U>() &&
CommonReference<T, U>() &&
CommonReference<T, U>()
struct common_reference<T, U, Rest...>
: common_reference<common_reference_t<T, U>, Rest...> {};
is reformatted to:
template <class T, class U, class... Rest>
requires CommonReference<T, U>() && CommonReference<T, U>() &&
CommonReference<T, U>() struct common_reference<T, U, Rest...>
: common_reference<common_reference_t<T, U>, Rest...> {};
Following customization parameters _might_ make sense, but I haven't given this
much thought:
- indentation of the require clause with respect to the template
arguments/struct (e.g. 1 space, 4 spaces...). Maybe we could reuse
ContinuationIndentWidth/AccessModifierOffset for this, but I'd rather have it
as a standalone option.
- AllowShortRequireClausesOnASingleLine: whether short requires clauses should
be wrapped into the same line as the template arguments
And well probably stuff like BreakBeforeBinaryOperators should work here
properly.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>