Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created May 3, 2024 11:11
Show Gist options
  • Save velotiotech/ffeaa3cad6ef3ff4c1cd4aeab63a9c74 to your computer and use it in GitHub Desktop.
Save velotiotech/ffeaa3cad6ef3ff4c1cd4aeab63a9c74 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
int main() {
std::vector<std::unique_ptr<int>> numbers;
std::unique_ptr<int> ptr1(new int(20));
std::unique_ptr<int> ptr2(new int(10));
numbers.push_back(ptr1);
numbers.push_back(ptr2);
for (const auto& ptr : numbers)
std::cout << *ptr << " ";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment