I usually pass a vector containing raw pointers, such as:
someFunc(const std::vector<MyClass*>& classList){..}
I wonder if you can do the same with unique_ptr as follows:
someFunc(const std::vector<std::unique_ptr<MyClass>>& classList){..}
? Does this mean the same thing ?, i.e. read-only.
Yes, you can. No, this does not mean the same thing: it std::unique_ptrrepresents a resource belonging to a pointer. A common raw pointer can have many other semantics.
std::unique_ptr
, operator[] std::unique_ptr s. const std::unique_ptr<T> , T, , .
operator[]
const std::unique_ptr<T>
T
Source: https://habr.com/ru/post/1619596/More articles:Reduce the image from 24-bit rgb to 8-bit rgb, but the result will not be as beautiful as tinypng.com - phpHow to specify load status for an asynchronous action during the first render using the shortcut - reactjsGoogleMobileAds.framework: package format unrecognized, invalid or inappropriate - xcode7Problems interacting with Wep pages using Selenium in Java - javaHow to track LLVM verifyFunction error "Expected Without Forward Ads!"? - c ++Corresponding "/" character in string - pythonHow to select a list of rows by name in a Pandas dataframe? - pythonUnderstanding Crash Report (Partial Application ...) in Swift - closuresthis.state does not match the state in this object - javascriptChanging values ββin javascript - javascriptAll Articles