[PATCH] D29930: Add `__reference_binds_to_temporary` trait for checking safe reference initialization.

Eric Fiselier via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 21 01:40:34 PST 2017


EricWF marked an inline comment as done.
EricWF added inline comments.


================
Comment at: test/SemaCXX/type-traits.cpp:2102-2116
+  using LRef = ConvertsToRef<int, int&>;
+  using RRef = ConvertsToRef<int, int&&>;
+  using CLRef = ConvertsToRef<int, const int&>;
+  using LongRef = ConvertsToRef<long, long&>;
+  { int arr[T((__is_constructible(int&, LRef)))]; }
+  { int arr[F((__reference_binds_to_temporary(int&, LRef)))]; }
+
----------------
rsmith wrote:
> Please also check things like:
> 
>   `__reference_binds_to_temporary(const int&, ConvertsToRef<long, long&>)`
> 
> (That is, a user-defined conversion to a reference type followed by converting and materializing a temporary.)
Isn't that exactly what the test on the specified line does? `LongRef` is  `ConvertsToRef<long, long&>`


https://reviews.llvm.org/D29930





More information about the cfe-commits mailing list