diff --git a/dune/subgrid/subgrid.hh b/dune/subgrid/subgrid.hh
index ee2ecf24cdb9c46f7f93a5f7842e2076da1640a0..99bdb45d6a4e6ce56e3331ab4cb8ba1e766a7650 100644
--- a/dune/subgrid/subgrid.hh
+++ b/dune/subgrid/subgrid.hh
@@ -12,7 +12,13 @@
 #include <vector>
 #include <type_traits>
 
+#include <dune/common/version.hh>
+#if DUNE_VERSION_LT(DUNE_COMMON,2,7)
 #include <dune/common/parallel/collectivecommunication.hh>
+#else
+#include <dune/common/parallel/communication.hh>
+#endif
+
 #include <dune/grid/common/backuprestore.hh>
 #include <dune/grid/common/capabilities.hh>
 #include <dune/grid/common/grid.hh>
diff --git a/dune/subgrid/subgrid/subgridgeometry.hh b/dune/subgrid/subgrid/subgridgeometry.hh
index c8ff55b65204410574f12b9a5c6c8c610f96f76d..423001afd7865960d3abab55ba63b7292b264f2b 100644
--- a/dune/subgrid/subgrid/subgridgeometry.hh
+++ b/dune/subgrid/subgrid/subgridgeometry.hh
@@ -5,7 +5,13 @@
 * \brief The SubGridGeometry class and its specializations
 */
 #include <type_traits>
+
+#include <dune/common/version.hh>
+#if DUNE_VERSION_LT(DUNE_COMMON,2,8)
 #include <dune/common/std/variant.hh>
+#else
+#include <variant>
+#endif
 
 #include <dune/common/fmatrix.hh>
 #include <dune/common/typetraits.hh>
@@ -147,7 +153,11 @@ class SubGridLocalGeometry
         using MultiLinGeometry = MultiLinearGeometry<ctype, mydim, coorddim>;
 
         // use a variant to store either a HostGridLocalGeometry or a MultiLinearGeometry
+#if DUNE_VERSION_LT(DUNE_COMMON,2,8)
         using GeometryContainer = Std::variant<HostGridLocalGeometry, MultiLinGeometry>;
+#else
+        using GeometryContainer = std::variant<HostGridLocalGeometry, MultiLinGeometry>;
+#endif
 
     public:
 
@@ -177,45 +187,77 @@ class SubGridLocalGeometry
         /** \brief Return the element type identifier
         */
         GeometryType type () const {
+#if DUNE_VERSION_LT(DUNE_COMMON,2,8)
             return Std::visit([&](auto&& geom) {return geom.type();}, localGeometry_);
+#else
+            return std::visit([&](auto&& geom) {return geom.type();}, localGeometry_);
+#endif
         }
 
         /** \brief Return true if the geometry mapping is affine and false otherwise */
         bool affine() const {
+#if DUNE_VERSION_LT(DUNE_COMMON,2,8)
             return Std::visit([&](auto&& geom) {return geom.affine();}, localGeometry_);
+#else
+            return std::visit([&](auto&& geom) {return geom.affine();}, localGeometry_);
+#endif
         }
 
         //! return the number of corners of this element. Corners are numbered 0...n-1
         int corners () const {
+#if DUNE_VERSION_LT(DUNE_COMMON,2,8)
             return Std::visit([&](auto&& geom) {return geom.corners();}, localGeometry_);
+#else
+            return std::visit([&](auto&& geom) {return geom.corners();}, localGeometry_);
+#endif
         }
 
         //! access to coordinates of corners. Index is the number of the corner
         FieldVector<ctype, coorddim> corner (int i) const {
+#if DUNE_VERSION_LT(DUNE_COMMON,2,8)
             return Std::visit([&](auto&& geom) {return geom.corner(i);}, localGeometry_);
+#else
+            return std::visit([&](auto&& geom) {return geom.corner(i);}, localGeometry_);
+#endif
         }
 
         /** \brief Maps a local coordinate within reference element to
         * global coordinate in element  */
