felipeprov / include-what-you-use

Automatically exported from code.google.com/p/include-what-you-use
Other
0 stars 0 forks source link

Why does "WhyIWYUIsDifficult" use scoped_ptr for its example where a forward-declaration is sufficient? #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
That description uses scoped_ptr and the instantiation of its con- and 
destructor to demonstrate that a forward declaration of "T" is sufficient for 
scoped_ptr<T> to work. 

But according to boost docs, T shall be a complete type when scoped_ptr<T> is 
implicitly instantiated.

Original issue reported on code.google.com by schaub.j...@googlemail.com on 5 Feb 2011 at 3:20

GoogleCodeExporter commented 9 years ago
I was wondering if someone would pick up on this!  You're right that 
scoped_ptr<T> does need the full type of T in some situations (I think it's 
only when the destructor is called).  So scoped_ptr<T> can forward-declare T 
only in some situations, like when it's a member variable of a class whose 
destructor is in a different file.

I'm happy to use another example if it's as well-known as scoped_ptr.  Any 
ideas?

Original comment by csilv...@gmail.com on 7 Feb 2011 at 6:35

GoogleCodeExporter commented 9 years ago
I don't know how detailed I wanted to get, so I ended up just changing the wiki 
to say "forward-declaring scoped_ptr<> is often sufficient."  I'll declare this 
enough. :-)

Original comment by csilv...@gmail.com on 25 Oct 2011 at 12:06