mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-08-29 20:21:50 +02:00
Make the code example c++20
compliant (#8177)
This commit is contained in:
@@ -20,7 +20,7 @@ public:
|
|||||||
// Make a copy only if we want to modify the data.
|
// Make a copy only if we want to modify the data.
|
||||||
void write(const std::string &str) {
|
void write(const std::string &str) {
|
||||||
// Check if there's more than one reference.
|
// Check if there's more than one reference.
|
||||||
if(!data.unique()) {
|
if(data.use_count() > 1) {
|
||||||
data = std::make_shared<std::string>(*data);
|
data = std::make_shared<std::string>(*data);
|
||||||
std::cout << "Copy is actually made for writing." << std::endl;
|
std::cout << "Copy is actually made for writing." << std::endl;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user