CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2009
    Posts
    2

    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?

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: question about boost tuple and template

    returns the view of the specified column
    What do you mean with "the view"?
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #3
    Join Date
    Jun 2009
    Posts
    2

    Re: question about boost tuple and template

    Quote Originally Posted by cilu View Post
    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}

  4. #4
    Join Date
    Jul 2005
    Location
    Netherlands
    Posts
    2,042

    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<...> >.
    Cheers, D Drmmr

    Please put [code][/code] tags around your code to preserve indentation and make it more readable.

    As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky

  5. #5
    Join Date
    Sep 2009
    Posts
    19

    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...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured