What is the equivalent of placement new in Ada?

  ada, c++, memory-management

I’m trying to learn Ada by writing a set of procedures for managing a dynamic array but I have no idea how to go about it. In C++ I can easily put arbitrary objects in memory like so:

#include <new>
#include <iostream>

class object {
  private:
    int value;

  public:
    ~object() noexcept { std::cout << "<> "; }
    object(int value) noexcept : value(value) { std::cout << object::value << ' '; }
};

constexpr auto size = 16;

int main() {
    auto buffer = static_cast<object*>(::operator new(size * sizeof(object)));
    for (auto offset = 0; offset < size; offset++)
        new (buffer + offset) object(offset);
    for (auto offset = 0; offset < size; offset++)
        (buffer + offset)->~object();
    ::operator delete(buffer);
}

Is there an equivalent of this type of "allocate x * sizeof(y) and initialize x y-items" operation in Ada?

Source: Windows Questions C++

LEAVE A COMMENT