What is the intention of ODR?

后端 未结 4 702
囚心锁ツ
囚心锁ツ 2021-01-06 16:11

I do understand what ODR says, but I don\'t understand what it tries to achieve.

I see two consequences of violating it - user will get syntax error, which is totall

4条回答
  •  独厮守ぢ
    2021-01-06 16:29

    To put it simply, the One Definition Rules guarantees:

    1. That entities that should be defined only once in the program are defined exactly once.

    2. That entities that can be defined in multiple Translation Units (classes, inline functions, template functions) have equivalent definitions that result in equivalent compiled code. The equivalence has to be perfect to be able to use any one definition at run time: the many definitions are indistinguishable.

提交回复
热议问题