Boost logo

Boost :

From: rogeeff (rogeeff_at_[hidden])
Date: 2002-01-20 12:22:01


--- In boost_at_y..., "Ralf W. Grosse-Kunstleve" <rwgk_at_y...> wrote:
> (This question is related to my previous posting.)
>
> Here is something I am often wondering about:
>
> template <typename NumVectorType>
> NumVectorType operator*(const NumVectorType& lhs, const
NumVectorType& rhs);
>
> Is there a way to classify or register types as NumVectorTypes?
>
> I know how to make a distinction between types once I am
> /inside/ the function (using traits). However, what I am
> after is something like:
>
> tell_compiler {
> possible typename NumType:
> double
> float
> etc.
> possible typename NumVectorType:
> std::vector<NumType>
> boost::array<NumType, *>
> etc.
> }
>
> Then the compiler should select template functions only if the
> concrete type is registered under the typename label.
>
> Is this asking for a formalization of "concepts?"
> To which degree can this be emulated with the language as-is?
> What can we expect in the future (from the standard committee)?
>
> Thanks,
> Ralf

I was thinking in this direction some time ago. The closest thing I
found is to define partial specialization by type list. But I did not
find a way to define automatically all specialization by given
typelist T and template definition foo<t>. For example,
  if T = int, fload, double

then I want to write foo<T> and compiler should understand it like
foo<int>
foo<float>
foo<double>

Does anybode know the MP solution (if there is one)?

Gennadiy.


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