Boost logo

Boost :

From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2003-01-09 14:47:21


----- Original Message -----
From: "Terje Slettebø" <tslettebo_at_[hidden]>

> > And since there are techniques for making out-of-class definitions
easier
> > (and automatic), which may be instantiated if needed, like you showed,
then
> > static const seems clearly best.
>
> That's not nearly so easy to take care of if the metafunction in
> question is something like alignment_of<T> which could potentially
> have lots of values, depending on the T chosen.

<quote>
In what way would this affect Paul's suggestion:

template<class T, T V> struct map_integral {
    static const T value = V;
};

template<class T, T V> const T map_integral<T, V>::value;

By the way, this could have been done with mpl::integral_c, as well,
provided the out-of-class definition is given.

Do you maybe refer to that each value may take up space in the executable,
if used in such a way that instantiation is needed? That's right, and that's
not the case for enum. Still, there are the issues for enum, as well.
</quote>

You would have to have more than one "map_integral" with a different value
name, where the values are dependent on one another and are part of the
public interface. It isn't a complete solution, but it does work in most
cases.

Paul Mensonides


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk