Skip to content

Commit

Permalink
Modernize placement-new custom constructors
Browse files Browse the repository at this point in the history
There were three
  • Loading branch information
r-owen committed Jul 18, 2018
1 parent 508d1e9 commit 7be1f88
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions python/lsst/sphgeom/angle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ PYBIND11_MODULE(angle, mod) {
// Construct an Angle from a NormalizedAngle, enabling implicit
// conversion from NormalizedAngle to Angle in python via
// py::implicitly_convertible
cls.def("__init__",
[](Angle &self, NormalizedAngle &a) {
new (&self) Angle(a.asRadians());
},
cls.def(py::init(
[](NormalizedAngle &a) {
return new Angle(a.asRadians());
}),
"normalizedAngle"_a);

cls.def("__eq__", &Angle::operator==, py::is_operator());
Expand Down
8 changes: 4 additions & 4 deletions python/lsst/sphgeom/rangeSet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ PYBIND11_MODULE(rangeSet, mod) {
cls.def(py::init<uint64_t>(), "integer"_a);
cls.def(py::init<uint64_t, uint64_t>(), "first"_a, "last"_a);
cls.def(py::init<RangeSet const &>(), "rangeSet"_a);
cls.def("__init__",
[](RangeSet &self, py::iterable iterable) {
new (&self) RangeSet(makeRangeSet(iterable));
},
cls.def(py::init(
[](py::iterable iterable) {
return new RangeSet(makeRangeSet(iterable));
}),
"iterable"_a);

cls.def("__eq__", &RangeSet::operator==, py::is_operator());
Expand Down
6 changes: 3 additions & 3 deletions python/lsst/sphgeom/vector3d.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ PYBIND11_MODULE(vector3d, mod) {
// Construct a Vector3d from a UnitVector3d, enabling implicit
// conversion from UnitVector3d to Vector3d in python via
// py::implicitly_convertible
cls.def("__init__", [](Vector3d &self, UnitVector3d const &u) {
new (&self) Vector3d(u.x(), u.y(), u.z());
});
cls.def(py::init([](Vector3d &self, UnitVector3d const &u) {
return new Vector3d(u.x(), u.y(), u.z());
}));

cls.def("__eq__", &Vector3d::operator==, py::is_operator());
cls.def("__ne__", &Vector3d::operator!=, py::is_operator());
Expand Down

0 comments on commit 7be1f88

Please sign in to comment.