question about boost tuple and template
Dear all,
I have the problem:
vec1 is of the type vector<boost::tuple<int, double>>
vec2 is of the type vector<boost::tuple<int, double, double>>
vec3 is of the type vector<boost::tuple<int, double, string>>
I have to write a template with name columnViewOfTuple such that
columnViewOfTuple<0>(vec1)
columnViewOfTuple<1>(vec1)
columnViewOfTuple<0>(vec2)
columnViewOfTuple<1>(vec2)
columnViewOfTuple<2>(vec2)
columnViewOfTuple<1>(vec3)
columnViewOfTuple<2>(vec3)
returns the view of the specified column.
Can anybody give me some clues?
Re: question about boost tuple and template
Quote:
returns the view of the specified column
What do you mean with "the view"?
Re: question about boost tuple and template
Quote:
Originally Posted by
cilu
What do you mean with "the view"?
i mean, if vec1 ={<1, 1.1>,
<2, 2.2>,
<3, 3.3>,
<4, 4,4>}
columnViewOfTuple <0>(vec1)
returns
{1, 2, 3, 4}
Re: question about boost tuple and template
If you only want read-only access with the view, you can return a copy of the data from the function.
If you want write access with the view, you'll have to return a custom class from the function that mimics the functionality of std::vector and refers internally to a column of a vector<tuple<...> >.
Re: question about boost tuple and template
Hi,
Did you ever get anywhere with this? I'm have the same problem and ideally would not want to copy data...