Closed xarthurx closed 5 years ago
No, there is no default constructor for the Catmull-Rom class.
This is because the constructor computes the parametrization from the point set geometry. The class is therefore always in a valid state. A default constructor leaves the class in an invalid state.
There's almost always a way around the problem you are encountering, though I do feel your pain!
However, @jzmaddock has vastly more C++ knowledge than myself. John, do you know a clean way to solve this problem of creating a member variable out of a class with no default constructor? IIRC the way to do it is with a pointer member?
(Your code reminds me I should add a unit test for Eigen
vectors to the Catmull-Rom tests.)
A pointer works, for the constructor.
However, if the class is designed to be used this way, a method similar to at()
that works the same as operator()
should be provided, similar to what std::vector
has.
Otherwise, sth like (*ptrToCatMullCrv)(t)
to get the value at t
is really wired.
at()
doesn't work that way: It does bounds checking on an integer index. It would definitely be surprising and non-idiomatic to use it in the way you are suggesting.
Personally, I don't see any problem with (*ptr)(t)
.
OK, I'll use the (*ptr)(t)
for now.
But IMHO, I don't think this issue is solved yet...
When trying to use this
catmull_rom
as a private member of a class, no matter what typePoint
is (sayEigen::Vector2d>
here), there're always an error saidno default constructor exists for class boost::math::catmull_rom<Eigen::Vector2d>"
.This usually will not happen to other constructors.
Would it be possible to provide an empty constructor for the class?