From: Wolfgang Bangerth Date: Thu, 5 Jun 2014 16:46:07 +0000 (+0000) Subject: Simplify code a bit by moving a function from a public header file into an anonymous... X-Git-Tag: v8.2.0-rc1~413 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=35af424d445d7a1b01038098441fe76efd30f267;p=dealii.git Simplify code a bit by moving a function from a public header file into an anonymous namespace in the .cc file. git-svn-id: https://svn.dealii.org/trunk@33023 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/hp/mapping_collection.h b/deal.II/include/deal.II/hp/mapping_collection.h index 117d76bee0..e187cfdc35 100644 --- a/deal.II/include/deal.II/hp/mapping_collection.h +++ b/deal.II/include/deal.II/hp/mapping_collection.h @@ -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 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& return_static_mapping_q1(); - public: /** * The publicly available diff --git a/deal.II/source/hp/mapping_collection.cc b/deal.II/source/hp/mapping_collection.cc index eb59d77463..06f111fdcf 100644 --- a/deal.II/source/hp/mapping_collection.cc +++ b/deal.II/source/hp/mapping_collection.cc @@ -82,17 +82,30 @@ namespace hp //--------------------------------------------------------------------------- - template - MappingQ1& StaticMappingQ1::return_static_mapping_q1() + namespace { - static MappingQ1 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 + MappingQ1 & + get_static_mapping_q1() + { + static MappingQ1 mapping; + return mapping; + } } template MappingCollection StaticMappingQ1::mapping_collection - = MappingCollection(StaticMappingQ1::return_static_mapping_q1()); + = MappingCollection(get_static_mapping_q1()); }