C ++ pointer overlay 0x

I'm thinking (as an idea) about unrelated pointer smoothing in C ++ 0x. I was thinking about whether it can be implemented in the same way as const correctness, i.e. Forced to be executed by the compiler. What would be the requirements for such a substance? Since this is a more thought-provoking experiment, I enjoy looking at solutions that destroy legacy code or redefine half of the language and such things.

What I really would not want to do is, say, restrictfrom C99, where the programmer just promises. This must be respected.

I thought that unique_ptr is not part of the library, but part of the language. Thus, the compiler can perform special optimizations on it and write its own unique pointer classes, if necessary.

+3
source share
1 answer

The C ++ Standard Library (including std::unique_ptr) is part of the language.

In addition, relevant programs are not allowed to add declarations and definitions to the namespace std.

After viewing the instance, the std::unique_ptr<T>compiler knows everything about the behavior of this instance - it is this behavior that was implemented as part of the language implementation, the compiler itself is part, and the compiler is free to perform “special optimizations” based on the guarantees of the C ++ standard.

-, , GCC C99 - inline insn - , GCC , .

+1

Source: https://habr.com/ru/post/1782998/


All Articles