c++ - Name lookup: downsides to using unqualified class name inside a class definition / omitting template parameters? -


in recent discussion, matter came whether or not should qualify current class' name in class definition, , use explicitly specialized templates when referring current template itself. sum up:

namespace foo {     struct foo {         dosomething(foo::foo& other); // arguably         dosomething(foo& other);      // arguably bad     }; }  template<typename t> struct bar {     dosomething(bar<t>& other); // arguably     dosomething(bar& other);    // arguably bad }; 

problem is, no 1 claims hard facts, merely "the name lookup go wrong" versus "meh, never had problem".

in order settle this: are 2 conventions strictly equivalent or can "bad" 1 introduce ambiguities in name lookup? references current standard nice.

of course, argument of legibility should not taken account, i'm asking how standard-conforming compiler behave in corner cases. however, known implementation bugs welcome.

https://ideone.com/f48mji

namespace foo {   namespace foo {     typedef int foo;   }   struct foo {     int m_foo;     foo( foo::foo const& o_foo ):m_foo(o_foo.m_foo) {}   }; }  int main() {   ::foo::foo foo_(::foo::foo::foo{}); } 

in conclusion, foo.


Comments

Popular posts from this blog

javascript - JS causing window size to be bigger than necessary - Dropdown bug -

How to mention the localhost in android -

php - Calling a template part from a post -