This bugzilla service is closed. All entries have been migrated to
Bug 903 - const loophole in DenseBase::swap and Ref(const DenseBase<Derived>&)
Summary: const loophole in DenseBase::swap and Ref(const DenseBase<Derived>&)
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.3 (current stable)
Hardware: All All
: Highest Compilation Problem
Assignee: Nobody
Depends on:
Blocks: 3.3
  Show dependency treegraph
Reported: 2014-11-03 15:35 UTC by Christoph Hertzberg
Modified: 2019-12-04 13:53 UTC (History)
3 users (show)


Description Christoph Hertzberg 2014-11-03 15:35:12 UTC
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.
Comment 1 Gael Guennebaud 2014-11-05 16:19:07 UTC
Changeset:   06d4fff20a93
User:        ggael
Date:        2014-11-05 15:15:17+00:00
Summary:     Big 853: replace enable_if in Ref<> ctor by static assertions and add failtests for Ref<>
Comment 2 Christoph Hertzberg 2014-11-05 16:58:20 UTC
The .swap() case still compiles.
Comment 3 Gael Guennebaud 2014-11-06 09:27:04 UTC
oops, I focused too much on Ref.
Changeset:   167ce78594dc
User:        ggael
Date:        2014-11-06 08:25:26+00:00
Summary:     Bug 903: clean swap API regarding extra enable_if parameters, and add failtests for swap
Comment 4 Nobody 2019-12-04 13:53:10 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance:

Note You need to log in before you can comment on or make changes to this bug.