c++ - Crazy unique_ptr syntax -
I was recently using this syntax for an indicator:
Std :: vector & lt; Shader * & Gt; * _shaderArray; The problem is that I started receiving memory leak errors. So now I have decided to use unique singers, so now I do not have to worry about it. But what I have understood in the above syntax in the C ++ 11 syntax is: std :: unique_ptr If this is correct, how do I get started? This code gives me an error:
_shaderArray = new std :: vector & lt; Shader * & gt; (); Start unique_ptr on announcement
std :: unique_ptr & lt; Std :: vector & lt; Std :: unique_ptr & lt; Shading & gt; & Gt; & Gt; _shaderArray {new std :: vector & lt; Std :: unique_ptr & lt; Shader & gt; & Gt; ()}; Full (confluent) minimum example:
#include & lt; Vector & gt; # Include & lt; Memory & gt; Class shader {}; Int main () {std :: unique_ptr & lt; Std :: vector & lt; Std :: unique_ptr & lt; Shader & gt; & Gt; & Gt; _shaderArray {new std :: vector & lt; Std :: unique_ptr & lt; Shader & gt; & Gt; ()}; }
Comments
Post a Comment