Boost logo

Boost Users :

From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2007-08-17 06:09:53


chun ping wang skrev:
> Question 1.
> std::vector<Roles> vr;
> the constructor for Roles:
> enum Role { .....};
> explicit Roles (const std::string& usr, const Role& r);
> How would I use boost::assign::list_of to assign a vector of Roles
> instead of doing regular vector push_back.

vr = list_of<Roles>( "foo", Role1 )( "bar", Role2 );

> Question 2.
> Related.
> I have a Hash map i.e. boost::unordered_map<std::string,
> compositionType> and i want to use boost::map_list_of how would i do that.

Does the normal way for maps not work?

> Question 3.
> trying to use operator += in boost::assignment i get error specifying
> unknown types.
> typedef boost::function<std::vector<int>(std::vector<int>)> sortfunc;
> std::vector<sortfunc> function_list;
> // quicksort random
> function_list += (&quicksort<QSTYPE(RANDOM), int, std::vector>)
> // quicksort median
> (&quicksort<QSTYPE(MEDIAN), int, std::vector>) // error here.
> // quicksort mediantriple
> (&quicksort<QSTYPE(MEDIANTRIPLE), int, std::vector>)
> // merge sort
> (&mergesort<int, std::vector>)
> // heap sort
> (&heapsort<int, std::vector>)
> // selection sort
> (&selection_sort<int, std::vector>)
> // standard sort
> (&standard_sort<int, std::vector>);

operator += requires a comma-separated list IIRC.

use push_back( function_list )(...)(...)

-Thorsten


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net