|
Boost Users : |
From: Robert Dailey (rcdailey_at_[hidden])
Date: 2007-11-16 19:02:21
So far, this is all I've been able to come up with:
#include <boost/mpl/map.hpp>
#include <boost/mpl/at.hpp>
namespace detail
{
template< unsigned int t_value >
struct integral
{
static const unsigned int value = t_value;
};
typedef boost::mpl::map< boost::mpl::pair<float, integral<GL_FLOAT>
>,
boost::mpl::pair<double, integral<GL_DOUBLE>
>
> glTypeMap;
};
template< typename t_type >
struct Vertex
{
static const unsigned int type = boost::mpl::at<detail::glTypeMap,
t_type>::type::value;
t_type x, y, z;
};
On Nov 16, 2007 5:48 PM, Robert Dailey <rcdailey_at_[hidden]> wrote:
> Hi,
>
> I'm looking for a complete compile-time constant map container that uses
> types as keys and integral constants as values. For example:
>
> typedef map< pair<float, 90>, pair<unsigned int, 3> > mapType;
> unsigned int value = get_value<mapType, float>::value;
>
> The above code is PSEUDO CODE only. It is supposed to give you an idea of
> what I'm looking for. I tried using boost::fusion::map, however the
> fusion::pair object expects a TYPE as the second template argument, so I
> can't specify integral values. Could someone provide a code example that
> achieves the above? Note that I should be able to do the following as well:
>
> typedef map< pair<float, 90>,
> pair<unsigned int, 3>
> > mapType;
>
> class foo
> {
> // This would result in 'value' being the integral number 90.
> static const unsigned int value = get_value<mapType, float>::value;
> }
>
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