Skip to content
Snippets Groups Projects
Commit d8ec10b4 authored by Martin Nolte's avatar Martin Nolte
Browse files

[bugfix] Prohibit copy constructor of DenseVector

DenseVector is the base class of a CRTP. This is kind of an abstract
class that works only if it can be casted into a derived type. Copying
the base class is pointless.

This patch marks the copy constructor of DenseVector private (not even
implementing it), so that it cannot be called anymore. Once we have a
DUNE_DELETE macro, we should use it, here.

At the same time, the default constructor is marked protected, so that only
derived classes can instantiate a DenseVector. Notice that this does not
prevent the user from building a derivced class which does not pass
itself as implementation to DenseVector. It is (to my knowledge) not possible
to make CRTPs completely fail-safe.
parent fd4572dd
No related branches found
No related tags found
No related merge requests found
......@@ -228,6 +228,13 @@ namespace Dune {
V & asImp() { return static_cast<V&>(*this); }
const V & asImp() const { return static_cast<const V&>(*this); }
// prohibit copying
DenseVector ( const DenseVector & );
protected:
// construction allowed to derived classes only
DenseVector () {}
public:
//===== type definitions and constants
......
......@@ -240,6 +240,11 @@ namespace Dune {
_data = x[0];
}
//! copy constructor
FieldVector ( const FieldVector &other )
: _data( other._data )
{}
//! Assignment operator for scalar
inline FieldVector& operator= (const K& k)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment