Why does everybody use unanchored namespace declarations (i.e. std:: not ::std::)?

前端 未结 8 1843
悲&欢浪女
悲&欢浪女 2020-11-30 03:01

It seems to me that using unanchored namespaces is just asking for trouble later when someone puts in a new namespace that happens to have the same name as a root level name

8条回答
  •  庸人自扰
    2020-11-30 03:50

    So, why do people always say std:: instead of ::std::

    Probably because they never really had problems with ambiguity because of it.

    Along the same lines: I never had to include "earth" in my address, and I'm not going to.

    You have to draw the line somewhere, and this it is a reasonable assumption that others won't make their own std namespaces, or at least that a library that does won't be very popular. :)

提交回复
热议问题