DGtal 2.1.0
Loading...
Searching...
No Matches
DummyTbl Struct Reference

Public Types

typedef int Element
 

Public Member Functions

 ~DummyTbl ()
 
 DummyTbl (int i, int val)
 
 DummyTbl (const DummyTbl &a)
 
 DummyTbl (DummyTbl &&a) noexcept
 
int value () const
 
void setValue (int v) const
 

Static Public Member Functions

static void reset ()
 

Data Fields

Elementdata
 
int size
 
int allocated
 

Static Public Attributes

static int nbCreated = 0
 
static int nbDeleted = 0
 
static int nbMoved = 0
 

Private Member Functions

 DummyTbl ()
 
DummyTbloperator= (const DummyTbl &a)
 

Detailed Description

Definition at line 156 of file testClone2.cpp.

Member Typedef Documentation

◆ Element

typedef int DummyTbl::Element

Definition at line 159 of file testClone2.cpp.

Constructor & Destructor Documentation

◆ DummyTbl() [1/4]

DummyTbl::DummyTbl ( )
private

◆ ~DummyTbl()

DummyTbl::~DummyTbl ( )
inline

Definition at line 163 of file testClone2.cpp.

164 {
165 std::cout << " ~DummyTbl() this=" << this << " data=" << data << std::endl;
166 if ( data != 0 ) {
167 std::cout << " - freed =" << allocated << std::endl;
168 delete[] data;
169 }
170 else
171 std::cout << " - nothing to do (already moved)" << std::endl;
172 ++nbDeleted;
173 }
static int nbDeleted
Element * data

References allocated, data, and nbDeleted.

◆ DummyTbl() [2/4]

DummyTbl::DummyTbl ( int  i,
int  val 
)
inline

Definition at line 174 of file testClone2.cpp.

175 : size( 0 ), allocated( i )
176 {
177 std::cout << " DummyTbl( " << i << " ) this=" << this << std::endl;
178 data = new Element[ allocated ];
179 data[ size++ ] = val;
180 std::cout << " - allocated=" << allocated << std::endl;
181 std::cout << " - copied =" << size << std::endl;
182 ++nbCreated;
183 }
static int nbCreated

References allocated, data, nbCreated, and size.

◆ DummyTbl() [3/4]

DummyTbl::DummyTbl ( const DummyTbl a)
inline

Definition at line 184 of file testClone2.cpp.

184 : size( a.size ), allocated( a.allocated )
185 {
186 std::cout << " DummyTbl( const DummyTbl & a ) this=" << this << " a=" << &a << std::endl;
187 data = new Element[ allocated ];
188 for ( int i = 0; i < size; ++i ) data[ i ] = a.data[ i ];
189 std::cout << " - allocated=" << allocated << std::endl;
190 std::cout << " - copied =" << size << std::endl;
191 ++nbCreated;
192 }

References allocated, data, nbCreated, and size.

◆ DummyTbl() [4/4]

DummyTbl::DummyTbl ( DummyTbl &&  a)
inlinenoexcept

Definition at line 194 of file testClone2.cpp.

195 : size( std::move( a.size ) ), allocated( std::move( a.allocated ) )
196 {
197 data = a.data; a.data = 0;
198 std::cout << " DummyTbl( DummyTbl && a ) this=" << this << " a=" << &a << std::endl;
199 std::cout << " - check data: a=" << allocated << " s=" << size << std::endl;
200 ++nbCreated;
201 ++nbMoved;
202 }
static int nbMoved

References allocated, data, nbCreated, nbMoved, and size.

Member Function Documentation

◆ operator=()

DummyTbl & DummyTbl::operator= ( const DummyTbl a)
inlineprivate

Definition at line 208 of file testClone2.cpp.

209 {
210 data = a.data;
211 std::cout << " DummyTbl::operator=( const DummyTbl & a ) " << std::endl;
212 return *this;
213 }

References data.

◆ reset()

static void DummyTbl::reset ( )
inlinestatic

Definition at line 215 of file testClone2.cpp.

215 {
216 nbCreated = 0;
217 nbDeleted = 0;
218 }

References nbCreated, and nbDeleted.

Referenced by testAliasCases(), testCloneCases(), and testConstAliasCases().

◆ setValue()

void DummyTbl::setValue ( int  v) const
inline

Definition at line 205 of file testClone2.cpp.

205{ data[ 0 ] = v; }

References data.

Referenced by CloneToCowMember::setValue(), and CloneToPtrMember::setValue().

◆ value()

Field Documentation

◆ allocated

int DummyTbl::allocated

Definition at line 222 of file testClone2.cpp.

Referenced by DummyTbl(), DummyTbl(), DummyTbl(), and ~DummyTbl().

◆ data

Element* DummyTbl::data

Definition at line 220 of file testClone2.cpp.

Referenced by DummyTbl(), DummyTbl(), DummyTbl(), operator=(), setValue(), value(), and ~DummyTbl().

◆ nbCreated

int DummyTbl::nbCreated = 0
static

◆ nbDeleted

int DummyTbl::nbDeleted = 0
static

Definition at line 225 of file testClone2.cpp.

Referenced by reset(), testAliasCases(), testCloneCases(), testConstAliasCases(), and ~DummyTbl().

◆ nbMoved

int DummyTbl::nbMoved = 0
static

Definition at line 226 of file testClone2.cpp.

Referenced by DummyTbl(), and testCloneCases().

◆ size

int DummyTbl::size

Definition at line 221 of file testClone2.cpp.

Referenced by DummyTbl(), DummyTbl(), and DummyTbl().


The documentation for this struct was generated from the following file: