[C++-sig] Re: vector_indexing_suite override question
Neal D. Becker
ndbecker2 at verizon.net
Fri Apr 16 13:56:14 CEST 2004
Joel de Guzman wrote:
> Neal D. Becker wrote:
>
>> I'm trying to wrap my new Ring class, which is a vector-like class. I
>> was hoping to use vector_indexing_suite but override one operator.
>>
>> template<class Container>
>> struct my_indexing_suite : public vector_indexing_suite<Container> {
>> typedef typename vector_indexing_suite<Container>::index_type
>> index_type;
>>
>> static index_type
>> convert_index(Container& container, PyObject* i_) {
>> throw ("help");
>> }
>> };
>
> Hi Neal,
>
> Try informing vector_indexing_suite about your class:
>
> struct my_indexing_suite :
> vector_indexing_suite<Container, false, my_indexing_suite>
>
Thanks! That did the trick. I would have never guessed this. The use of
CRTP here is beyond my understanding.
I suggest adding an example to the documentation.
Thanks again.
More information about the Cplusplus-sig
mailing list