Commit 59c5ac10 authored by Jakob Schneck's avatar Jakob Schneck Committed by Martin Nolte

Explicit implementation of geometry grid views copy constructor and copy...

Explicit implementation of geometry grid views copy constructor and copy assignment operator, since default versions were not sufficient.
parent 802dcf44
Pipeline #6199 passed with stage
in 50 minutes and 30 seconds
......@@ -390,7 +390,7 @@ namespace Dune
const LeafIndexSet &leafIndexSet () const
{
if( !leafIndexSet_ )
leafIndexSet_ = LeafIndexSet( hostGrid().leafIndexSet() );
leafIndexSet_.reset( hostGrid().leafIndexSet() );
assert( leafIndexSet_ );
return leafIndexSet_;
}
......
......@@ -112,10 +112,35 @@ namespace Dune
static const bool conforming = Traits::conforming;
GridView ( const Grid &grid, const HostGridView &hostGridView )
: grid_( &grid ),
hostGridView_( hostGridView )
: grid_( &grid ), hostGridView_( hostGridView )
{}
GridView ( const This &other )
: grid_( other.grid_ ), hostGridView_( other.hostGridView_ )
{}
GridView ( This &&other )
: grid_( other.grid_ ), hostGridView_( std::move( other.hostGridView_ ) )
{}
This &operator= ( const This &other )
{
grid_ = other.grid_;
hostGridView_ = other.hostGridView_;
if( indexSet_ )
indexSet_.reset( hostGridView().indexSet() );
return *this;
}
This &operator= ( This &&other )
{
grid_ = other.grid_;
hostGridView_ = std::move( other.hostGridView_ );
if( indexSet_ )
indexSet_.reset( hostGridView().indexSet() );
return *this;
}
const Grid &grid () const
{
assert( grid_ );
......@@ -124,8 +149,7 @@ namespace Dune
const IndexSet &indexSet () const
{
if( !indexSet_ )
indexSet_ = IndexSet( hostGridView().indexSet() );
indexSet_.reset( hostGridView().indexSet() );
return indexSet_;
}
......
......@@ -39,23 +39,18 @@ namespace Dune
typedef typename Base::Types Types;
IndexSet ()
: hostIndexSet_( 0 )
{}
IndexSet () = default;
explicit IndexSet ( const HostIndexSet &hostIndexSet )
: hostIndexSet_( &hostIndexSet )
{}
IndexSet ( const This &other )
: hostIndexSet_( other.hostIndexSet_ )
{}
// The index set contains a pointer to the host index set, so copying or assigning this can be dangerous.
IndexSet ( const This & ) = delete;
IndexSet ( This && ) = delete;
const This &operator= ( const This &other )
{
hostIndexSet_ = other.hostIndexSet_;
return *this;
}
IndexSet &operator= ( const This & ) = delete;
IndexSet &operator= ( This && ) = delete;
using Base::index;
using Base::subIndex;
......@@ -97,6 +92,9 @@ namespace Dune
explicit operator bool () const { return bool( hostIndexSet_ ); }
void reset () { hostIndexSet_ = nullptr; }
void reset ( const HostIndexSet &hostIndexSet ) { hostIndexSet_ = &hostIndexSet; }
private:
const HostIndexSet &hostIndexSet () const
{
......@@ -104,7 +102,7 @@ namespace Dune
return *hostIndexSet_;
}
const HostIndexSet *hostIndexSet_;
const HostIndexSet *hostIndexSet_ = nullptr;
};
} // namespace GeoGrid
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment