NVIDIA / NVIDIA/cccl

[FEA]: Consider making cuda::std::complex trivially default constructible

Open
#643 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.5k
Forks
486
Avg merge
2d 6h
Merged PRs (30d)
295

Description

### Is this a duplicate?

- [X] I confirmed there appear to be no [duplicate issues](https://github.com/NVIDIA/cccl/issues) for this request and that I agree to the [Code of Conduct](CODE_OF_CONDUCT.md)

### Area

libcu++

### Is your feature request related to a problem? Please describe.

As a CUDA C++ programmer, I'd like to use `cuda::std::complex` in performance sensitive code where default initialization can be problematic for both performance reasons and lead to [warning/errors when used in `__shared__` memory](https://github.com/NVIDIA/cccl/issues/993).

The standard specifies that the default constructor for `std::complex` is spelled:
```
constexpr complex(const T& re = T(), const T& im = T());
```
meaning the real and imaginary parts are value initialized by default.

### Describe the solution you'd like

We should consider either:

1. Deviate from the standard and make `cuda::std::complex` trivially default constructible
2. Introduce a `cuda::complex` extension type that is trivially default constructible

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.