variant with shrink
boost::variant should be variant<int,int> => int variant<int,double> => double variant<int,boost::rational<int> > => boost::rational<int> variant<int,double,std::string> => variant<double,std::string> I wrote such extension https://github.com/niitsuma/variant_shrink
2013/2/27 Niitsuma Hirotaka <hirotaka.niitsuma@gmail.com>
boost::variant should be
variant<int,int> => int
variant<int,double> => double
variant<int,boost::rational<int> > => boost::rational<int>
variant<int,double,std::string> => variant<double,std::string>
1. Is double guaranteed to be a superset of int?
2. Do you lose the information, which type is contained (int/double)? Regards, Kris
I wrote such extension
https://github.com/niitsuma/variant_shrink _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
You can edit your prefer type generalize oder typedef boost::mpl::vector<int,boost::rational<int>,float,double,long double,std::complex<double>,std::complex<long double> >::type ordered_number_types; => typedef boost::mpl::vector<bool,char,int,boost::rational<int> >::type ordered_number_types;
1. Is double guaranteed to be a superset of int? 2. Do you lose the information, which type is contained (int/double)?
Regards, Kris
I wrote such extension
On Wed, Feb 27, 2013 at 5:10 AM, Niitsuma Hirotaka < hirotaka.niitsuma@gmail.com> wrote:
You can edit your prefer type generalize oder
typedef boost::mpl::vector<int,boost::rational<int>,float,double,long double,std::complex<double>,std::complex<long double> >::type ordered_number_types;
=>
typedef boost::mpl::vector<bool,char,int,boost::rational<int> >::type ordered_number_types;
float tends not to hold all ints. double usually does, although I'm not sure it is guaranteed. Tony
float tends not to hold all ints. double usually does, although I'm not sure it is guaranteed.
Such complicated type order can use by defining is_generalizable_to<T, BaseType> plz see section define is_generalizable_to : in https://github.com/niitsuma/variant_shrink
participants (3)
-
Gottlob Frege
-
Krzysztof Czainski
-
Niitsuma Hirotaka