]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Simplify code a bit by moving a function from a public header file into an anonymous...
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 5 Jun 2014 16:46:07 +0000 (16:46 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 5 Jun 2014 16:46:07 +0000 (16:46 +0000)
git-svn-id: https://svn.dealii.org/trunk@33023 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/hp/mapping_collection.h
deal.II/source/hp/mapping_collection.cc

index 117d76bee04106f777a41238fc7fd4d43d7aaa7d..e187cfdc35895405f57b142ee18a370f85846857 100644 (file)
@@ -138,26 +138,14 @@ namespace hp
 
   /**
    * In order to avoid creation of static MappingQ1 objects at several
-   * places in the library (in particular in backward compatibility
-   * functions), we define a static collection of mappings with a single
+   * places in the library, this class
+   * defines a static collection of mappings with a single
    * MappingQ1 mapping object once and for all places where it is
    * needed.
    */
   template<int dim, int spacedim=dim>
   struct StaticMappingQ1
   {
-  private:
-    /**
-     * A static MappingQ1 object. We can't use the one in ::StaticMappingQ1
-     * since we can't make sure that the constructor for that object is run
-     * before we want to use the object (when constructing mapping_collection
-     * below).  Therefore we create a helper function which returns a
-     * reference to a static object that will be constructed the first time
-     * this function is called.
-     */
-      static
-      MappingQ1<dim,spacedim>& return_static_mapping_q1();
-
   public:
     /**
      * The publicly available
index eb59d77463377e3bf3bbaaa84202a25e92d2ba0a..06f111fdcf5e45af09312b52693ff91eac3c4ae3 100644 (file)
@@ -82,17 +82,30 @@ namespace hp
 //---------------------------------------------------------------------------
 
 
-  template<int dim, int spacedim>
-  MappingQ1<dim,spacedim>& StaticMappingQ1<dim,spacedim>::return_static_mapping_q1()
+  namespace
   {
-    static MappingQ1<dim,spacedim> mapping;
-    return mapping;
+    /**
+     * Create and return a reference to a static MappingQ1 object. We can't
+     * use the one in ::StaticMappingQ1 to initialize the static object below
+     * since we can't make sure that the constructor for that object is run
+     * before we want to use the object (when constructing mapping_collection
+     * below).  Therefore we create a helper function which returns a
+     * reference to a static object that will be constructed the first time
+     * this function is called.
+     */
+    template<int dim, int spacedim>
+    MappingQ1<dim,spacedim> &
+    get_static_mapping_q1()
+    {
+      static MappingQ1<dim,spacedim> mapping;
+      return mapping;
+    }
   }
 
   template<int dim, int spacedim>
   MappingCollection<dim,spacedim>
   StaticMappingQ1<dim,spacedim>::mapping_collection
-    = MappingCollection<dim,spacedim>(StaticMappingQ1<dim,spacedim>::return_static_mapping_q1());
+    = MappingCollection<dim,spacedim>(get_static_mapping_q1<dim,spacedim>());
 
 }
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.