I just corrected a subtle bug--at least, I think it's a bug--in the
use of smart pointers in gel/vtol. I wanted to write to this list to
discuss my fix, and to help avoid similar issues in the future.
The simple rule is, I think, always use "xxx_sptr const&" and never
The problem as far as I see it is using a xxx_sptr class as a function
void f( xxx_sptr );
When you try to instantiate f(), the GCC compilers and VC7 seem to
instantiate xxx_sptr [*1]. Now, xxx_sptr is typically a typedef to an
_incomplete type_, so the instantiation fails.
class xxx; // forward declaration, therefore incomplete
typedef vbl_smart_ptr<xxx> xxx_sptr; // xxx_sptr is incomplete
The solution is to use a const reference instead:
void f( xxx_sptr const& );
Now, the instantation of f doesn't require xxx_sptr to be complete.
The way to treat this is to consider "xxx_sptr.h" as forward declaring
the smart pointer type. If you want the full type, such as when you
have a smart pointer member variable, you need to include "xxx.h".
I am not sure if my conclusions are correct. I welcome alternate
[*1] I don't know if this behaviour is mandated by the standard. I
think it is.