================
@@ -287,6 +287,46 @@ Example Usage
       basePtr->virtualFunction(); // Allowed since obj is constructed in 
device code
    }
 
+C++17 Class Template Argument Deduction (CTAD) Support
+======================================================
+
+Clang supports C++17 Class Template Argument Deduction (CTAD) in both host and 
device code for HIP.
+This allows you to omit template arguments when creating class template 
instances, letting the compiler
+deduce them from constructor arguments.
+
+.. code-block:: c++
+
+   #include <tuple>
+
+   __host__ __device__ void func() {
+     std::tuple<int, int> t = std::tuple(1, 1);
+   }
+
+In the above example, ``std::tuple(1, 1)`` automatically deduces the type to 
be ``std::tuple<int, int>``.
+
+Deduction Guides
+----------------
+
+User-defined deduction guides are also supported. Since deduction guides are 
not executable code and only
+participate in type deduction, they are treated as ``__host__ __device__`` by 
the compiler, regardless of
+explicit target attributes. This ensures they are available for deduction in 
both host and device contexts.
----------------
Artem-B wrote:

I'm not convinced that ignoring target attribute is the best approach here.

Perhaps we should require deduction guides to always be host/device, either 
explicitly or implicitly.




https://github.com/llvm/llvm-project/pull/168711
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to