From 82cf04d9f14ab9288d7062df763bdc9bf018598d Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Thu, 19 Sep 2013 11:05:15 +0200 Subject: [PATCH] Convert functions in anonymous namespace into statics These functions are referred to from templates which may not be instantiated. Since they were in an anonymous namespace they were not reachable otherwise, and a warning is emitted. This only applies to Clang; GCC consider them used. If we make them static helper functions instead, the warning disappears. --- opm/core/utility/parameters/ParameterGroup.hpp | 6 ++++++ .../utility/parameters/ParameterGroup_impl.hpp | 17 +++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/opm/core/utility/parameters/ParameterGroup.hpp b/opm/core/utility/parameters/ParameterGroup.hpp index 4521592f..466d242c 100644 --- a/opm/core/utility/parameters/ParameterGroup.hpp +++ b/opm/core/utility/parameters/ParameterGroup.hpp @@ -282,6 +282,12 @@ namespace Opm { template void parseCommandLineArguments(int argc, StringArray argv); void recursiveSetIsOutputEnabled(bool output_is_enabled); + + // helper routines to do textual I/O + template + static std::string to_string(const T& val); + static std::pair + filename_split(const std::string& filename); }; } // namespace parameter } // namespace Opm diff --git a/opm/core/utility/parameters/ParameterGroup_impl.hpp b/opm/core/utility/parameters/ParameterGroup_impl.hpp index 8de64958..dfeb9acf 100644 --- a/opm/core/utility/parameters/ParameterGroup_impl.hpp +++ b/opm/core/utility/parameters/ParameterGroup_impl.hpp @@ -66,18 +66,18 @@ namespace Opm { static std::string type() {return "ParameterGroup";} }; - namespace { template inline std::string - to_string(const T& val) + ParameterGroup::to_string(const T& val) { std::ostringstream os; os << val; return os.str(); } + template <> inline std::string - to_string(const bool b) { + ParameterGroup::to_string(const bool& b) { if (b) { return ID_true; } else { @@ -85,14 +85,15 @@ namespace Opm { } } + template <> inline std::string - to_string(const ParameterGroup&) + ParameterGroup::to_string(const ParameterGroup&) { return std::string(""); } - std::pair - filename_split(const std::string& filename) + inline std::pair + ParameterGroup::filename_split(const std::string& filename) { int fpos = filename.rfind('.'); std::string name = filename.substr(0, fpos); @@ -100,10 +101,6 @@ namespace Opm { return std::make_pair(name, type); } - } - - - template ParameterGroup::ParameterGroup(int argc, StringArray argv, bool verify_syntax) : path_(ID_path_root), parent_(0), output_is_enabled_(true)