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
This commit is contained in:
Бычков Андрей
2022-08-12 18:14:55 +03:00
parent f07f814b08
commit 00f7a24d54
6 changed files with 555 additions and 38 deletions

View File

@@ -1,13 +1,76 @@
#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[]) {
//PIMap<int, PIString> v{{1, "xdsa"},{2, "blya"},{3, "\n"}};
PIVector<int> x{1,2};
piCout << 1 << 2;
piCout << 1 << 2;
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;
}