Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
improved answer
Source Link
Simone
  • 11.8k
  • 1
  • 33
  • 45

I think the reason is the same for you can't overload language keyword.

In fact, you have to see them as language keyword and not template function, even if the look the same. OTOH, I couldn' imagine what kind of disasters one could do by changing the meaning of this particular C++ aspect.

EDIT
I was pretty sure that someone would have come up with the question: "then why you can overload new/delete?". I think that memory allocation/deallocation customization is something that you need in certain scenarios, and the benefits of allowing you to overload them outweighs the risks. I can't see any advantage in subverting the C++ type system, IOW I fail to think a scenario where it would be useful. Do you?

I think the reason is the same for you can't overload language keyword.

In fact, you have to see them as language keyword and not template function, even if the look the same. OTOH, I couldn' imagine what kind of disasters one could do by changing the meaning of this particular C++ aspect.

I think the reason is the same for you can't overload language keyword.

In fact, you have to see them as language keyword and not template function, even if the look the same. OTOH, I couldn' imagine what kind of disasters one could do by changing the meaning of this particular C++ aspect.

EDIT
I was pretty sure that someone would have come up with the question: "then why you can overload new/delete?". I think that memory allocation/deallocation customization is something that you need in certain scenarios, and the benefits of allowing you to overload them outweighs the risks. I can't see any advantage in subverting the C++ type system, IOW I fail to think a scenario where it would be useful. Do you?

Source Link
Simone
  • 11.8k
  • 1
  • 33
  • 45

I think the reason is the same for you can't overload language keyword.

In fact, you have to see them as language keyword and not template function, even if the look the same. OTOH, I couldn' imagine what kind of disasters one could do by changing the meaning of this particular C++ aspect.