diff gcc/testsuite/g++.old-deja/g++.robertl/eb120.C @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb120.C	Fri Oct 27 22:46:09 2017 +0900
@@ -0,0 +1,23 @@
+// { dg-do run  }
+template<double functionToIntegrate(double)>
+double integrate(double a, double b, int numSamplePoints)
+{
+  //    PRECONDITION(numSamplePoints > 1);
+    double delta = (b-a) / (numSamplePoints-1);
+    double sum = 0.;
+    for (int i=0; i < numSamplePoints; ++i)
+        sum += functionToIntegrate(a + i*delta);
+    return sum * (b-a) / numSamplePoints;
+}
+
+inline double myFunction(double x)
+{
+    return 1 / (1 + x);
+}
+
+// Example use
+int main() {
+double z = integrate<myFunction>(0.0, 1.0, 50);
+	return 0 ;
+}
+