Boost logo

Boost :

Subject: [boost] [smart-ptr][containers] type of the operator[] index
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2011-12-04 11:46:02


Hi,

which is the correct type used as index of operator[]. scoped_array uses
std::ptrdiff_t. Others containers use std::size_t.

The standard uses also std::size_t, but in

13.6 Built-in operators
13 For every cv-qualified or cv-unqualified object type T there exist
candidate operator functions of the form
T* operator+(T*, std::ptrdiff_t);
T& operator[](T*, std::ptrdiff_t);
T* operator-(T*, std::ptrdiff_t);
T* operator+(std::ptrdiff_t, T*);
T& operator[](std::ptrdiff_t, T*);

we see again std::ptrdiff_t.

When using an index to move from a scoped_array to another container
which should be the type if the index?

Best,
Vicente


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