c++ std unique_ptr code example
Example 1: c++ std::unique
sort( vec.begin(), vec.end() );
vec.erase( unique( vec.begin(), vec.end() ), vec.end() );
Example 2: unique_ptr in c++
#include <iostream>
class Entity {
public:
int b = 0;
Entity() { std::cout << "[CREATED ENTITY]" << std::endl; };
~Entity() { std::cout << "[Destroyed ENTITY]" << std::endl; };
void Print() {};
};
int main()
{
{
std::unique_ptr<Entity> entity = std::make_unique<Entity>();
//std::unique_ptr<Entity> entity1 = entity;//can't copy
entity->Print();
}
}