AFF --- A container for numbers (array) by Friederich and Forbriger.
sum.h
Go to the documentation of this file.
1
35
// include guard
36
#ifndef AFF_SUM_H_VERSION
37
38
#define AFF_SUM_H_VERSION \
39
"AFF_SUM_H V1.0 "
40
41
42
#include<
aff/lib/collector.h
>
43
44
namespace
aff
{
45
46
namespace
func {
47
48
namespace
util {
49
57
template
<
class
C>
58
class
Extractsum
{
59
typedef
typename
C::Tcoc
Tcont
;
60
typedef
typename
C::Tvalue
Tvalue
;
61
public
:
62
typedef
Tvalue
Tretval
;
64
Extractsum
(
const
Tcont
& c):
Msum
(0),
Mn
(0) { }
66
void
operator()
(
const
Tvalue
& v) {
Msum
+=v; ++
Mn
; }
68
Tretval
result
()
const
{
return
(
Msum
); }
69
private
:
70
Tvalue
Msum
;
71
int
Mn
;
72
};
// class Extractsum
73
74
}
// namespace util
75
76
/*----------------------------------------------------------------------*/
77
88
template
<
class
C>
89
typename
C::Tvalue
sum
(
const
C& c)
90
{
91
return
(aff::func::util::collect<C, aff::func::util::Extractsum>(c));
92
}
// sum()
93
94
}
// namespace func
95
96
}
// namespace aff
97
98
#endif // AFF_SUM_H_VERSION (includeguard)
99
100
/* ----- END OF sum.h ----- */
aff
Root namespace of library.
Definition:
array.h:148
aff::func::util::Extractsum::operator()
void operator()(const Tvalue &v)
collect another value
Definition:
sum.h:66
collector.h
collect values (prototypes)
aff::func::util::Extractsum::Tcont
C::Tcoc Tcont
Definition:
sum.h:59
aff::func::sum
C::Tvalue sum(const C &c)
Definition:
sum.h:89
aff::func::util::Extractsum
Definition:
sum.h:58
aff::func::util::Extractsum::Tvalue
C::Tvalue Tvalue
Definition:
sum.h:60
aff::func::util::Extractsum::Tretval
Tvalue Tretval
Definition:
sum.h:62
aff::func::util::Extractsum::Msum
Tvalue Msum
Definition:
sum.h:70
aff::func::util::Extractsum::result
Tretval result() const
return result of operation
Definition:
sum.h:68
aff::func::util::Extractsum::Extractsum
Extractsum(const Tcont &c)
initialize member data
Definition:
sum.h:64
aff::func::util::Extractsum::Mn
int Mn
Definition:
sum.h:71
functions
sum.h
Generated on Mon Aug 21 2023 17:36:08 for AFF --- A container for numbers (array) by Friederich and Forbriger. by
1.8.14