]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Move a template function to the .h file.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 18 Oct 2011 10:38:56 +0000 (10:38 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 18 Oct 2011 10:38:56 +0000 (10:38 +0000)
git-svn-id: https://svn.dealii.org/trunk@24624 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/base/table_handler.h
deal.II/source/base/table_handler.cc

index 01c91f11d3e16ae294444d84be14d836ea632e23..35e9e5b3c4b64f80dde06601d79a22715ff48f0d 100644 (file)
@@ -109,13 +109,13 @@ namespace internal
  * <h3>Usage</h3>
  *
  * The most important function is the templatized function
- * add_value(const std::string &key, const value_type value), that
- * adds a column with the name <tt>key</tt> to the table if this column
- * does not yet exist and adds the value of <tt>value_type</tt>
- * (e.g. <tt>unsigned int</tt>, <tt>double</tt>, <tt>std::string</tt>, ...) to this
- * column.  After the table is complete there are different
- * possibilities of output, e.g.  into a tex file with
- * write_tex() or as text with write_text().
+ * <code>add_value(const std::string &key, const T value)</code> that adds a
+ * column with the name <tt>key</tt> to the table if this column does not yet
+ * exist and adds the given value of type <tt>T</tt> (which must be one of
+ * <tt>int</tt>, <tt>unsigned int</tt>, <tt>double</tt>, <tt>std::string</tt>)
+ * to this column.  After the table is complete there are different
+ * possibilities of output, e.g., into a latex file with write_tex() or as text
+ * with write_text().
  *
  * Two (or more) columns may be merged into a "supercolumn" by twice
  * (or multiple) calling add_column_to_supercolumn(), see
@@ -174,14 +174,18 @@ class TableHandler
     TableHandler ();
 
                                      /**
-                                      * Adds a column (if not yet
-                                      * existent) with the key <tt>key</tt>
-                                      * and adds the value of
-                                      * <tt>value_type</tt> to the column.
+                                      * Adds a column (if not yet existent)
+                                      * with the key <tt>key</tt> and adds the
+                                      * value of type <tt>T</tt> to the
+                                      * column. Values of type <tt>T</tt> must
+                                      * be convertible to one of <code>int,
+                                      * unsigned int, double,
+                                      * std::string</code> or a compiler error
+                                      * will result.
                                       */
-    template <typename value_type>
+    template <typename T>
     void add_value (const std::string &key,
-                    const value_type   value);
+                    const T            value);
 
                                      /**
                                       * Creates a supercolumn (if not
@@ -706,6 +710,23 @@ namespace internal
 }
 
 
+template <typename T>
+void TableHandler::add_value (const std::string &key,
+                             const T            value)
+{
+  if (columns.find(key) == columns.end())
+    {
+      std::pair<std::string, Column> new_column(key, Column(key));
+      columns.insert(new_column);
+      column_order.push_back(key);
+    }
+
+  const internal::TableEntry entry = { value };
+  columns[key].entries.push_back (entry);
+}
+
+
+
 template <class Archive>
 void
 TableHandler::Column::serialize(Archive & ar,
index 7a3771d9fc43c28d0cdfcb9f00fe231273a53728..20e66b5a35b536bef828949bb4c40e7a5792b2f7 100644 (file)
@@ -57,23 +57,6 @@ TableHandler::TableHandler()
 
 
 
-template <typename number>
-void TableHandler::add_value (const std::string &key,
-                             const number value)
-{
-  if (columns.find(key) == columns.end())
-    {
-      std::pair<std::string, Column> new_column(key, Column(key));
-      columns.insert(new_column);
-      column_order.push_back(key);
-    }
-
-  const internal::TableEntry entry = { value };
-  columns[key].entries.push_back (entry);
-}
-
-
-
 void TableHandler::add_column_to_supercolumn (const std::string &key,
                                              const std::string &superkey)
 {
@@ -488,21 +471,4 @@ void TableHandler::get_selected_columns(std::vector<std::string> &sel_columns) c
 }
 
 
-// explicit instantiations
-template
-void TableHandler::add_value<double> (const std::string &,
-                                     const double);
-
-template
-void TableHandler::add_value<int> (const std::string &,
-                                  const int);
-
-template
-void TableHandler::add_value<unsigned int> (const std::string &,
-                                           const unsigned int);
-
-template
-void TableHandler::add_value<std::string> (const std::string &,
-                                          const std::string);
-
 DEAL_II_NAMESPACE_CLOSE

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.