I get a is implicitly deleted because the default definition would be ill-formed
error with below code when I want to add the element to the vector with container.push_back(tmp);
, why is this?
My code:
#include <vector>
#include <mutex>
class A {
public:
A(){}
~A(){}
};
class my_t {
private:
bool busy;
bool alive;
std::mutex bmtx;
std::mutex amtx;
public:
my_t(){std::lock_guard<std::mutex>lock(bmtx);busy=false;}
~my_t(){}
A* conn;
void take(void) {std::lock_guard<std::mutex>lock(bmtx);busy=true; }
void give(void) {std::lock_guard<std::mutex>lock(bmtx);busy=false; }
bool busy_get(void) {return busy;}
void set_online(void){ std::lock_guard<std::mutex>lock(amtx); alive=true; }
void set_OFFLINE(void) {std::lock_guard<std::mutex>lock(amtx); alive=false; }
bool alive_get(void) {return alive;}
};
class app {
private:
std::vector<my_t> container;
public:
app();
~app();
};
app::app() {
my_t tmp;
tmp.conn = new A();
if (tmp.conn)
tmp.set_online();
container.push_back(tmp);
}
int main(void) {}
or on Coliru: https://coliru.stacked-crooked.com/a/11625c77383df80c