Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-01-04 18:25:44


Terje Slettebø <tslettebo_at_[hidden]> writes:

>>From: "David Abrahams" <dave_at_[hidden]>
>
>> "Jaap Suter" <J.Suter_at_[hidden]> writes:
>>
>> > Mm, I still don't quite understand. Consider the following function:
>> >
>> > void foo( int_c< 0 > );
>> >
>> > Shouldn't the following code:
>> >
>> > foo( int_c< minus< int_c< 4 >, int_c< 4 > >::type > );
>> >
>> > Behave the same as this:
>> >
>> > foo( minus< int_c< 4 >, int_c< 4 > >::type );
>>
>> We'd like it to. However, as Aleksey said, until we get typedef
>> templates, there's no way to make int_c<0> into the same type as
>> integral_c<int,0>. The result of
>>
>> minus< int_c< 4 >, int_c< 4 > >::type
>> is
>> integral_c<int,0>
>
> You could get the above code to compile, if they were related by
> inheritance, and you use "void foo( integral_c<0> )", instead. For example:
>
> template<int N>
> struct int_c : integral_c<int, N> {};

or
    template <class T, T N>
    struct integral_c
         : select_int_base<T,N>::type
    {};

To let Jaap keep using his convenient int_c arguments

-- 
                       David Abrahams
   dave_at_[hidden] * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

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