[llvm-bugs] [Bug 32165] New: [feature request] requires clause in class templates (Concepts TS)
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Mar 7 02:48:37 PST 2017
https://bugs.llvm.org/show_bug.cgi?id=32165
Bug ID: 32165
Summary: [feature request] requires clause in class templates
(Concepts TS)
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Formatter
Assignee: unassignedclangbugs at nondot.org
Reporter: gonzalobg88 at gmail.com
CC: djasper at google.com, klimek at google.com,
llvm-bugs at lists.llvm.org
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170307/bc955f41/attachment.html>
More information about the llvm-bugs
mailing list