Solved: 34 - Smart Pointers
This commit is contained in:
@@ -3,18 +3,19 @@
|
||||
namespace cpp11 {
|
||||
|
||||
auto make_counter(int start) -> std::unique_ptr<int> {
|
||||
(void)start;
|
||||
return nullptr;
|
||||
return std::make_unique<int>(start);
|
||||
}
|
||||
|
||||
auto shared_total(const std::vector<std::shared_ptr<int>>& values) -> int {
|
||||
(void)values;
|
||||
return 0;
|
||||
int total = 0;
|
||||
for (const auto& value : values) {
|
||||
total += *value;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
auto clone_unique(const std::unique_ptr<int>& value) -> std::unique_ptr<int> {
|
||||
(void)value;
|
||||
return nullptr;
|
||||
return std::make_unique<int>(*value);
|
||||
}
|
||||
|
||||
} // namespace cpp11
|
||||
|
||||
Reference in New Issue
Block a user