auto_ptr and msvc 6.0 
Author Message
 auto_ptr and msvc 6.0

Is MS's (or whoever did their stl stuff) implementation of auto_ptr any
good?

How, if possible, can it be broken?

thanx...



Sat, 04 Oct 2003 20:48:08 GMT  
 auto_ptr and msvc 6.0

Quote:
> Is MS's (or whoever did their stl stuff) implementation of auto_ptr any
> good?

It works - what's your criteria for it being "good"?.

Quote:
> How, if possible, can it be broken?

By using it in an STL collection - the compiler should catch this error, but
doesn't.

NeilB



Sat, 04 Oct 2003 22:54:29 GMT  
 auto_ptr and msvc 6.0

Quote:



> > Is MS's (or whoever did their stl stuff) implementation of auto_ptr any
> > good?

> It works - what's your criteria for it being "good"?.

> > How, if possible, can it be broken?

> By using it in an STL collection - the compiler should catch this error, but
> doesn't.

Where "should" means ", although not required to, would be more helpful
if it did". <g>

--
Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)



Sun, 05 Oct 2003 01:01:37 GMT  
 auto_ptr and msvc 6.0


Quote:


> > Is MS's (or whoever did their stl stuff) implementation of auto_ptr any
> > good?

> It works - what's your criteria for it being "good"?.

> > How, if possible, can it be broken?

> By using it in an STL collection - the compiler should catch this error,
but
> doesn't.

should i use auto_ptr in stl collections at all, if my collection keeps
smart pointers?

--
mr.black's here...



Sun, 05 Oct 2003 02:11:05 GMT  
 auto_ptr and msvc 6.0

Quote:
> > > Is MS's (or whoever did their stl stuff) implementation of auto_ptr
any
> > > good?

> > It works - what's your criteria for it being "good"?.

> > > How, if possible, can it be broken?

> > By using it in an STL collection - the compiler should catch this error,
but
> > doesn't.

> Where "should" means ", although not required to, would be more helpful
> if it did". <g>

this auto_ptr is driving me crazy :)

i can use them in a such way:

auto_ptr<A> a(new A(0));
...
...a.get();

but can i use them like this?:

auto_ptr<A> a;
A aa(0);
a = aa;
...
...a.get();

in other words, can i wrap present object into auto_ptr?

the problem is: i need a function, that creates new object, puts it into
collection and returns it.

--
mr.black's here...



Sun, 05 Oct 2003 02:06:00 GMT  
 auto_ptr and msvc 6.0

Quote:

> auto_ptr<A> a;
> A aa(0);
> a = aa;
> ...
> ...a.get();

> in other words, can i wrap present object into auto_ptr?

No. auto_ptr's primary purpose is to insure destruction of a heap object
when the auto_ptr goes out of scope. Auto objects already insure
dstruction when they go out of scope.

--
Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)



Sun, 05 Oct 2003 02:23:30 GMT  
 auto_ptr and msvc 6.0

Quote:
> > > > Is MS's (or whoever did their stl stuff) implementation of auto_ptr
> any
> > > > good?

> > > It works - what's your criteria for it being "good"?.

> > > > How, if possible, can it be broken?

> > > By using it in an STL collection - the compiler should catch this
error,
> but
> > > doesn't.

> > Where "should" means ", although not required to, would be more helpful
> > if it did". <g>

> this auto_ptr is driving me crazy :)

> i can use them in a such way:

> auto_ptr<A> a(new A(0));
> ...
> ...a.get();

> but can i use them like this?:

> auto_ptr<A> a;
> A aa(0);
> a = aa;
> ...
> ...a.get();

> in other words, can i wrap present object into auto_ptr?

No of course you can't. auto_ptrs are used for managing dynamically
allocated objects. Stack based objects (like aa above) manage themselves.
This is very, very basic C++ - if you don't understand it, you need a better
text book.

Quote:
> the problem is: i need a function, that creates new object, puts it into
> collection and returns it.

You almost certainly need to create the objects dynamically. Either use an
collection of ordinary pointers and manage the object lifetimes yourself, or
use a collection of reference-counted pointers, sucha as can be found at
www.boost.org and have them manage the lifetimes for you.

NeilB



Sun, 05 Oct 2003 01:54:18 GMT  
 auto_ptr and msvc 6.0


Quote:





> > > Is MS's (or whoever did their stl stuff) implementation of auto_ptr
any
> > > good?

> > It works - what's your criteria for it being "good"?.

> > > How, if possible, can it be broken?

> > By using it in an STL collection - the compiler should catch this error,
> but
> > doesn't.

> should i use auto_ptr in stl collections at all

Never. auto_ptr's are incompatible with the STL collections as they do not
have the right copy constructor semantics. So don't do it!!!

, if my collection keeps

Quote:
> smart pointers?

If your collection keeps smart pointers you have to roll your own smart
pointer or investigate those at www.boost.org

Stephen Howe



Wed, 08 Oct 2003 20:27:57 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Using MSVC 5.0 and MSVC 6.0 On One Machine

2. Can I mix MSVC 4.0 and MSVC 6.0?

3. bug: VS7.0 (6.0) C++ std::auto_ptr conflict with std::vector

4. auto_ptr template in Visual C++ 6.0 SP5

5. auto_ptr with VC 6.0

6. MSVC 6.0 rpcasync.h generates warning

7. Crashing OCX on computers with no MSVC 6.0

8. msvc 6.0, Access 2000

9. Error in MSVC 6.0 headers...

10. XP and MSVC ++ 6.0 Crash

11. new to msvc++ 6.0

12. Comiling large HELP files using MSVC 6.0

 

 
Powered by phpBB® Forum Software