c++11 - c++ send arguments to union (variable union) -
well cant find how this, variable union params, basic idea, (writed function)
ex1
union (int le) { int i[le]; float f[le]; };
ex2
union { int le; int i[le]; float f[le]; };
obs don't works d: maybe way use internal variable set lenght don't works too. thx.
no, not possible: le
need known @ compile-time.
one solution use templated union:
template <int n> union { int i[n]; float f[n]; };
n
, of course, compile-time evaluable.
another solution arguably more succinct
typedef std::vector<std::pair<int, float>> some;
or similar solution based on std::array
.
Comments
Post a Comment