Boost logo

Boost :

From: Martin Bonner (martin.bonner_at_[hidden])
Date: 2005-11-16 06:49:30


----Original Message----
From: Manfred Doudar [mailto:manfred.doudar_at_[hidden]]
Sent: 16 November 2005 11:35
To: boost_at_[hidden]
Subject: Re: [boost] mpl help needed - doing the impossible?

> Manfred Doudar wrote:
>
>>
>> /* Now, how do I get T out when Rank == 1, ... compiler complains
>> about seeing a MyArray/blitz::Array of <T, Rank = 0>
>> (, which is not defined for blitz Arrays)
>> */
>> template <typename T, int Rank>
>> typename boost::mpl::if_
>> < typename boost::mpl::equal_to
>> < boost::mpl::int_<Rank>
>> , boost::mpl::int_<1>
>> >::type
>> , T
>> , blitz::Array<T,
>>
>> boost::mpl::int_<Rank>::prior::value>
>>
>>
>
> ^
> Oops typo, should be:
> MyArray<T,
>
> boost::mpl::int_<Rank>::prior::value>
>
> ... but nonetheless, the problem remains ...
>
>> >::type
>> MyArray<T, Rank> :: operator[] (const int& index) throw(); {
>> // Slicing

How about a helper traits class?

template <typename T, int Rank>
struct SliceType
{
  typedef typename MyArray<T, Rank-1> type;
};

template <typename T>
struct SliceType<T,1>
{
   typedef T type;
};

template <typename T, int Rank>
typename SliceType<T,Rank>::type
   MyArray<T,Rank> :: operator[] (const int& index) throw();

-- 
Martin Bonner
Martin.Bonner_at_[hidden]
Pi Technology, Milton Hall, Ely Road, Milton, Cambridge, CB4 6WZ,
ENGLAND Tel: +44 (0)1223 441434

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