Single Stage to Orbit於 2012年8月15日星期三UTC+8上午2時17分26秒 寫道:
> Hello!
>
>
>
> Suppose I have the following:
>
>
>
> int main()
>
> {
>
> typedef boost::tuple<int, int, int> tuple3;
>
> std::vector<tuple3> tuples;
>
>
>
> tuples.push_back(tuple3(1, 2, 3));
>
> tuples.push_back(tuple3(7, 8, 9));
>
> tuples.push_back(tuple3(4, 5, 6));
>
>
>
> for (auto& i : tuples)
>
> std::cout << i.get<0>() << " " << i.get<1>() << " " <<
>
> i.get<2>() << '\n';
>
>
>
> return 0;
>
> }
>
>
>
> Is it even possible to have something like this:
>
>
>
> for (auto& i : tuples)
>
> {
>
> for (unsigned j = 0; j < 3; ++j)
>
> {
>
> std::cout << i.get<j>();
>
> if (j < 3)
>
> std::cout << " ";
>
> }
>
>
>
> std::cout << '\n';
>
> }
>
>
>
> When I try it, GCC 4.6.3 says it's illegal to have an non constant
>
> expression as in 'i.get<j>'. Are there any workarounds for this one?
>
>
>
> Thanks!
>
> --
>
> Tactical Nuclear Kittens
Single Stage to Orbit於 2012年8月15日星期三UTC+8上午2時17分26秒 寫道:
> Hello!
>
>
>
> Suppose I have the following:
>
>
>
> int main()
>
> {
>
> typedef boost::tuple<int, int, int> tuple3;
>
> std::vector<tuple3> tuples;
>
>
>
> tuples.push_back(tuple3(1, 2, 3));
>
> tuples.push_back(tuple3(7, 8, 9));
>
> tuples.push_back(tuple3(4, 5, 6));
>
>
>
> for (auto& i : tuples)
>
> std::cout << i.get<0>() << " " << i.get<1>() << " " <<
>
> i.get<2>() << '\n';
>
>
>
> return 0;
>
> }
>
>
>
> Is it even possible to have something like this:
>
>
>
> for (auto& i : tuples)
>
> {
>
> for (unsigned j = 0; j < 3; ++j)
>
> {
>
> std::cout << i.get<j>();
>
> if (j < 3)
>
> std::cout << " ";
>
> }
>
>
>
> std::cout << '\n';
>
> }
>
>
>
> When I try it, GCC 4.6.3 says it's illegal to have an non constant
>
> expression as in 'i.get<j>'. Are there any workarounds for this one?
>
>
>
> Thanks!
>
> --
>
> Tactical Nuclear Kittens
Do you plan to compress imutable objects into a serializable frozen file in
the hard disk or your own heap manager?
If you are not planning to do that then I don't think immutable tuples
are very helpful.
|