home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,662 of 33,346   
   greg to All   
   boost.fusion vector question   
   21 Nov 12 12:48:19   
   
   From: gregory.newmann@googlemail.com   
      
   Hi,   
      
   I am looking for help from some boost guru. Here is the problem: I   
   have a matrix M of the following type:   
      
   typedef fusion::vector row;   
   std::vector M;   
      
   This matrix is supposed to be used as a parameter to a function   
   Accumulate:   
      
   Accumulate( fun<0>(M) );   
      
   where Accumulate is defined as   
      
   template    
   typename T::value_type Accumulate( T const &t )   
   {   
   	typedef typename T::value_type value_type;   
   	return std::accumulate( t.begin(), t.end(), value_type() );   
   }   
      
      
   Obviously, my task is to write the interface function fun   
      
   template    
      ??? fun( T const &t )   
      
   returning a representation of an arbitrary chosen column. No copying   
   of data is supposed to take place so I assume I am expected to return   
   some kind of a boost view which in addition needs to be iterable in   
   the stl containers sense.   
      
   Yes, you are right, this was an interview question, and no, I did not   
   make the cut. Nevertheless for my own education I would like to know   
   the solution and any clues are welcomed.   
      
   Thanks,   
   G.   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca