-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccumulate.cpp
More file actions
37 lines (28 loc) · 802 Bytes
/
accumulate.cpp
File metadata and controls
37 lines (28 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
* \file accumulate.cpp
* \brief
*
* \todo
*/
#include <StdStream/StdStream.h>
#include <StdTest/StdTest.h>
#include <Stl.h>
//-------------------------------------------------------------------------------------------------
int main(int, char **)
{
std::list<std::string> amounts;
amounts.push_back("0.1");
amounts.push_back("0.2");
amounts.push_back("0.3");
std::string sRv = std::accumulate(amounts.begin(), amounts.end(), std::string("0.0"),
[&](const std::string &a_it_1, const std::string &a_it_2)
{
return std::to_string(std::stod(a_it_1) + std::stod(a_it_2));
});
std::cout << STD_TRACE_VAR(sRv) << std::endl;
return 0;
}
//-------------------------------------------------------------------------------------------------
#if OUTPUT
sRv: 0.600000
#endif