-        FieldVector<ctype, coorddim> global (const FieldVector<ctype, mydim>& local) const{
+        FieldVector<ctype, coorddim> global (const FieldVector<ctype, mydim>& local) const {
+#if DUNE_VERSION_LT(DUNE_COMMON,2,8)
             return Std::visit([&](auto&& geom) {return geom.global(local);}, localGeometry_);
+#else
+            return std::visit([&](auto&& geom) {return geom.global(local);}, localGeometry_);
+#endif
         }
 
         /** \brief Maps a global coordinate within the element to a
         * local coordinate in its reference element */
         FieldVector<ctype, mydim> local (const FieldVector<ctype, coorddim>& global) const {
+#if DUNE_VERSION_LT(DUNE_COMMON,2,8)
             return Std::visit([&](auto&& geom) {return geom.local(global);}, localGeometry_);
+#else
+            return std::visit([&](auto&& geom) {return geom.local(global);}, localGeometry_);
+#endif
         }
 
         /**
         */
         ctype integrationElement (const FieldVector<ctype, mydim>& local) const {
+#if DUNE_VERSION_LT(DUNE_COMMON,2,8)
             return Std::visit([&](auto&& geom) {return geom.integrationElement(local);}, localGeometry_);
+#else
+            return std::visit([&](auto&& geom) {return geom.integrationElement(local);}, localGeometry_);
+#endif
         }
 
         /** \brief return volume of geometry */
         ctype volume () const {
+#if DUNE_VERSION_LT(DUNE_COMMON,2,8)
             return Std::visit([&](auto&& geom) {return geom.volume();}, localGeometry_);
+#else
+            return std::visit([&](auto&& geom) {return geom.volume();}, localGeometry_);
+#endif
         }
 
         /** \brief return center of geometry
@@ -228,17 +270,29 @@ class SubGridLocalGeometry
         *  find reasonably efficient ways to implement it properly.
         */
         FieldVector<ctype, coorddim> center () const {
+#if DUNE_VERSION_LT(DUNE_COMMON,2,8)
             return Std::visit([&](auto&& geom) {return geom.center();}, localGeometry_);
+#else
+            return std::visit([&](auto&& geom) {return geom.center();}, localGeometry_);
+#endif
         }
 
         //! The Jacobian matrix of the mapping from the reference element to this element
         const JacobianTransposed jacobianTransposed (const FieldVector<ctype, mydim>& local) const {
+#if DUNE_VERSION_LT(DUNE_COMMON,2,8)
             return Std::visit([&](auto&& geom) {return static_cast<JacobianTransposed>(geom.jacobianTransposed(local));}, localGeometry_);
+#else
+            return std::visit([&](auto&& geom) {return static_cast<JacobianTransposed>(geom.jacobianTransposed(local));}, localGeometry_);
+#endif
         }
 
         //! The inverse of the Jacobian matrix of the mapping from the reference element to this element
         const JacobianInverseTransposed jacobianInverseTransposed (const FieldVector<ctype, mydim>& local) const {
+#if DUNE_VERSION_LT(DUNE_COMMON,2,8)
             return Std::visit([&](auto&& geom) {return static_cast<JacobianInverseTransposed>(geom.jacobianInverseTransposed(local));}, localGeometry_);
+#else
+            return std::visit([&](auto&& geom) {return static_cast<JacobianInverseTransposed>(geom.jacobianInverseTransposed(local));}, localGeometry_);
+#endif
         }
 
     private:
diff --git a/dune/subgrid/test/common.hh b/dune/subgrid/test/common.hh
index eee8122352abbcc67bbd87c3331e029291dafdf8..96c9545dfc9a408711fdbbe6565b5bd6113b8d2e 100644
--- a/dune/subgrid/test/common.hh
+++ b/dune/subgrid/test/common.hh
@@ -2,6 +2,8 @@
 
 #define DISABLE_DEPRECATED_METHOD_CHECK 1
 
+#include <memory>
+
 #include <dune/common/exceptions.hh>
 
 #include <dune/grid/utility/structuredgridfactory.hh>
@@ -24,7 +26,7 @@ enum EltGeometryType {SIMPLEX, CUBE, NA};
 template <class GridType, EltGeometryType EGT>
 struct CoarseGridConstructor
 {
-    static Dune::shared_ptr<GridType> constructCoarseGrid(size_t ncells=1)
+    static std::shared_ptr<GridType> constructCoarseGrid(size_t ncells=1)
     {
         DUNE_THROW(Dune::NotImplemented,"not implemented for this Element geometry");
     }
@@ -45,7 +47,7 @@ struct CoarseGridConstructor<GridType, SIMPLEX>
 template <class GridType>
 struct CoarseGridConstructor<GridType, CUBE>
 {
-    static Dune::shared_ptr<GridType> constructCoarseGrid(size_t ncells=1)
+    static std::shared_ptr<GridType> constructCoarseGrid(size_t ncells=1)
     {
         const int dim=GridType::dimension;
         std::array<unsigned int, dim> elts;