Perhaps we need bit_cast or other conversions for arrays and templated containers. Either as noop or as actual conversion.

 

ranges? adapter classes? Do we have enough facilities?
 

-----Ursprüngliche Nachricht-----
Von: Paul Caprioli <paul@hpkfft.com>
Gesendet: Mo 25.08.2025 22:03
Betreff: RE: [std-proposals] TBAA and extended floating-point types
An: std-proposals@lists.isocpp.org;
CC: Sebastian Wittmeier <wittmeier@projectalpha.org>;
> What about bitcast instead?

I'm thinking about the following, and don't see how bitcast is useful:

 void daxpy(std::size_t n, const std::float64_t alpha, const std::float64_t* x,
            std::float64_t* y) {
     for (std::size_t i = 0; i < n; ++i) y[i] += alpha * x[i];
 }

 int main() {
     std::size_t n = 40;
     double alpha = 2.0;
     std::vector<double> x(n, 1.0);
     std::vector<double> y(n, 3.0);

     daxpy(n, alpha, x.data(), y.data());

     std::cout << y[17] << '\n';  // UB
 }