Functions
gmemory.h File Reference
#include "gdef.h"
#include <memory>

Go to the source code of this file.

Functions

template<typename T >
void operator<<= (std::auto_ptr< T > &ap, T *p)
 A portable fix for the problem of resetting an auto_ptr<>. More...
 
template<typename T >
void operator<<= (std::auto_ptr< T > &ap, int)
 A version for null-pointer constants. More...
 

Function Documentation

template<typename T >
void operator<<= ( std::auto_ptr< T > &  ap,
T *  p 
)

A portable fix for the problem of resetting an auto_ptr<>.

Some compilers do not have a reset() method, and some have non-const assignment operators.

Usage:

1 {
2  std::auto_ptr<Foo> ptr ;
3  for( int i = 0 ; i < 10 ; i++ )
4  {
5  ptr <<= new Foo ;
6  if( ptr->fn() )
7  eatFoo( ptr->release() ) ;
8  }
9 }

Definition at line 46 of file gmemory.h.

template<typename T >
void operator<<= ( std::auto_ptr< T > &  ap,
int   
)

A version for null-pointer constants.

Definition at line 56 of file gmemory.h.