◐ Shell
clean mode source ↗

std::valarray::sum — cppreference.com

De cppreference.com

<metanoindex/>

<tbody> </tbody>

Calcule la somme des éléments .

Original:

Computes the sum of the elements.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

La fonction peut être utilisée uniquement si operator+= est défini pour T type. Si le std::valarray est vide, le comportement est indéfini. L'ordre dans lequel les éléments sont traités par cette fonction n'est pas spécifié .

Original:

The function can be used only if operator+= is defined for type T. If the std::valarray is empty, the behavior is undefined. The order in which the elements are processed by this function is unspecified.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Paramètres

(Aucun)

Original:

(none)

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Retourne la valeur

La somme des éléments .

Original:

The sum of the elements.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Exemple

#include <iostream>
#include <valarray>

int main()
{
    std::valarray<int> a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    std::cout << a.sum() << '\n';
}

Résultat :

Voir aussi

applies a function to every element of a valarray
(fonction membre publique) [edit]

résume un ensemble d'éléments

Original:

sums up a range of elements

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(fonction générique) [edit]