Is std :: complex stored in rotation?

That is, on disk, if I have an array std::complex, is it stored, RIRIRIRIor RRRRIIIIor something else?

My real question is: if I have a structure that I defined that contains two numbers, can I re-interpret to pass an array of my structure in order to use the functions that the array would expect std::complex?

What about memcpy? If both of my structures are floats, should this be normal if they are kept the same?

+3
source share
4 answers

The C ++ class is slightly larger than structwith some decorations. Thus, the members defined in the class are ordered sequentially in memory, adjacent to each element of this type. In other words, the array std::complexwhere each element contains RIwill be saved RIRIRIRI.

You may succeed with reinterpret_cast, but you will be dependent on the implementation std::complexif you do this - and it will probably be just fine.

+2
source

The std :: complex array, defined as follows:

std :: complex array [COUNT];

... RIRIRIRI , [i] , [array], * ( + i). RRRRIIII, .

, IS RRRRIIII: StructuredBuffer Direct3D 11+. API, RIRIRIRI GPU, RRRRIIII, GPU, .

+2

, .

:

ofstream file("somefile.txt");

file << complex_var.real() << "\t" << complex_var.imag() << "\n";

file << complex_var << "\n";

( ) '(realpart, imaginarypart) `. , , , , (, , ) , .

+1

, . , . .

, , ( ). std::complex .

+1

Source: https://habr.com/ru/post/1531142/


All Articles