valarray::operator-=

从valarray的操作数减去元素的指定valarray或元素类型的值,元素,。

valarray<Type>& operator-=(
   const valarray<Type>& _Right
);
valarray<Type>& operator-=(
   const Type& _Right
);

参数

  • _Right
    元素类型的valarray或值与将减去valarray的操作数,元素,从valarray的操作数。

返回值

元素是valarray该操作数的元素差异以及 _Right.的valarray

示例

// valarray_op_esub.cpp
// compile with: /EHsc
#include <valarray>
#include <iostream>

int main( )
{
   using namespace std;
   int i;

   valarray<int> vaL ( 8 ), vaR ( 8 );
   for ( i = 0 ; i < 8 ; i += 2 )
      vaL [ i ] =  10;
   for ( i = 1 ; i < 8 ; i += 2 )
      vaL [ i ] =  0;
   for ( i = 0 ; i < 8 ; i++ )
      vaR [ i ] =  i;
   
   cout << "The initial valarray is: ( ";
      for (i = 0 ; i < 8 ; i++ )
         cout << vaL [ i ] << " ";
   cout << ")." << endl;

   cout << "The initial _Right valarray is: ( ";
      for ( i = 0 ; i < 8 ; i++ )
         cout << vaR [ i ] << " ";
   cout << ")." << endl;

   vaL -= vaR;
   cout << "The element-by-element result of "
        << "the difference is the\n valarray: ( ";
      for ( i = 0 ; i < 8 ; i++ )
         cout << vaL [ i ] << " ";
   cout << ")." << endl;
}
  
  
  

要求

标头: <valarray>

命名空间: std

请参见

参考

valarray Class