[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: First draft of Memory Hunting HOWTO
From:       Lubos Lunak <l.lunak () sh ! cvut ! cz>
Date:       1999-04-06 21:34:09
[Download RAW message or body]

On Út, 06 dub 1999, Stephan Kulow wrote :
>Lubos Lunak wrote:
>> 

<snip>
>> #include <stdio.h>
>> #include <memory>
>> 
>> int main()
>>     {
>>     auto_ptr< char > ptr( new char[10] );
>>     char* p = ptr.get();
>>     //char* p = new char[10];
>>     p[0] = 'A';
>>     printf("%c\n", p[0]);
>>     }
>> ( ... damn, no auto_ptr<T>::operator[]()  ? :(   )
>Sorry, the example is wrong. auto_ptr is for pointers,
>not for char arrays, since they require another delete
>operator.

The example perhaps doesn't look nice( I miss some overloaded operators in
auto_ptr<> ), but I'm quite sure that the it's correct. Char arrays behave
_almost_ the same way as char pointers. Why two delete operators ?

>
>You would have to use array<char>

There's no array<> in my STL headers. Maybe vector<> ? But that wouldn't work.
>
>> 
>> However, I'm not sure whether auto_ptr<T> is widely available, as it's quite
>> a new thing( ... maybe Kauto_ptr<T> ? :)  ).
>> 
>It's a simple class and part of STL and KDE requires STL anyway.

Great. Does that mean I can use auto_ptr<>'s , static_cast<>'s, etc. without
configure test and lot of #ifdef's ?

>
>Greetings, Stephan

 Lubos Lunak
 l.lunak@email.cz

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic