Commit 88447b6c authored by Dmitry Yu. Naumov's avatar Dmitry Yu. Naumov
Browse files

[T/GL] Replace std::bind with lambdas.

By Jason Turner in his "C++ Best Practices":
std::bind is almost always way more overhead
(both compile time and runtime) than you need.
Instead simply use a lambda.
parent ff64d3aa
......@@ -31,22 +31,22 @@ public:
PointGenerator point_generator1 = PointGenerator(
MathLib::Point3d(std::array<double, 3>{{0.0, 0.0, 0.0}}), 1.0);
SymmSegmentGenerator segment_generator1 = SymmSegmentGenerator{point_generator1,
std::bind(ac::reflect, point_generator1.center, std::placeholders::_1)};
[&](auto p){ return ac::reflect(point_generator1.center, p); }};
PointGenerator point_generator2 = PointGenerator(
MathLib::Point3d(std::array<double, 3>{{2.0, 0.0, 0.0}}), 1.0);
SymmSegmentGenerator segment_generator2 = SymmSegmentGenerator{point_generator2,
std::bind(ac::reflect, point_generator2.center, std::placeholders::_1)};
[&](auto p){ return ac::reflect(point_generator2.center, p); }};
Eigen::Vector3d const translation_vector1 = {2, 2, 0};
PairSegmentGenerator pair_segment_generator1 = PairSegmentGenerator{
segment_generator1,
std::bind(ac::translate, translation_vector1, std::placeholders::_1)};
[&](auto p) { return ac::translate(translation_vector1, p); }};
Eigen::Vector3d const translation_vector2 = {0, 0, 0};
PairSegmentGenerator pair_segment_generator2 = PairSegmentGenerator{
segment_generator1,
std::bind(ac::translate, translation_vector2, std::placeholders::_1)};
[&](auto p) { return ac::translate(translation_vector2, p); }};
ac::gtest_reporter gtest_reporter;
};
......
......@@ -24,8 +24,9 @@ public:
PointGenerator point_generator = PointGenerator(
MathLib::Point3d(std::array<double, 3>{{0.0, 0.0, 0.0}}), 1.0);
SymmSegmentGenerator segment_generator = SymmSegmentGenerator{point_generator,
std::bind(ac::reflect, point_generator.center, std::placeholders::_1)};
SymmSegmentGenerator segment_generator = SymmSegmentGenerator{
point_generator,
[&](auto p) { return ac::reflect(point_generator.center, p); }};
ac::gtest_reporter gtest_reporter;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment