This bugzilla service is closed. All entries have been migrated to
Bug 1074 - Forbid the creation of PlainObjectBase object
Summary: Forbid the creation of PlainObjectBase object
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.3 (current stable)
Hardware: All All
: Normal API Change
Assignee: Nobody
Depends on:
Blocks: 3.3
  Show dependency treegraph
Reported: 2015-09-28 14:00 UTC by Gael Guennebaud
Modified: 2019-12-04 14:58 UTC (History)
4 users (show)


Description Gael Guennebaud 2015-09-28 14:00:31 UTC
It is currently possible to directly create PlainObjectBase<Derived> objects, which is not very good practice as this class has been thought as an abstract base class.

So what about disabling this possibility by making all PlainObjectBase<Derived> private, and making Derived a friend class of PlainObjectBase<Derived>?

See also the following thread for some weird usages of PlainObjectBase<Derived>:
Comment 1 Christoph Hertzberg 2015-09-28 14:54:47 UTC
I also see no legit use of directly creating a PlainObjectBase<> (nor any other ...Base<>-object -- which in many cases would be an empty object, which behaves as if it contained data).
To implement this, wouldn't it be sufficient to make all constructors (and destructors, if needed) protected? Of course, this would leave the possibility to inherit 

  class WeirdClass : PlainObjectBase<SomeOtherClass> { ... };

but we can't avoid every possibility to shoot oneself in the foot ...
Comment 2 Gael Guennebaud 2015-09-28 15:04:43 UTC
yes, making them protected is definitely enough!
Comment 3 Nathan 2015-10-04 17:23:46 UTC
What about making the destructor of PlainObjectBase<typename> a pure virtual function? This would need only two additional lines of code and no changes to any of the derived classes.
Comment 4 Christoph Hertzberg 2015-12-08 17:40:26 UTC
We use pure static polymorphism in Eigen (no virtual functions).
A pure virtual destructor is actually rather complicated (I was surprised that it is even possible ...)
Comment 5 Gael Guennebaud 2015-12-09 20:37:32 UTC
Comment 6 Nobody 2019-12-04 14:58:29 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.