multi_index_container: modification of a non-key member of a value_type
Let say we have
struct A {...}; struct B {...}; struct C {...};
And we define a container of objects that hold these three structures:
struct Whole { A a; B b; C c; };
multi_index_container
container;
As you can see only a and b are the keys, c is just a member.
Let's also say that we've got an iterator "it" pointing to an element
in the container
(through what index the iterator has been retrieved is immaterial at
this point).
And we want to modify "c" member of that element.
Is this safe:
*const_cast
Hi Andy,
----- Mensaje original -----
De: "Venikov, Andy"
Let say we have
struct A {...}; struct B {...}; struct C {...};
And we define a container of objects that hold these three structures:
struct Whole { A a; B b; C c; };
multi_index_container
> >, indexed_by< ordered_unique< member > > container;
This definition is incorrect, but I assume you mean the following:
multi_index_container<
Whole,
indexed_by<
ordered_unique< member
container;
As you can see only a and b are the keys, c is just a member.
Let's also say that we've got an iterator "it" pointing to an element in the container
(through what index the iterator has been retrieved is immaterial at this point).
And we want to modify "c" member of that element.
Is this safe:
*const_cast
(&it->c) = <new value of c> ??? [...]
Well, the expression above is incorrect, I take you meant this
instead:
*const_cast
participants (2)
-
"JOAQUIN LOPEZ MU?Z"
-
Venikov, Andy