Home » Community » Newbie corner » moveable question
moveable question [message #38005] |
Wed, 28 November 2012 04:56 |
|
Hi-
In the following sample I thought this would break the moveable assertion. I used a class instead of a struct. I hooked up ultimate++ tonight and I wanted to see how moveable worked.
Please see my one in-line comment.
thanks for any assistance. - jim
#include <Core/Core.h>
#include<iostream>
using namespace Upp;
using namespace std;
class SimpleVector: Moveable<SimpleVector>{
UPP::Vector<int*> v;
int * val;
int a;
SimpleVector * sv;
public:
SimpleVector();
SimpleVector& operator=( const SimpleVector& rhs );
~SimpleVector();
void TestMove();
};
SimpleVector::SimpleVector(){
int n = 2;
int * y = &n;
v.Add(y);
cout<<*v[0];
}
SimpleVector::~SimpleVector(){
AssertMoveable<SimpleVector>();
}
void SimpleVector::TestMove(){
val = &a;
sv = this;
// thought these 2 would break moveable assertion per the example in docs ??
}
SimpleVector& SimpleVector::operator=( const SimpleVector& rhs ){
sv= rhs.sv;
return *this;
}
CONSOLE_APP_MAIN
{
SimpleVector s;
s.TestMove();
}
|
|
|
Goto Forum:
Current Time: Mon May 13 12:31:45 CEST 2024
Total time taken to generate the page: 0.02531 seconds
|