rjmccall added inline comments.

================
Comment at: clang/include/clang/Basic/PartialDiagnostic.h:66
+    return *this;
+  }
+
----------------
yaxunl wrote:
> rjmccall wrote:
> > Why are these template operators necessary?  The LHS of the `<<` should 
> > convert to a base reference type just fine.
> There are lots of usage patterns expecting the derived class after streaming, 
> e.g.
> 
> ```
> void foo(PartialDiagnostic& PD);
> foo(PD << X << Y);
> ```
I see.  You could also just do this in the base operators by just making them 
templates, e.g.

```
template <class Diagnostic>
std::enable_if_t<std::is_base_of_v<StreamingDiagnostic, Diagnostic>, const 
Diagnostic &>
operator<<(const Diagnostic &D, ...) {
}
```

That way you'd never have these forwarding problems — but it would be more 
boilerplate for each operator, so maybe it's a wash.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84362/new/

https://reviews.llvm.org/D84362

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to