E
Emanuel Ziegler
Hi,
I am using the vector class from the STL. Normally, I initialize values
element by element, which is very uncomfortable and sometimes impossible
(e.g. when passing a constant vector to an inherited constructor, since I
cannot create a temporary vector before calling).
Is there a possibility to assign a vector in one line, like it is possible
for arrays?
I want to write code like this:
#include <vector>
typedef std::vector<int> ivec;
void test (ivec w) {};
int main () {
// Is there a possibility to make these lines valid
// (e.g. by extending the vector class)?
ivec v = {1, 2};
v = {3, 4};
test({5, 6});
return 0;
}
Is there at least a workaround for calling
aconstructor () : inheritedconstructor({5, 6}) {
...
}
where inheritedconstructor needs a vector?
Please help,
Emanuel
I am using the vector class from the STL. Normally, I initialize values
element by element, which is very uncomfortable and sometimes impossible
(e.g. when passing a constant vector to an inherited constructor, since I
cannot create a temporary vector before calling).
Is there a possibility to assign a vector in one line, like it is possible
for arrays?
I want to write code like this:
#include <vector>
typedef std::vector<int> ivec;
void test (ivec w) {};
int main () {
// Is there a possibility to make these lines valid
// (e.g. by extending the vector class)?
ivec v = {1, 2};
v = {3, 4};
test({5, 6});
return 0;
}
Is there at least a workaround for calling
aconstructor () : inheritedconstructor({5, 6}) {
...
}
where inheritedconstructor needs a vector?
Please help,
Emanuel