C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Providing information about data structures to the compiler

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Fri, 10 Jan 2025 23:42:26 +0000
On Fri, Jan 10, 2025 at 3:16 PM Ehsan Amiri wrote:
>
> It may make sense to have a mechanism to provide such
> information to the compiler (for example, a class implements
> a vector-like data structure. Certain functions of the class will
> add/remove elements or reallocate memory, etc.).


I'm pretty clueless about this stuff . . . but are you saying we'd
write a class something like as follows?

template<typename T>
class MyVector [[classtype=container]] {
public:
    void emplace_back(T const &) [[container_add, might_realloc]]
    {
        . . .
    }
};

Received on 2025-01-10 23:42:28