52 lines
1.5 KiB
C++
52 lines
1.5 KiB
C++
#include "pip.h"
|
|
#include "pivariantsimple.h"
|
|
|
|
#pragma pack(push, 1)
|
|
struct MM {
|
|
int x;
|
|
int x2;
|
|
double y;
|
|
char c[16];
|
|
int e2;
|
|
int e;
|
|
//PIPointd h;
|
|
};
|
|
#pragma pack(pop)
|
|
|
|
int Acnt = 0;
|
|
|
|
class A {
|
|
public:
|
|
A() {moved = false; i = "constructor"; piCout << "A()"; ++Acnt;}
|
|
A(const PIString & s): i(s) {moved = false; piCout << "A(String)"; ++Acnt;}
|
|
A(const A & a): i(a.i) {moved = false; piCout << "copy A(&)"; ++Acnt;}
|
|
A(A && a): i(std::move(a.i)) {moved = false; a.moved = true; piCout << "copy A(&&)"; ++Acnt;}
|
|
~A() {piCout << "~A()" << moved; --Acnt;}
|
|
void swap(A & a) {piCout << "swap A()"; piSwap(i, a.i);}
|
|
A & operator =(const A & a) {i = a.i; piCout << "= A&"; return *this;}
|
|
A & operator =(A && a) {piSwap(i, a.i); a.moved = true; piCout << "= A&&)"; return *this;}
|
|
bool operator ==(const A & a) {return true;}
|
|
PIString i;
|
|
bool moved;
|
|
MM m;
|
|
static void F(int) {}
|
|
};
|
|
|
|
inline PIByteArray & operator <<(PIByteArray & ba, const A & v) {ba << v.i << v.m; return ba;}
|
|
inline PIByteArray & operator >>(PIByteArray & ba, A & v) {ba >> v.i >> v.m; return ba;}
|
|
|
|
inline PIByteArray & operator <<(PIByteArray & ba, const MM & v) {piCout << "<<"; ba << v.x << v.y << v.c; return ba;}
|
|
inline PIByteArray & operator >>(PIByteArray & ba, MM & v) {piCout << ">>"; ba >> v.x >> v.y >> v.c; return ba;}
|
|
|
|
|
|
int main() {
|
|
PIMathMatrixd m = PIMathMatrixd::identity(3,3);
|
|
m.fill(0);
|
|
PIMathMatrixd m2 = PIMathMatrixd::identity(3,4);
|
|
piCout << m;
|
|
piCout << m2;
|
|
piCout << m * m2;
|
|
piCout << m2 * m;
|
|
return 0;
|
|
}
|