[cfe-dev] Two style questions
Cédric Venet
cedric.venet at student.ecp.fr
Sun Nov 11 06:49:21 PST 2007
> I'm not familiar with boost scoped_ptr, and won't have time to dig
> into it for a couple of days. Assuming it is simple and useful (i.e.
> it really does simplify the C++ code we end up writing and
> maintaining), I don't have a problem with adopting it.
Scoped_ptr must be the simplest smart pointer existing, but useful:
// scoped_ptr mimics a built-in pointer except that it guarantees deletion
// of the object pointed to, either on destruction of the scoped_ptr or via
// an explicit reset().
Basically:
Template< class T >
Class scoped_ptr {
T* ptr;
Public:
Explicit scoped_ptr(T* p=NULL):ptr(p) {}
~scoped_ptr() { delete ptr; }
// function get, op -> ,...
}
Attached the scoped_ptr extracted from boost (just modified the include
style from <> to ""), there is some accessory (but useful) features which
could be deleted as the complete_type delete checker.
> > In particular, I don't see why BuilderTy in ModuleBuilder.h is
> > declared as
> > an opaque type since it represente a CodeGenModule and could simply
> > use a
> > forward declared class no?
>
> You're right, this is a clear "bug", please send in a patch!
Attached: patch1.patch
Cédric
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch1.patch
Type: application/octet-stream
Size: 3540 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20071111/0dc40b83/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: scoped_ptr.patch
Type: application/octet-stream
Size: 23550 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20071111/0dc40b83/attachment-0001.obj>
More information about the cfe-dev
mailing list