On Sun, 11 Dec 2022 at 13:44, Gavin Ray wrote: > > Whoops, the last line should be pages_span(storage, ...)
That won't even compile, so there's your main difference. That seems even more off-topic on this list than "somebody told me gcc is broken, because of [unrelated code example with UB]". A creates 'pages' objects in the storage, B doesn't compile, but even if it did, it's just saying "look at this storage as though it contained this many objects of type 'pages'" which doesn't create any objects, and would be a lie. > > On Sun, Dec 11, 2022 at 8:38 AM Gavin Ray <ray.gavi...@gmail.com> wrote: >> >> @Richard >> >> That's some intense code, I appreciate the code-samples and explanation, >> thank you =) >> >> @Jonathan >> >> Maybe there was some misunderstanding? >> I didn't make the connection either but I also don't know that much about C++ >> >> It seems like that expression is valid then? Good to know =) >> >> As a random aside if I may -- what is the difference between placement-new >> of pointers in >> std::byte storage, and making a std::span over the storage area? >> >> std::byte storage[PAGE_SIZE * NUM_PAGES]; >> >> // A) >> page* pages = new (storage) page[NUM_PAGES]; >> // B) >> std::span<page, NUM_PAGES> pages_span(pages, NUM_PAGES);