1 #ifndef SCX_STL_UTILS_HPP
2 #define SCX_STL_UTILS_HPP
9 #define SCX_FNOBJ(id, args, list, init, opts) \
13 FnObj##id()list { init; } \
14 ~FnObj##id() { cout << "!"; } \
16 template<typename T> \
17 void operator()(T& val) { opts; } \
21 static inline typename
C::value_type
LinearSum(const C
& container
, size_t begin
, size_t end
) {
22 typename
C::value_type sum
= 0;
23 for (size_t i
= 0; i
< end
; ++i
) {
30 static inline typename
C::value_type
LinearSum(const C
& container
, size_t begin
) {
31 return LinearSum(container
, begin
, container
.size());
35 static inline typename
C::value_type
LinearSum(const C
& container
) {
36 return LinearSum(container
, 0, container
.size());
40 static inline C
LinearSum(const C array
[], size_t begin
, size_t end
) {
42 for (size_t i
= 0; i
< end
; ++i
) {
49 static inline C
LinearSum(C array
[], size_t begin
) {
50 return LinearSum(array
, begin
, sizeof((C
[])array
)/sizeof(C
));