Topic: auto_ptr with array..
Author: Valentin Bonnard <Bonnard.V@wanadoo.fr>
Date: 1999/05/10 Raw View
Michele Paoli wrote:
> I'm looking for a nice solution to use auto_ptr with array.
There isn't.
> In the follow code:
> { // Use of array.
> char *myArray1 = new char[myLenArray1];
> char *myArray2 = new char[myLenArray2];
> ....
> delete [] myArray1;
> delete [] myArray2;
> }
> to use auto_ptr, what do I have to do?
You don't. You use vector:
vector<char> myArray1 (myLenArray1);
--
Valentin Bonnard
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Joerg Schaible" <Joerg.Schaible.A@T.gft.de>
Date: 1999/05/11 Raw View
You may have a look at www.boost.com
Greetings, J rg
--
BTW: It is normally better to answer to the group! For direct mail reply
exchange the ".A@T." by "@"
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: zeisel@lnzx16.vai.co.at (Zeisel Helmut)
Date: 1999/05/11 Raw View
In article <37370472.FBCC2DEA@ibm.net>, Biju Thomas <b_thomas@ibm.net> writes:
>Michele Paoli wrote:
>>
>> I'm looking for a nice solution to use auto_ptr with array.
>>
>
>There is no standard auto_ptr that can be used with an array. You have
>to create your own, which will call the 'delete[]' operator in its
>destructor.
>
The nicest solution were when auto_ptr had a second template parameter,
say
auto_ptr<T, Deleter=DefaultDeleter<T> >
with an obvious implementation.
Then you could easily implement
auto_ptr<char, ArrayDeleter<char> >,
or auto_ptr<char, CDeleter > (for a C function returning a pointer),
or auto_ptr<char, SomeSpecialLibraryDeleter<char> >,
or whatever you need.
This would work fine without breaking
any existing code; it is, however, not part of the standard.
Helmut
--
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Michele Paoli <zizzi@cribecu.sns.it>
Date: 1999/05/10 Raw View
Hi all,
I'm looking for a nice solution to use auto_ptr with array.
In the follow code:
{ // Use of array.
char *myArray1 = new char[myLenArray1];
char *myArray2 = new char[myLenArray2];
....
delete [] myArray1;
delete [] myArray2;
}
to use auto_ptr, what do I have to do?
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: sbnaran@localhost.localdomain (Siemel Naran)
Date: 1999/05/10 Raw View
On 10 May 99 12:05:54 GMT, Michele Paoli <zizzi@cribecu.sns.it> wrote:
>I'm looking for a nice solution to use auto_ptr with array.
Use vector<>, valarray<>, or something along those lines.
--
----------------------------------
Siemel B. Naran (sbnaran@uiuc.edu)
----------------------------------
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Biju Thomas <b_thomas@ibm.net>
Date: 1999/05/10 Raw View
Michele Paoli wrote:
>
> I'm looking for a nice solution to use auto_ptr with array.
>
There is no standard auto_ptr that can be used with an array. You have
to create your own, which will call the 'delete[]' operator in its
destructor.
--
Biju Thomas
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]