Is it a bug???????????????/
- by Knowing me knowing you
I'm using VS2010 Ultimate.
Having code:
//file IntSet.h
#include "stdafx.h"
#pragma once
/*Class representing set of integers*/
template<class T>
class IntSet
{
private:
T** myData_;
std::size_t mySize_;
std::size_t myIndex_;
public:
#pragma region ctor/dtor
explicit IntSet();
virtual ~IntSet();
#pragma endregion
#pragma region publicInterface
IntSet makeUnion(const IntSet&)const;
IntSet makeIntersection(const IntSet&)const;
IntSet makeSymmetricDifference(const IntSet&)const;
void insert(const T&);
#pragma endregion
};
//file IntSet_impl.h
#include "StdAfx.h"
#include "IntSet.h"
#pragma region ctor/dtor
template<class T>
IntSet<T>::IntSet():myData_(nullptr),
mySize_(0),
myIndex_(0)
{
}
template<class T>
IntSet<T>::~IntSet()
{
}
#pragma endregion
#pragma region publicInterface
template<class T>
void IntSet<T>::insert(const T& obj)
{/*IF I SET A BREAKPOINT HERE AND AFTER THAT I CHANGE SOMETHING IN THE BODY
I'M GETTING MSG SAYING THAT THE BREAKPOINT WILL NOT CURRENTLY BE HIT, AFTER I REBUILD
THE BREAKPOINT IS VALID AGAIN*/
/*Check if we are initialized*/
if (mySize_ == 0)
{
mySize_ = 1;
myData_ = new T*[mySize_];
}
/*Check if we have place to insert obj in.*/
if (myIndex_ < mySize_)
{
myData_[myIndex_++] = new T(obj);
return;
}
/*We didn't have enough place...*/
T** tmp = new T*[mySize_];//for copying old to temporary basket
std::copy(&myData_[0],&myData_[mySize_],&tmp[0]);
delete myData_;
auto oldSize = mySize_;
mySize_ *= 2;
myData_ = new T*[mySize_];
std::copy(&tmp[0],&tmp[oldSize],&myData_[0]);
myData_[myIndex_] = new T(obj);
++myIndex_;
}
#pragma endregion
Thanks.