
Hello, I want to use boost::any in a project where I want store different values or pointers. What is the fastest solution to make the different actions for different value types? Using the type() member function? Is it also possible to detect if the value is a pointer or a value? Best regards Hansjörg

Hi, Just a wonder: why did you choose to use boost::any rather than boost::variant? In case of boost::variant you could use static visiting instead of checking the types in runtime "to make the different actions for different value types" .
I want to use boost::any in a project where I want store different > values or pointers.> What is the fastest solution to make the different actions for different > value types? Using the type() member function?> Is it also possible to detect if the value is a pointer or a value?> > Best regards> Hansjörg> > _______________________________________________> Boost-users mailing list> Boost-users@lists.boost.org> http://lists.boost.org/mailman/listinfo.cgi/boost-users
News, entertainment and everything you care about at Live.com. Get it now! http://www.live.com/getstarted.aspx

First I wanted to use boost::variant. It would be the best solution, i think. The problem is that I have at least the datatypes: unsigned char char unsigned short short unsigned int int unsigned long long long long double float string wstring and maybe some pointer types and there is the problem. I think the variant datatype can use only 10 different parameters. Isn't it? Best regards Hansjörg Igor R. schrieb:
Hi,
Just a wonder: why did you choose to use boost::any rather than boost::variant? In case of boost::variant you could use static visiting instead of checking the types in runtime "to make the different actions for different value types" .
I want to use boost::any in a project where I want store different values or pointers. What is the fastest solution to make the different actions for different value types? Using the type() member function? Is it also possible to detect if the value is a pointer or a value?
Best regards Hansjörg
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
------------------------------------------------------------------------ Get news, entertainment and everything you care about at Live.com. Check it out! <http://www.live.com/getstarted.aspx >
------------------------------------------------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

and there is the problem. I think the variant datatype can use only 10 different parameters. Isn't it?
The maximal number of types is limited by BOOST_VARIANT_LIMIT_TYPES macro, which is defined in 1.35 as follows: #if !defined(BOOST_MPL_LIMIT_LIST_SIZE)# define BOOST_MPL_LIMIT_LIST_SIZE 20#endif #define BOOST_VARIANT_LIMIT_TYPES BOOST_MPL_LIMIT_LIST_SIZE So it's default is 20, but IIUC you can set it to anything (>=10) _________________________________________________________________ Discover the new Windows Vista http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE

you are right. I missunderstood the last comment.... maybe I should switch the code to the variant type...it is for sure better... Igor R. schrieb:
and there is the problem. I think the variant datatype can use only 10 different parameters. Isn't it?
The maximal number of types is limited by _BOOST_VARIANT_LIMIT_TYPES_ http://www.boost.org/doc/libs/1_35_0/doc/html/BOOST_VARIANT_LIMIT_TYPES.html macro, which is defined in 1.35 as follows:
#if !defined(BOOST_MPL_LIMIT_LIST_SIZE) # define BOOST_MPL_LIMIT_LIST_SIZE 20 #endif
#define BOOST_VARIANT_LIMIT_TYPES BOOST_MPL_LIMIT_LIST_SIZE
So it's default is 20, but IIUC you can set it to anything (>=10)
------------------------------------------------------------------------ Discover the new Windows Vista Learn more! http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE
------------------------------------------------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

AMDG Igor R. wrote:
and there is the problem. I think the variant datatype can use only 10 different parameters. Isn't it?
The maximal number of types is limited by _BOOST_VARIANT_LIMIT_TYPES_ http://www.boost.org/doc/libs/1_35_0/doc/html/BOOST_VARIANT_LIMIT_TYPES.html macro, which is defined in 1.35 as follows:
#if !defined(BOOST_MPL_LIMIT_LIST_SIZE) # define BOOST_MPL_LIMIT_LIST_SIZE 20 #endif
#define BOOST_VARIANT_LIMIT_TYPES BOOST_MPL_LIMIT_LIST_SIZE
So it's default is 20, but IIUC you can set it to anything (>=10)
In Addition, you can bypass this limitation by using make_variant_over, which takes an MPL sequence. In Christ, Steven Watanabe

Hansi wrote:
Hello,
I want to use boost::any in a project where I want store different values or pointers. What is the fastest solution to make the different actions for different value types? Using the type() member function? Is it also possible to detect if the value is a pointer or a value?
I would suggest that such requirements indicate a necessity to rethink your design. Consider looking up the Liskov Substitution Principle to discuss why what you seem to be planning could seriously stab you in the face later.
participants (4)
-
Hansi
-
Igor R.
-
Noah Roberts
-
Steven Watanabe