inline-namespaces

Wherefore inline unnamed namespaces?

强颜欢笑 提交于 2019-12-04 16:41:44
问题 A quick one for the gurus: C++11 allows unnamed namespaces to be declared inline . This seems redundant to me; things declared in an unnamed namespace are already used as if they were declared in the enclosing namespace. So my question is this: what does it mean to say inline namespace /*anonymous*/ { // stuff } and how is it different from the traditional namespace /*anonymous*/ { // stuff } that we know and love from C++98? Can anyone give an example of different behaviour when inline is

Wherefore inline unnamed namespaces?

痴心易碎 提交于 2019-12-03 09:53:12
A quick one for the gurus: C++11 allows unnamed namespaces to be declared inline . This seems redundant to me; things declared in an unnamed namespace are already used as if they were declared in the enclosing namespace. So my question is this: what does it mean to say inline namespace /*anonymous*/ { // stuff } and how is it different from the traditional namespace /*anonymous*/ { // stuff } that we know and love from C++98? Can anyone give an example of different behaviour when inline is used? EDIT: Just to clarify, since this question has been marked as a duplicate: I'm not asking about

What are inline namespaces for?

六眼飞鱼酱① 提交于 2019-11-26 01:55:39
问题 C++11 allows inline namespace s, all members of which are also automatically in the enclosing namespace . I cannot think of any useful application of this -- can somebody please give a brief, succinct example of a situation where an inline namespace is needed and where it is the most idiomatic solution? (Also, it is not clear to me what happens when a namespace is declared inline in one but not all declarations, which may live in different files. Isn\'t this begging for trouble?) 回答1: Inline