}
myPointer = myAllocator.allocate(mySize);
myIsOwner = true;
- construct();
+ construct(0, mySize);
}
explicit NCollection_Array1(const allocator_type& theAlloc,
}
myPointer = myAllocator.allocate(mySize);
myIsOwner = true;
- construct();
+ construct(0, mySize);
}
explicit NCollection_Array1(const_reference theBegin,
}
myPointer = myAllocator.allocate(mySize);
myIsOwner = true;
- construct();
+ construct(0, mySize);
}
//! Copy constructor
{
return;
}
- destroy();
+ destroy(myPointer, 0, mySize);
myAllocator.deallocate(myPointer, mySize);
}
}
if (myIsOwner)
{
- destroy();
+ destroy(myPointer, 0, mySize);
myAllocator.deallocate(myPointer, mySize);
}
myLowerBound = theOther.myLowerBound;
{
Standard_RangeError_Raise_if(theUpper < theLower, "NCollection_Array1::Resize");
const size_t aNewSize = static_cast<size_t>(theUpper - theLower + 1);
- const size_t anOldSize = mySize;
pointer aPrevContPnt = myPointer;
- if (aNewSize == anOldSize)
+ if (aNewSize == mySize)
{
myLowerBound = theLower;
return;
if (theToCopyData)
destroy(myPointer, aNewSize, mySize);
else
- destroy();
+ destroy(myPointer, 0, mySize);
}
myLowerBound = theLower;
- mySize = aNewSize;
if (theToCopyData)
{
- const size_t aMinSize = std::min<size_t>(aNewSize, anOldSize);
+ const size_t aMinSize = std::min<size_t>(aNewSize, mySize);
if (myIsOwner)
{
myPointer = myAllocator.reallocate(myPointer, aNewSize);
myPointer = myAllocator.allocate(aNewSize);
copyConstruct(aPrevContPnt, aMinSize);
}
- construct(anOldSize, aNewSize);
+ construct(mySize, aNewSize);
}
else
{
if (myIsOwner)
myAllocator.deallocate(aPrevContPnt, mySize);
myPointer = myAllocator.allocate(aNewSize);
- construct();
+ construct(0, aNewSize);
}
+ mySize = aNewSize;
myIsOwner = true;
}
protected:
template <typename U = TheItemType>
- typename std::enable_if<std::is_arithmetic<U>::value, void>::type construct()
+ typename std::enable_if<std::is_trivially_default_constructible<U>::value, void>::type construct(
+ const size_t,
+ const size_t)
{
// Do nothing
}
template <typename U = TheItemType>
- typename std::enable_if<!std::is_arithmetic<U>::value, void>::type construct()
- {
- for (size_t anInd = 0; anInd < mySize; anInd++)
- {
- myAllocator.construct(myPointer + anInd);
- }
- }
-
- template <typename U = TheItemType>
- typename std::enable_if<std::is_arithmetic<U>::value, void>::type construct(const size_t,
- const size_t)
- {
- // Do nothing
- }
-
- template <typename U = TheItemType>
- typename std::enable_if<!std::is_arithmetic<U>::value, void>::type construct(const size_t theFrom,
- const size_t theTo)
+ typename std::enable_if<!std::is_trivially_default_constructible<U>::value, void>::type construct(
+ const size_t theFrom,
+ const size_t theTo)
{
for (size_t anInd = theFrom; anInd < theTo; anInd++)
{
}
template <typename U = TheItemType>
- typename std::enable_if<std::is_arithmetic<U>::value, void>::type destroy()
- {
- // Do nothing
- }
-
- template <typename U = TheItemType>
- typename std::enable_if<!std::is_arithmetic<U>::value, void>::type destroy()
- {
- for (size_t anInd = 0; anInd < mySize; anInd++)
- {
- myAllocator.destroy(myPointer + anInd);
- }
- }
-
- template <typename U = TheItemType>
- typename std::enable_if<std::is_arithmetic<U>::value, void>::type destroy(pointer,
- const size_t,
- const size_t)
+ typename std::enable_if<std::is_trivially_destructible<U>::value, void>::type destroy(
+ pointer,
+ const size_t,
+ const size_t)
{
// Do nothing
}
template <typename U = TheItemType>
- typename std::enable_if<!std::is_arithmetic<U>::value, void>::type destroy(pointer theWhat,
- const size_t theFrom,
- const size_t theTo)
+ typename std::enable_if<!std::is_trivially_destructible<U>::value, void>::type destroy(
+ pointer theWhat,
+ const size_t theFrom,
+ const size_t theTo)
{
for (size_t anInd = theFrom; anInd < theTo; anInd++)
{