C++17 introduced the new attribute [[nodiscard]]
in p0189r1. When a function is decorated with this attribute, the return type must not be discarded. If it is discarded, a warning is emitted.
Example:
[[nodiscard]] void* allocateMemory();
void doWork() {
allocateMemory(); // Warning is emitted, because the value is not stored in a variable and thus is discarded
}
This seems to be a good addition for any function that returns anything that later must be freed/destroyed/deleted/... again. However, the standard did not change the definition of the global new operator to make use of this new annotation. Is there any good reason for this?