[mpl] value2type generalization of int_ needed

mpl has int_ which wraps an int value, but I've needed something similar for other types, in particular, for enumerated types. I'm suggesting something like: //template to create a type from a value of some type. template < typename ValueType //type of value to be "typified"
struct value2type { typedef ValueType value_type ; template < value_type ValueInstance //value to be typified. > struct instance //the type created from ValueInstance {}; }; The name is modelled after In2Type in Alexandrescu's _Modern C++ Design_ which is also where the "typified" comes from. Could this template, or something like it be added to mpl?

Larry Evans wrote:
mpl has int_ which wraps an int value, but I've needed something similar for other types, in particular, for enumerated types. I'm suggesting something like: [snip]
Could this template, or something like it be added to mpl?
What's wrong with mpl::integral_c<> ? -- Daniel Wallin

On 12/29/2004 06:46 AM, Larry Evans wrote:
On 12/29/2004 05:33 AM, Daniel Wallin wrote: [snip]
What's wrong with mpl::integral_c<> ?
OOPS. I missed that. Thanks.
I started to use it; however, in the particular application I have (located at http://boost-sandbox.sourceforge.net/vault/index.php? in placeholders_test.cpp), the T must be separate from the value. In other words instead of: template<class T, T N> struct integral_c, I need the N to be separate in order to use it as the a_index template argument to typemap_valued_placeholdered<,>::at<a_index>. Can you see any other way? TIA.

On 12/29/2004 07:08 AM, Larry Evans wrote: [snip]
in placeholders_test.cpp), the T must be separate from the value. In other words instead of:
template<class T, T N> struct integral_c,
I need the N to be separate in order to use it as the a_index template argument to typemap_valued_placeholdered<,>::at<a_index>.
Can you see any other way?
Never mind. I figured it out. Thanks anyway.
participants (2)
-
Daniel Wallin
-
Larry Evans