Renouncement
I am trying to allocate an array of objects that are not constructive for copying, are assigned and do not have a default constructor. Objects have arguments that are determined at runtime. I know that you can solve this problem by having an array of pointers or skillfully using a new placement, but I'm more interested if this can be done using the magic of C ++ 11 (1y). So, please, this is a purely theoretical interest, so do not try to solve "my problem" by offering a job.
The code...
... So the question is: is there a way to do the following work in C ++ 11 or C ++ 14:
class X{
public:
explicit X(int a){...}
X(const X&) = delete;
void operator = (const X&) = delete;
private:
...
};
class Y{
public:
Y(const std::vector<int>& args) {
x = new X[]{args};
}
~Y(){
delete [] x;
}
private:
X* x;
};
Criteria
, /, :
- X .
- X .
- X ( ).
- X .
- X .
- X , ( , ). .
/
, . X this , .