Constructor

We can construct a Buffer object like this:

auto float_array = Buffer({0.0f, 0.5f, 1.0f, 1.5f}); 

The actual object will then look like this in computer memory:

The copy-constructor, copy-assignment, and destructor are invoked in the following cases:

auto func() { 
  // Construct 
  auto b0 = Buffer({0.0f, 0.5f, 1.0f, 1.5f});   // 1. Copy-construct 
  auto b1 = b0;   // 2. Copy-assignment as b0 is already initialized 
  b0 = b1;   // 3. When the function exits, the destructors are automatically invoked 
} 

Get C++ High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.