It's been proposed already. One of the issues with the proposal that jumps out to me is that it wants memory allocation to be not allowed in a pure function. Which is both fair & not. That means no collections, more or less, as you can't allocate the return value.
But if you allow memory allocations, then you go down the rabbit hole of well whose memory allocations are allowed? Only `new`? What about `malloc`? Or a custom allocator? If custom allocators are allowed, do they need a `mutable` keyword equivalent but for pure functions, where it's internally not-pure but is allowed to be used from a pure function?
But it looks like there was no follow-up proposal. `constexpr` isn't too far off from a [[pure]] specifier, though.
It's been proposed already. One of the issues with the proposal that jumps out to me is that it wants memory allocation to be not allowed in a pure function. Which is both fair & not. That means no collections, more or less, as you can't allocate the return value.
But if you allow memory allocations, then you go down the rabbit hole of well whose memory allocations are allowed? Only `new`? What about `malloc`? Or a custom allocator? If custom allocators are allowed, do they need a `mutable` keyword equivalent but for pure functions, where it's internally not-pure but is allowed to be used from a pure function?
But it looks like there was no follow-up proposal. `constexpr` isn't too far off from a [[pure]] specifier, though.