Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.robertl/eb59.C

raw
1 // { dg-do run }
2 // { dg-skip-if "requires hosted libstdc++ for vector" { ! hostedlib } }
3 #define INC_FUNCTIONAL 1
4 #define USE_STATIC_CAST 1
5
6 #include <vector>
7 #include <numeric>
8 #ifdef INC_FUNCTIONAL
9 #include <functional>
10 #endif
11
12 using namespace std;
13
14 template<class R> int p( int val, R& r )
15 {
16 return val + r;
17 }
18
19 template<class R> void f( vector<R>& v )
20 {
21 #ifdef USE_STATIC_CAST
22 accumulate( v.begin(), v.end(), 0, static_cast<int (*)(int, R&)>(p) );
23 #else
24 accumulate( v.begin(), v.end(), 0, p<R> );
25 #endif
26 }
27
28 int main()
29 {
30 vector<int> r;
31 f( r );
32 }