Boost logo

Boost Users :

From: Christian Henning (chhenning_at_[hidden])
Date: 2005-10-08 17:10:27


I'm not sure why you would want to use traits here. I think traits are
used for compile-time if...else tests on types.

Why not use a static numerical member in classes that you put in your
map and so you could use a switch statement to figure out what type
you are using?

There are probably better ways to do that. RTTI ain't!

Christian

On 10/7/05, Piyush Kapadia <piyush.kapadia_at_[hidden]> wrote:
>
>
>
> I am new user of Boost, I tried to use boost::variant first, but in
> comparison to boost::any performance of boost::variant appears to be around
> 4 times slower, so settled for boost::any.
>
>
>
> Also boost::any has cleaner interface but I don't know how to query current
> type information for boost::any ?
>
>
>
> My code looks like following
>
>
>
> map<unsigned int, boost::any> result_table;
>
>
>
> result_table[1] = 543.434;
>
> vector<int> vec;
>
> …. Some vec population code;
>
> result_table[2] = vec;
>
>
>
> Now I need to develop a stringify function for result_table;
>
>
>
> I can fetch the results back as
>
> boost::any value = result_table[2];
>
>
>
> But I need to know the type of value, so that I can treat it accordingly to
> stringify;
>
> I know there exists type_traits, but very limited examples of type_traits is
> provided on Boost documentation and particularly, I am clueless about how to
> use type_traits in above context to find out what is the current type
> returned by result_table[int]
>
>
>
> Also I want to know if Boost has any Hash map implementation that can be
> superior in performance compare to regular std::map ??
>
>
>
> Thanks,
>
>
>
>
>
> Piyush
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>


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