Boost logo

Boost :

Subject: [boost] shared_ptr<>: why no operator[] ?
From: dgwsoft (gareth_at_[hidden])
Date: 2011-07-26 18:39:37

boost::shared_ptr<int> p(new int(42));

To access elements of the array I can do:

p.get()[10] = 7;

But wouldn't it be nicer to do:

p[10] = 7; // ?

So: why is no T& operator[](int) defined for shared_ptr ? I'm just
interested in the design reasons for this.



View this message in context:
Sent from the Boost - Dev mailing list archive at

Boost list run by bdawes at, gregod at, cpdaniel at, john at