diff --git a/examples/bounding_box.cu b/examples/bounding_box.cu index cca71a45e..abc52036c 100644 --- a/examples/bounding_box.cu +++ b/examples/bounding_box.cu @@ -50,7 +50,7 @@ struct bbox }; // reduce a pair of bounding boxes (a,b) to a bounding box containing a and b -struct bbox_reduction : public thrust::binary_function +struct bbox_union : public thrust::binary_function { __host__ __device__ bbox operator()(bbox a, bbox b) @@ -75,21 +75,17 @@ int main(void) thrust::device_vector points(N); // generate some random points in the unit square - for(size_t i = 0; i < N; i++) - { - float x = u01(rng); - float y = u01(rng); - points[i] = point2d(x,y); - } + std::generate(points.begin(), points.end(), [&] { + auto x = u01(rng); + auto y = u01(rng); + return point2d(x, y); + }); // initial bounding box contains first point - bbox init = bbox(points[0], points[0]); - - // binary reduction operation - bbox_reduction binary_op; + bbox first_point = bbox(points[0], points[0]); // compute the bounding box for the point set - bbox result = thrust::reduce(points.begin(), points.end(), init, binary_op); + bbox result = thrust::reduce(points.begin(), points.end(), first_point, bbox_union()); // print output std::cout << "bounding box " << std::fixed;