Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualL. Spiro

Posted 01 November 2012 - 04:08 PM

Because it isn’t necessarily defined.


[EDIT]
Actually I tested this out about 5 years ago when I was not so advanced. I think I either made a mistake in my testing or I misinterpreted another error as being caused by copy-constructor.

Today, I see no reason it should not work. I am going to redo my tests.
[/EDIT]


[EDIT2]
It does work. I don’t know what my problem was in the past.
When possible, copy-constructors should be used as they reduce construction to a single stage instead of construct-then-copy (though poor implementations of copy constructors may yield the exact same result).

The new code inside of Allocate() is this:

// Construct and copy all the items in the newly allocated array.
			for ( LSUINT32 I = Parent::m_tLen; I--; ) {
				// Construct new.
				new( &ptNew[I] ) _tType( Parent::m_ptData[I] );
				// Destroy old.
				Parent::Destroy( static_cast<_tDataType>(I) );
			}
You could also use copy-constructor inside Insert() for the last element but you will have to rewrite the following array. I leave that up to you.
[/EDIT2]


L. Spiro

#5L. Spiro

Posted 01 November 2012 - 10:35 AM

Because it isn’t necessarily defined.


[EDIT]
Actually I tested this out about 5 years ago when I was not so advanced. I think I either made a mistake in my testing or I misinterpreted another error as being caused by copy-constructor.

With my current level, I see no reason it should not work. I am going to redo my tests.
[/EDIT]


[EDIT2]
It does work. I don’t know what my problem was in the past.
When possible, copy-constructors should be used as they reduce construction to a single stage instead of construct-then-copy (though poor implementations of copy constructors may yield the exact same result).

The new code inside of Allocate() is this:

// Construct and copy all the items in the newly allocated array.
			for ( LSUINT32 I = Parent::m_tLen; I--; ) {
				// Construct new.
				new( &ptNew[I] ) _tType( Parent::m_ptData[I] );
				// Destroy old.
				Parent::Destroy( static_cast<_tDataType>(I) );
			}
You could also use copy-constructor inside Insert() for the last element but you will have to rewrite the following array. I leave that up to you.
[/EDIT2]


L. Spiro

#4L. Spiro

Posted 01 November 2012 - 10:34 AM

Because it isn’t necessarily defined.


[EDIT]
Actually I tested this out about 5 years ago and was not so advanced. I think I either made a mistake in my testing or I misinterpreted another error as being caused by copy-constructor.

With my current level, I see no reason it should not work. I am going to redo my tests.
[/EDIT]


[EDIT2]
It does work. I don’t know what my problem was in the past.
When possible, copy-constructors should be used as they reduce construction to a single stage instead of construct-then-copy (though poor implementations of copy constructors may yield the exact same result).

The new code inside of Allocate() is this:

// Construct and copy all the items in the newly allocated array.
			for ( LSUINT32 I = Parent::m_tLen; I--; ) {
				// Construct new.
				new( &ptNew[I] ) _tType( Parent::m_ptData[I] );
				// Destroy old.
				Parent::Destroy( static_cast<_tDataType>(I) );
			}
You could also use copy-constructor inside Insert() for the last element but you will have to rewrite the following array. I leave that up to you.
[/EDIT2]


L. Spiro

#3L. Spiro

Posted 01 November 2012 - 10:33 AM

Because it isn’t necessarily defined.


[EDIT]
Actually I tested this out about 5 years ago and was not so advanced. I think I either made a mistake in my testing or I misinterpreted another error as being caused by copy-constructor.

With my current level, I see no reason it should not work. I am going to redo my tests.
[/EDIT]


[EDIT2]
It does work. I don’t know what my problem was in the past.
When possible, copy-constructors should be used as they reduce construction to a single stage instead of construct-then-copy.

The new code inside of Allocate() is this:

// Construct and copy all the items in the newly allocated array.
			for ( LSUINT32 I = Parent::m_tLen; I--; ) {
				// Construct new.
				new( &ptNew[I] ) _tType( Parent::m_ptData[I] );
				// Destroy old.
				Parent::Destroy( static_cast<_tDataType>(I) );
			}
You could also use copy-constructor inside Insert() for the last element but you will have to rewrite the following array. I leave that up to you.
[/EDIT2]


L. Spiro

#2L. Spiro

Posted 01 November 2012 - 10:28 AM

Because it isn’t necessarily defined.


[EDIT]
Actually I tested this out about 5 years ago and was not so advanced. I think I either made a mistake in my testing or I misinterpreted another error as being caused by copy-constructor.

With my current level, I see no reason it should not work. I am going to redo my tests.
[/EDIT]


L. Spiro

#1L. Spiro

Posted 01 November 2012 - 10:14 AM

Because it isn’t necessarily defined.


L. Spiro

PARTNERS