Monday, 15 August 2011

c++11 - Does using unique_ptr mean that I don't have to use the restrict keyword? -


When auto-vectories try to get loops, I've written the written code like this:

 {Code> zero addFP (int n, float * in 1, float * in 2, float * restricted) {for (i = 0; i & lt; n; i ++) {outside [i] = in1 [I] + in2 [i]; }}  

Where restricted keywords are needed, convincing the compiler about pointers aliens so that it can vector the loop.

Do something like this? (For (i = 0; i & lt; n; i ++) {out [F [FAP] (ANFA, float * i1, float * in 2, std :: UNIPT & lt; float & gt; ] = 1 (i) +2 [i];}}

If this works, which is a more portable option?

tl; dr what std: : Unique_ptr can be used to replace restricted keywords in a loop, are you trying to auto-vector?

, instead it is part of C99.

std :: unique_ptr> L & gt; Foo; your compile Saying to me: I only need memory in this area, once the scope ends, release the memory.

Restrict tells your compiler I know that you can not know or prove it, but I swear by pink that it is only in the context of memory being performed in this ceremony.

< P> unique_ptr does not close the aliases, nor Npailr believe that they do not exist:

  int * pointer = new Int [3]; Int * alias = pointer; Std :: unique_ptr & lt; Integer & gt; Alias2 (pointer); Std :: unique_ptr & lt; Integer & gt; Alias3 (indicator); // compiles, but when crashes when deleting  

, then your first version is not valid in C ++ 11 (though it works on many modern compilers) and not the other optimization Expect the behaviors that are still included.


No comments:

Post a Comment