#include <iostream>
#include <vector>
#include <typeinfo>
#include <memory>
#include <boost/iterator/indirect_iterator.hpp>
using namespace std;
struct HeavyResource{};
class Owner
{
private:
vector<unique_ptr<HeavyResource>> _vectorOfHeavyResources;
public:
using ResourceIterator =
boost::indirect_iterator<std::vector<std::unique_ptr<HeavyResource>>::iterator,
const HeavyResource>;
ResourceIterator begin() { return std::begin(_vectorOfHeavyResources); }
ResourceIterator end() { return std::end(_vectorOfHeavyResources); }
Owner() : _vectorOfHeavyResources(5)
{}
};
int main() {
Owner o;
for (const auto& b : o)
{
cout << typeid(b).name() << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8dHlwZWluZm8+CiNpbmNsdWRlIDxtZW1vcnk+CiNpbmNsdWRlIDxib29zdC9pdGVyYXRvci9pbmRpcmVjdF9pdGVyYXRvci5ocHA+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpzdHJ1Y3QgSGVhdnlSZXNvdXJjZXt9OwpjbGFzcyBPd25lcgp7CnByaXZhdGU6CiAgICB2ZWN0b3I8dW5pcXVlX3B0cjxIZWF2eVJlc291cmNlPj4gX3ZlY3Rvck9mSGVhdnlSZXNvdXJjZXM7CnB1YmxpYzoKICAgIHVzaW5nIFJlc291cmNlSXRlcmF0b3IgPQogICAgIGJvb3N0OjppbmRpcmVjdF9pdGVyYXRvcjxzdGQ6OnZlY3RvcjxzdGQ6OnVuaXF1ZV9wdHI8SGVhdnlSZXNvdXJjZT4+OjppdGVyYXRvciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgSGVhdnlSZXNvdXJjZT47CiAgICBSZXNvdXJjZUl0ZXJhdG9yIGJlZ2luKCkgeyByZXR1cm4gc3RkOjpiZWdpbihfdmVjdG9yT2ZIZWF2eVJlc291cmNlcyk7IH0KICAgIFJlc291cmNlSXRlcmF0b3IgZW5kKCkgeyByZXR1cm4gc3RkOjplbmQoX3ZlY3Rvck9mSGVhdnlSZXNvdXJjZXMpOyB9CiAgICBPd25lcigpIDogX3ZlY3Rvck9mSGVhdnlSZXNvdXJjZXMoNSkKICAgIHt9Cn07CgoKaW50IG1haW4oKSB7CglPd25lciBvOwoJZm9yIChjb25zdCBhdXRvJiBiIDogbykKCXsKCQljb3V0IDw8IHR5cGVpZChiKS5uYW1lKCkgPDwgZW5kbDsKCX0KCXJldHVybiAwOwp9