<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 - After formatting done by the clang-format utility, the source code of the class ++ template class does not compile"
href="https://bugs.llvm.org/show_bug.cgi?id=42381">42381</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>After formatting done by the clang-format utility, the source code of the class ++ template class does not compile
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>6.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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>rumgot@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>// OS Ubuntu 18.04 x64
// Compiler g++ 7.4.0 (compilation runs in c++11 mode)
// Tested on standard styles that are part of the сlang-format utility (LLVM,
Google, Chromium, Mozilla, WebKit)
// There is code on C++
#include <iostream>
#include <set>
template <typename T>
class Point;
template <typename T>
std::ostream &operator<< (std::ostream &os, const Point<T> &point);
template <typename T>
bool operator< (const Point<T> &point, const Point<T> &otherPoint);
template <typename T>
class Point {
public:
Point() : x_(0), y_(0) {}
Point(const T &x, const T &y) : x_(x), y_(y) {}
bool isPointsInHorLine(const Point<T> &other) const {
return y_ == other.y_;
}
friend std::ostream &operator<< <>(std::ostream &os, const Point<T>
&point);
// Pay attention to this line (Before formatting utility сlang-format):
// friend bool operator< <>(const Point<T> &point, const Point<T>
&otherPoint);
// After formatting with the Klangformat utility, this line will be (as
such, the string is not compiled):
friend bool operator<<>(const Point<T> &point, const Point<T> &otherPoint);
private:
T x_;
T y_;
};
template <typename T>
std::ostream &operator<< (std::ostream &os, const Point<T> &point) {
os << "Point(" << point.x_ << ", " << point.y_ << ")";
return os;
}
template <typename T>
bool operator< (const Point<T> &point, const Point<T> &otherPoint) {
return point.isPointsInHorLine(otherPoint) ? point.x_ < otherPoint.x_
: point.y_ < otherPoint.y_;
}
int main(int argc, char *argv[]) {
Point<int> point(5, 5);
std::cout << point << std::endl;
return 0;
}</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>