## ◆ unary_plus()

 Value boost::simd::unary_plus ( Value const & x )

This function object returns the elementwise unary plus of the parameter.

Infix notation can be used with operator '+'

Note:
• r = unary_plus(x) is equivalent to r = +x for SIMD types.
Warning
Take care that the infix notation in scalar integral mode encurs a possible promotion of the type as C++ rules state.
plus, unary_minus
Example:
#include <boost/simd/arithmetic.hpp>
#include <boost/simd/pack.hpp>
#include <iostream>
namespace bs = boost::simd;
using pack_ft = bs::pack <float, 4>;
using pack_it = bs::pack <std::int16_t,4>;
int main()
{
pack_ft pf = {-1.0f, 2.0f, -3.0f, -32768.0f};
pack_it pi = {-1, 2, -3, -32768 };
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> bs::unary_plus(pf) = " << bs::unary_plus(pf) << '\n'
<< "<- pi = " << pi << '\n'
<< "-> bs::unary_plus(pi) = " << bs::unary_plus(pi) << '\n'
<< "-> +pi = " << +pi << '\n';
float xf = -32768.0f;
std::int16_t xi = -32768;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::unary_plus(xf) = " << bs::unary_plus(xf) << '\n'
<< "<- xi = " << xi << '\n'
<< "-> bs::unary_plus(xi) = " << bs::unary_plus(xi) << '\n'
<< "-> +xi = " << +xi << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (-1, 2, -3, -32768)
-> bs::unary_plus(pf) = (-1, 2, -3, -32768)
<- pi = (-1, 2, -3, -32768)
-> bs::unary_plus(pi) = (-1, 2, -3, -32768)
-> +pi = (-1, 2, -3, -32768)
---- scalar
<- xf = -32768
-> bs::unary_plus(xf) = -32768
<- xi = -32768
-> bs::unary_plus(xi) = -32768
-> +xi = -32768