Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Iterate shared_ptr<std::vector<T>>

Let's assume I have the following:

auto vec = std::shared_ptr<std::vector<T>>

And I want to loop through all the vec entities using C++11 Range-Based for Loop.

The following works:

for (auto entity: *vec)

my question is there anyway to do the same without using the * operator?

like image 721
MBZ Avatar asked Dec 09 '22 13:12

MBZ


1 Answers

No. The only sensible way to dereference a pointer is with the dereference operator.

like image 72
Mike Seymour Avatar answered Dec 21 '22 10:12

Mike Seymour