[go: up one dir, main page]

const loophole in DenseBase::swap and Ref(const DenseBase<Derived>&)

Submitted by Christoph Hertzberg @chhtz

Assigned to Nobody

Link to original bugzilla bug (#903)
Version: 3.3 (current stable)

Description

The following should not work:

void test(const Eigen::VectorXd& x) {
Eigen::VectorXd a;
// a.col(0).swap(x); // fails as intended
a.col(0).swap(x, 0); // Manually set sanity check parameter

// Ref<Eigen::VectorXd> rX(x); // fails as intended  
Ref<Eigen::VectorXd> rX(x, &a, 0); // Manually set sanity check parameters  

}

Generally, I'd suggest to avoid adding sanity-check parameters to the public interface. If they are required, it is usually cleaner to hide them into a private function and have a "clean" wrapper function for the interface.

This also avoids the problem of accidentally passing bogus parameters to functions which are not used.

Blocking

#558 (closed)

Edited by Eigen Bugzilla