A
abir
Hi
I am using an object with a const member like ,
struct Foo{
const int x_;
explicit Foo(int x) : x_(x){}
};
I am happy with default copy ctor ...
but as its member is const, i can't make it assignable.
if i have std::vector<Foo> FV;
FV v; v.push_back(Foo(1));
Now i can't store it in vector. push_back internally calls insert and
which somewhere needs fill.
Why it is required at all,?
I have a handcrafted vector class where push_back does not need
assignment (not even copy ctor, an move op is sufficient)
I don't know where it is required apart from v = Foo(3); or
equivalently *it = Foo(3); kind of statement.
even for insert at the mid i can transfer the mid elements at the
tail and copy /move construct the new elements at the raw memory at
mid.
Can anybody help me here?
Thanks
I am using an object with a const member like ,
struct Foo{
const int x_;
explicit Foo(int x) : x_(x){}
};
I am happy with default copy ctor ...
but as its member is const, i can't make it assignable.
if i have std::vector<Foo> FV;
FV v; v.push_back(Foo(1));
Now i can't store it in vector. push_back internally calls insert and
which somewhere needs fill.
Why it is required at all,?
I have a handcrafted vector class where push_back does not need
assignment (not even copy ctor, an move op is sufficient)
I don't know where it is required apart from v = Foo(3); or
equivalently *it = Foo(3); kind of statement.
even for insert at the mid i can transfer the mid elements at the
tail and copy /move construct the new elements at the raw memory at
mid.
Can anybody help me here?
Thanks