[boost-users] boost assignment problem on non primitive type.
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. 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. 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>); Thanks for any help in advanced.
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
thanks. So how would i repalce this using repeat. for (int i = 0; i < 20; ++i) v.push_back(parser.value("titles[]", i)); or it does not seems to be possible. On 8/17/07, Thorsten Ottosen <thorsten.ottosen@dezide.com> wrote:
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 mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
chun ping wang
-
Thorsten Ottosen