How to safely and efficiently manage pointers and objects in this system? Beginner Pointer/Vector problem

My Goal

I am using an OpenCL Wrapper for GPU processing in C++. This library creates memory objects as:

Memory<float>(gpuDevice, sizeOfMemoryObject)

I need to create several lists of these each within a vector<Memory<float>>. It is not important to me whether anything is an object or pointer as long as it is smart, safe, and works. At no point am I intending or wanting to copy the actual objects around.

In simple terms, if it wasn’t for pointers issues (pseudo-code of C++/C#), what I would want to do (in the best words I can express it):

private:

//define the main objects/pointers I will access throughout my code 

std::vector<Memory<float>> memoryVecA;  
std::vector<Memory<float>> memoryVecB;  
std::vector<Memory<float>> memoryVecC;  
... //more, D, E, F, etc.

On initialization, I want to first add these to a temp parent vector. This is to allow iteration through them to initialize them and their contents:

//temporary list to iterate through just for construction
std::vector<std::vector<Memory<float>> tempMemoryVec; 

//add the main objects to it
tempMemoryVec.emplace_back(memoryVecA);
tempMemoryVec.emplace_back(memoryVecB);
tempMemoryVec.emplace_back(memoryVecC);

Then right after that, I want to iterate through this temp list to fill it all in:

int numMemoriesPerVector = 10; // number of Memory<float>'s to add to each memoryVec
int numSamplesPerMemory = 100; // construction parameter for size of each Memory<float> 

for (int i=0; i < tempMemoryVec.size(); i++){

    //fill in memoryVecA/B/C by accessing them from the tempMemoryVec
    for (int j=0; j < numMemoriesPerVector; j++){

        //create the memory objects and add them to memoryVecA/B/C 
        Memory<float> newMemory = Memory<float>(gpuDevice, numSamplesPerMemory);
        tempMemoryVec[i].emplace_back(newMemory); //add Memory<float> to vector<Memory<float>>

        //set all memory values to zero
        for (int k=0; k < numSamplesPerMemory; k++){
            newMemory[k] = 0;
        }
        //copy data to GPU inside Memory<float> object (internal function of it)
        newMemory.write_to_device(); 

    }

}
tempMemoryList.clear(); //no longer need this - was just temporary list to make initialization easier

At the end, I need want my Vector<Memory<float>> memoryVecA etc. (pointers or objects) where each Vector has 10 Memory<float> entries, each of which is then filled with 100 zeros.

I then must access these Vectors and their contained Memory<float> objects easily and routinely from there.

My Failed Attempts

I have spent hours today trying to make this work. I have tried all sorts of pointers, passing things in by reference, make_shared, etc. but it is just getting so complicated with all the nested brackets and asterixes etc. I don’t have the knowledge of how it is working and what I am doing.

I am not sure when I am copying an object or just the pointer, etc. I keep just getting errors and I can’t spend another 2-3 days just failing on something trivial like this. The Memory objects are expensive so I can’t be copying them around unnecessarily and it will break function.

Is there anyone who would be very kind as to help me write some version of what I am trying to do above in a way that doesn’t become overly complicated but allows creation and initialization of the vector<Memory<float>> objects I want (and/or some variant of pointers/objects for these?)

I often want to do something like this but then I struggle. C++ pointers and references have always been difficult for me. I’d appreciate some help. This is a common situation for me, so it would be good to learn from.

Thanks for any help.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật