Files
pip/main.cpp
Бычков Андрей 00f7a24d54 new caontainers functions
atWhere()
lastAtWhere()
contains(v)
filter(), map(), reduce(), forEach() indexed and reverse variants
fix PIDeque reverse for
fix insert with move of complex type potential segfault
2022-08-12 18:14:55 +03:00

77 lines
1.2 KiB
C++

#include "pip.h"
#include "piiostream.h"
#include "pibytearray.h"
#include <vector>
using namespace PICoutManipulators;
class A {
public:
A(int id) : id_(id) {
piCout << "A()" << id_ << this;
}
A(const A & a) {
id_ = a.id_;
piCout << "A(A)" << id_ << this;
}
A(A && a) {
std::swap(id_, a.id_);
piCout << "move A(A)" << id_ << this;
}
~A() {
piCout << "~A()" << id_ << this;
//id_ = 0;
}
inline A & operator =(const A & a) {
id_ = a.id_;
piCout << "A =" << id_ << this;
return *this;
}
inline A & operator =(A && a) {
std::swap(id_, a.id_);
piCout << "move A=" << id_ << this;
return *this;
}
private:
int id_;
};
//class B {
//public:
// B() {a_ = nullptr;}
// ~B() {if (a_) delete a_;}
// void setA(A && a) {
// a_ = (A *)malloc(sizeof(a));
// memcpy(a_, &a, sizeof(a));
// operator delete(&a);
// }
// void setA(const A & a) {a_ = new A(a);}
//private:
// A * a_;
//};
int main(int argc, char * argv[]) {
piCout << "pip 3.1";
{
PIDeque<A> v;
v.push_back(A(1));
// v.push_back(A(2));
}
piCout << "std";
{
std::vector<A> v;
v.push_back(A(1));
// v.push_back(A(2));
}
return 0;
}