GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::valarray::sum(3) C++ Standard Libary std::valarray::sum(3)

std::valarray::sum - std::valarray::sum


T sum() const;


Computes the sum of the elements.


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.


(none)


The sum of the elements.

// Run this code


#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';
}


55


apply applies a function to every element of a valarray
(public member function)
accumulate sums up a range of elements
(function template)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.