From b6881d262265aeb807be825a4bcf7cb73b5018d7 Mon Sep 17 00:00:00 2001 From: bangerth Date: Tue, 18 Oct 2011 10:38:56 +0000 Subject: [PATCH] Move a template function to the .h file. git-svn-id: https://svn.dealii.org/trunk@24624 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/base/table_handler.h | 47 ++++++++++++++------ deal.II/source/base/table_handler.cc | 34 -------------- 2 files changed, 34 insertions(+), 47 deletions(-) diff --git a/deal.II/include/deal.II/base/table_handler.h b/deal.II/include/deal.II/base/table_handler.h index 01c91f11d3..35e9e5b3c4 100644 --- a/deal.II/include/deal.II/base/table_handler.h +++ b/deal.II/include/deal.II/base/table_handler.h @@ -109,13 +109,13 @@ namespace internal *

Usage

* * 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 key to the table if this column - * does not yet exist and adds the value of value_type - * (e.g. unsigned int, double, std::string, ...) 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(). + * add_value(const std::string &key, const T value) that adds a + * column with the name key to the table if this column does not yet + * exist and adds the given value of type T (which must be one of + * int, unsigned int, double, std::string) + * 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 key - * and adds the value of - * value_type to the column. + * Adds a column (if not yet existent) + * with the key key and adds the + * value of type T to the + * column. Values of type T must + * be convertible to one of int, + * unsigned int, double, + * std::string or a compiler error + * will result. */ - template + template 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 +void TableHandler::add_value (const std::string &key, + const T value) +{ + if (columns.find(key) == columns.end()) + { + std::pair 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 void TableHandler::Column::serialize(Archive & ar, diff --git a/deal.II/source/base/table_handler.cc b/deal.II/source/base/table_handler.cc index 7a3771d9fc..20e66b5a35 100644 --- a/deal.II/source/base/table_handler.cc +++ b/deal.II/source/base/table_handler.cc @@ -57,23 +57,6 @@ TableHandler::TableHandler() -template -void TableHandler::add_value (const std::string &key, - const number value) -{ - if (columns.find(key) == columns.end()) - { - std::pair 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 &sel_columns) c } -// explicit instantiations -template -void TableHandler::add_value (const std::string &, - const double); - -template -void TableHandler::add_value (const std::string &, - const int); - -template -void TableHandler::add_value (const std::string &, - const unsigned int); - -template -void TableHandler::add_value (const std::string &, - const std::string); - DEAL_II_NAMESPACE_CLOSE -- 2.39.5