Boost logo

Boost :

Subject: Re: [boost] [smart-ptr][containers] type of the operator[] index
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2011-12-04 17:55:46


On Sun, Dec 4, 2011 at 2:40 PM, Vicente J. Botet Escriba <
vicente.botet_at_[hidden]> wrote:

> Le 04/12/11 23:37, Vicente J. Botet Escriba a écrit :
>
>> Le 04/12/11 19:25, Peter Dimov a écrit :
>>
>>> Vicente J. Botet Escriba wrote:
>>>
>>>> So which will be the type used to to move from a scoped_array to
>>>> another container?
>>>>
>>>
>>> I have no idea what you mean, sorry.
>>>
>>>
>>> No problem. I'm analyzing this ticket https://svn.boost.org/trac/**
>> boost/ticket/5040 <https://svn.boost.org/trac/boost/ticket/5040>future.hpp in boost::thread does not compile with /clr
>>
>> With some missing declarations
>
>> The concerned code is
>>
>> typedef std::vector<registered_waiter>**::size_type
>> count_type;
>> count_type count;
>> boost::scoped_array<boost::**unique_lock<boost::mutex> >
>> locks;
>> std::vector<registered_waiter> futures;
>> // ...
>> for(count_type i=0;i<count;++i)
>> {
>> locks[i]=boost::unique_lock<**boost::mutex>(futures[i].**
>> future->mutex);
>> }
>>
>> The question is how count_type must be defined so that we don't have
>> portable issues.
>>
>
I would do the narrower of the make_unsigned versions of the respective
index types. In this case, I'd guess that would be std::size_t? And,
maybe, cast it to std::ptrdiff_t when indexing into locks?

- Jeff


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