A
Andrey Vul
I'm building a multi-dimensional array using std::vector and I want to
know there's a way (without using old-fashioned pointers) to alias
elements from one to another by reference rather than by value (and
invoking possibly significant overhead from operator=).
Using vector < vector< ... >& > invokes compiler errors.
Example:
vector< vector<unsigned> > foo;
/* ... initialize elements of foo */
vector< vector<unsigned> > bar;
bar[0] = foo[2]; // (*)
bar[3] = foo[1]; // (*)
/* ... continue initializing elements of bar */
Is there a way to do the operation in (*) by using pass-by-reference,
so that, e.g. &(bar[0]) == &(foo[2]) ?
know there's a way (without using old-fashioned pointers) to alias
elements from one to another by reference rather than by value (and
invoking possibly significant overhead from operator=).
Using vector < vector< ... >& > invokes compiler errors.
Example:
vector< vector<unsigned> > foo;
/* ... initialize elements of foo */
vector< vector<unsigned> > bar;
bar[0] = foo[2]; // (*)
bar[3] = foo[1]; // (*)
/* ... continue initializing elements of bar */
Is there a way to do the operation in (*) by using pass-by-reference,
so that, e.g. &(bar[0]) == &(foo[2]) ?