Skip to content

Remove deduction guides for alias templates to support C++20 - #15

Open
benvanwerkhoven wants to merge 1 commit into
mainfrom
fix-cxx20-alias-deduction-guides
Open

benvanwerkhoven wants to merge 1 commit into
mainfrom
fix-cxx20-alias-deduction-guides

Conversation

@benvanwerkhoven

Copy link
Copy Markdown
Contributor

The deduction guides for vec, vec_ptr, kscalar, kvec and kconstant were enabled only for __cpp_deduction_guides >= 201907L, i.e. C++20. Compilers reject guides that name an alias template, so kernel_float.h could not be included in C++20 builds. From C++20, the compiler derives deduction guides for alias templates from the class template's own guides, so these can be removed. Adds tests/deduction.cu with compile-time checks of class template argument deduction.

Perhaps the CI should also test with C++20.

The deduction guides for vec, vec_ptr, kscalar, kvec and kconstant were
enabled only for `__cpp_deduction_guides >= 201907L`, i.e. C++20. Compilers
reject guides that name an alias template, so kernel_float.h could not be
included in C++20 builds. From C++20, the compiler derives deduction guides
for alias templates from the class template's own guides, so these can be
removed. Adds tests/deduction.cu with compile-time checks of class template
argument deduction.
@stijnh

stijnh commented Sep 28, 2026

Copy link
Copy Markdown
Member

Thanks. Looks good to me!

The HIP test seem to be failing, I'l look into this:

 /home/runner/work/kernel_float/kernel_float/tests/deduction.cu:17:16: error: reference to __host__ function '<deduction guide for vector><int, float>' in __host__ __device__ function
   17 |     kf::vector v(1, 2.0f);
      |                ^
/home/runner/work/kernel_float/kernel_float/include/kernel_float/vector.h:382:1: note: '<deduction guide for vector><int, float>' declared here
  382 | vector(Args&&... args) -> vector<promote_t<Args...>, extent<sizeof...(Args)>>;

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants