]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Simplify string handling. 17802/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Wed, 23 Oct 2024 17:07:28 +0000 (11:07 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 24 Oct 2024 02:56:58 +0000 (20:56 -0600)
18 files changed:
include/deal.II/base/hdf5.h
include/deal.II/base/patterns.h
include/deal.II/fe/fe_tools.templates.h
include/deal.II/lac/read_write_vector.templates.h
include/deal.II/lac/trilinos_tpetra_vector.templates.h
include/deal.II/numerics/dof_output_operator.h
source/base/convergence_table.cc
source/base/enable_observer_pointer.cc
source/base/hdf5.cc
source/base/job_identifier.cc
source/base/logstream.cc
source/base/parsed_convergence_table.cc
source/base/path_search.cc
source/base/timer.cc
source/differentiation/sd/symengine_tensor_operations.cc
source/grid/grid_out.cc
source/lac/trilinos_epetra_vector.cc
source/lac/trilinos_solver.cc

index bac862d70ed56c4f4dc75b891f204c877f0fdbf7..888833edb210726beb2ce3027728c42a9527fdf9 100644 (file)
@@ -61,7 +61,7 @@ DEAL_II_NAMESPACE_OPEN
  * double double_attribute = 2.2;
  * data_file.set_attribute("double_attribute", double_attribute);
  * auto group = data_file.create_group("group");
- * group.set_attribute("simulation_type", std::string("elastic_equation"));
+ * group.set_attribute("simulation_type", "elastic_equation");
  * auto dataset = group.create_dataset<double>("dataset_name", dimensions);
  * dataset.set_attribute("complex_double_attribute",
  *                       std::complex<double>(2,2.3));
index 2300fa183d63139cb2682ea13b60299f36c2234c..0b1a6123063489bea37facaea91046376d420382 100644 (file)
@@ -805,7 +805,7 @@ namespace Patterns
 
     /**
      * Constructor. This is needed to allow users to specify
-     * directly the separator without using std::string(";").
+     * directly the separator without using ";".
      *
      * Since we support a pure variadic templates version, without this
      * specialization, the compiler will fail with cryptic errors.
@@ -1441,7 +1441,7 @@ namespace Patterns
   template <class... PatternTypes>
   Tuple::Tuple(const PatternTypes &...ps)
     : // forward to the version with the separator argument
-    Tuple(std::string(":"), ps...)
+    Tuple(":", ps...)
   {}
 
 
index 505195ec1fcde9a2491b2f06ab2890fde5d2cde2..e211523b699c8554e4713af440d512c5ce0e046f 100644 (file)
@@ -2308,7 +2308,7 @@ namespace FETools
             // Now, just the [...]
             // part should be left.
             if (name.empty() || name[0] != '[')
-              throw std::string("Invalid first character in ") + name;
+              throw "Invalid first character in " + name;
             do
               {
                 // Erase the
@@ -2362,7 +2362,7 @@ namespace FETools
             // we actually had a ']'
             // there
             if (name.empty() || name[0] != ']')
-              throw std::string("Invalid first character in ") + name;
+              throw "Invalid first character in " + name;
             name.erase(0, 1);
             // just one more sanity check
             Assert((base_fes.size() == base_multiplicities.size()) &&
@@ -2411,7 +2411,7 @@ namespace FETools
             // Now, just the (degree) or (Quadrature<1>(degree+1)) part should
             // be left.
             if (name.empty() || name[0] != '(')
-              throw std::string("Invalid first character in ") + name;
+              throw "Invalid first character in " + name;
             name.erase(0, 1);
             if (name[0] != 'Q')
               {
@@ -2590,9 +2590,7 @@ namespace FETools
       }
     catch (const std::string &errline)
       {
-        AssertThrow(false,
-                    ExcInvalidFEName(parameter_name + std::string(" at ") +
-                                     errline));
+        AssertThrow(false, ExcInvalidFEName(parameter_name + " at " + errline));
         return nullptr;
       }
   }
index 0a6c62d9fd243a21bcfcb7f74a95b2f752f2b8a8..0f0c52b22e0581cf278ccf33f7c086020f74ba5d 100644 (file)
@@ -556,7 +556,7 @@ namespace LinearAlgebra
           communication_pattern);
         AssertThrow(tpetra_comm_pattern != nullptr,
                     ExcMessage(
-                      std::string("The communication pattern is not of type ") +
+                      "The communication pattern is not of type "
                       "LinearAlgebra::TpetraWrappers::CommunicationPattern."));
       }
 
@@ -686,7 +686,7 @@ namespace LinearAlgebra
             communication_pattern);
         AssertThrow(epetra_comm_pattern != nullptr,
                     ExcMessage(
-                      std::string("The communication pattern is not of type ") +
+                      "The communication pattern is not of type "
                       "LinearAlgebra::EpetraWrappers::CommunicationPattern."));
       }
 
index 4814631ea134cbcb2893aa2143cd71d3c4837848..1d30fd42659f9a60f8c0d9c1ac9b5dd3d0f6d5a0 100644 (file)
@@ -528,9 +528,8 @@ namespace LinearAlgebra
 
           AssertThrow(
             !tpetra_comm_pattern.is_null(),
-            ExcMessage(
-              std::string("The communication pattern is not of type ") +
-              "LinearAlgebra::TpetraWrappers::CommunicationPattern."));
+            ExcMessage("The communication pattern is not of type "
+                       "LinearAlgebra::TpetraWrappers::CommunicationPattern."));
         }
 
       Teuchos::RCP<const TpetraTypes::ExportType<MemorySpace>> tpetra_export =
index 1ff4be52cfe986d9e92d6124f7b78a34eb5ca346..8ef06582c813731d5738fd3f5cf6bb6c6e728df7 100644 (file)
@@ -53,7 +53,7 @@ namespace Algorithms
      * last step command. Numbers with less digits are filled with
      * zeros from the left.
      */
-    DoFOutputOperator(const std::string &filename_base = std::string("output"),
+    DoFOutputOperator(const std::string &filename_base = "output",
                       const unsigned int digits        = 3);
 
     void
index 3930aa51baa5b4911a7c3bf4e1750ef06e5e5542..c93c6f34de6373cf6705880280ae7eb44a71453d 100644 (file)
@@ -69,7 +69,7 @@ ConvergenceTable::evaluate_convergence_rates(
             if (i == 0)
               {
                 // no value available for the first row
-                add_value(rate_key, std::string("-"));
+                add_value(rate_key, "-");
               }
             else
               {
@@ -88,7 +88,7 @@ ConvergenceTable::evaluate_convergence_rates(
             if (i == 0)
               {
                 // no value available for the first row
-                add_value(rate_key, std::string("-"));
+                add_value(rate_key, "-");
               }
             else
               {
@@ -159,7 +159,7 @@ ConvergenceTable::evaluate_convergence_rates(const std::string &data_column_key,
             if (i == 0)
               {
                 // no value available for the first row
-                add_value(rate_key, std::string("-"));
+                add_value(rate_key, "-");
               }
             else
               {
@@ -177,7 +177,7 @@ ConvergenceTable::evaluate_convergence_rates(const std::string &data_column_key,
             if (i == 0)
               {
                 // no value available for the first row
-                add_value(rate_key, std::string("-"));
+                add_value(rate_key, "-");
               }
             else
               {
index 4360970748788702e7b0ee1d44c3ee6dccf3060b..d551c34c955a9cabaa773d0d77086b90eee5b68d 100644 (file)
@@ -80,8 +80,8 @@ EnableObserverPointer::check_no_subscribers() const noexcept
           for (const auto &map_entry : counter_map)
             {
               if (map_entry.second > 0)
-                infostring += std::string("\n  from Subscriber ") +
-                              std::string(map_entry.first);
+                infostring +=
+                  "\n  from Subscriber " + std::string(map_entry.first);
             }
 
           if (infostring.empty())
index 1af74efbcee34df6530f28c3772cf4ee14c475cd..a95ef9e41064bd91cd0c6373d7d8cd4bbf75b26b 100644 (file)
@@ -212,28 +212,28 @@ namespace HDF5
     switch (io_mode)
       {
         case (H5D_MPIO_NO_COLLECTIVE):
-          return std::string("H5D_MPIO_NO_COLLECTIVE");
+          return "H5D_MPIO_NO_COLLECTIVE";
           break;
         case (H5D_MPIO_CHUNK_INDEPENDENT):
-          return std::string("H5D_MPIO_CHUNK_INDEPENDENT");
+          return "H5D_MPIO_CHUNK_INDEPENDENT";
           break;
         case (H5D_MPIO_CHUNK_COLLECTIVE):
-          return std::string("H5D_MPIO_CHUNK_COLLECTIVE");
+          return "H5D_MPIO_CHUNK_COLLECTIVE";
           break;
         case (H5D_MPIO_CHUNK_MIXED):
-          return std::string("H5D_MPIO_CHUNK_MIXED");
+          return "H5D_MPIO_CHUNK_MIXED";
           break;
         case (H5D_MPIO_CONTIGUOUS_COLLECTIVE):
-          return std::string("H5D_MPIO_CONTIGUOUS_COLLECTIVE");
+          return "H5D_MPIO_CONTIGUOUS_COLLECTIVE";
           break;
         default:
           DEAL_II_ASSERT_UNREACHABLE();
-          return std::string("Internal error");
+          return "Internal error";
           break;
       }
     // The function should not reach this line.
     DEAL_II_ASSERT_UNREACHABLE();
-    return std::string("Internal error");
+    return "Internal error";
   }
 
 
index 76ec231ef0d5cf019b7c6fc29f1bab4dfff07a5e..d52812bf7ce5fca0591f4d52a5500afde62721d3 100644 (file)
@@ -35,14 +35,14 @@ JobIdentifier::get_dealjobid()
 JobIdentifier::JobIdentifier()
 {
   time_t t = std::time(nullptr);
-  id       = std::string("JobId ");
+  id       = "JobId ";
 
 #if defined(DEAL_II_HAVE_UNISTD_H) && defined(DEAL_II_HAVE_GETHOSTNAME)
   char name[100];
   gethostname(name, 99);
-  id += std::string(name) + std::string(" ");
+  id += std::string(name) + " ";
 #else
-  id += std::string("unknown ");
+  id += "unknown ";
 #endif
 
   id += std::string(std::ctime(&t));
index 889faf92b9a3294eacd1706a164de017fd44540b..5fa846a197ce85ae9591973ba84cb3df8ed97075 100644 (file)
@@ -306,7 +306,7 @@ LogStream::push(const std::string &text)
     pre = get_prefixes().top();
 
   pre += text;
-  pre += std::string(":");
+  pre += ":";
   get_prefixes().push(pre);
 }
 
index 9a6be7e3427fbfa303501c4b9b4dd52bbdb9ef90..58733e8fb1f227a403b52fe1e41c780118f2cf20 100644 (file)
@@ -248,9 +248,8 @@ ParsedConvergenceTable::output_table()
       else
         {
           AssertThrow(false,
-                      ExcInternalError(
-                        std::string("Unrecognized file format: ") +
-                        error_file_format));
+                      ExcInternalError("Unrecognized file format: " +
+                                       error_file_format));
         }
       table_file.close();
     }
index 61c8df942aca5bec7a9f053cdc6b918f9d98b9a2..d479fb3288cf34315535b8984fbf5dfe86b5a4aa 100644 (file)
@@ -33,17 +33,17 @@ PathSearch::initialize_classes()
 {
   std::vector<std::string> v;
   v.emplace_back();
-  path_lists.insert(map_type(std::string("PARAMETER"), v));
+  path_lists.insert(map_type("PARAMETER", v));
 
   /*
    * TODO: re-enable some sensible default paths. Maier, 2012
    */
-  path_lists.insert(map_type(std::string("MESH"), v));
+  path_lists.insert(map_type("MESH", v));
 
   v.clear();
   v.emplace_back();
   v.emplace_back(".prm");
-  suffix_lists.insert(map_type(std::string("PARAMETER"), v));
+  suffix_lists.insert(map_type("PARAMETER", v));
 
   /*
    * TODO: "Would require linking with the deal.II libraries"? This .cc
@@ -62,7 +62,7 @@ PathSearch::initialize_classes()
   v.emplace_back(".plt");
   v.emplace_back(".nc");
   v.emplace_back(".msh");
-  suffix_lists.insert(map_type(std::string("MESH"), v));
+  suffix_lists.insert(map_type("MESH", v));
 }
 
 std::vector<std::string> &
@@ -163,7 +163,7 @@ PathSearch::find(const std::string &filename,
         }
     }
   AssertThrow(false, ExcFileNotFound(filename, cls));
-  return std::string("");
+  return "";
 }
 
 std::string
@@ -189,7 +189,7 @@ PathSearch::find(const std::string &filename, const char *open_mode)
         }
     }
   AssertThrow(false, ExcFileNotFound(filename, cls));
-  return std::string("");
+  return "";
 }
 
 
index da4c87827da36d679e2fd2b50a9cd22a4160a600..4b35f50bab988d2888a34f46d3b11305bffd6859 100644 (file)
@@ -402,8 +402,8 @@ TimerOutput::enter_subsection(const std::string &section_name)
   Assert(std::find(active_sections.begin(),
                    active_sections.end(),
                    section_name) == active_sections.end(),
-         ExcMessage(std::string("Cannot enter the already active section <") +
-                    section_name + ">."));
+         ExcMessage("Cannot enter the already active section <" + section_name +
+                    ">."));
 
   if (sections.find(section_name) == sections.end())
     {
index 1dee85e8c60d2cb636d6d3e17b8316dfa6b2d536..b27b9eb954c1fa11b476e8b2e12474b68204f9eb 100644 (file)
@@ -65,8 +65,8 @@ namespace Differentiation
               {
                 const TableIndices<rank> indices(
                   out.unrolled_to_component_indices(i));
-                out[indices] = Expression(sym + std::string("_") +
-                                          internal::make_index_string(indices));
+                out[indices] =
+                  Expression(sym + "_" + internal::make_index_string(indices));
               }
             return out;
           }
@@ -99,8 +99,8 @@ namespace Differentiation
               {
                 const TableIndices<rank> indices(
                   out.unrolled_to_component_indices(i));
-                out[indices] = Expression(sym + std::string("_") +
-                                          internal::make_index_string(indices));
+                out[indices] =
+                  Expression(sym + "_" + internal::make_index_string(indices));
               }
             return out;
           }
@@ -123,9 +123,8 @@ namespace Differentiation
                 {
                   const TableIndices<4> indices =
                     make_rank_4_tensor_indices<dim>(i, j);
-                  out[indices] =
-                    Expression(sym + std::string("_") +
-                               internal::make_index_string(indices));
+                  out[indices] = Expression(
+                    sym + "_" + internal::make_index_string(indices));
                 }
             return out;
           }
@@ -151,8 +150,7 @@ namespace Differentiation
                 const TableIndices<rank> indices(
                   out.unrolled_to_component_indices(i));
                 out[indices] =
-                  Expression(sym + std::string("_") +
-                               internal::make_index_string(indices),
+                  Expression(sym + "_" + internal::make_index_string(indices),
                              args);
               }
             return out;
@@ -191,8 +189,7 @@ namespace Differentiation
                 const TableIndices<rank> indices(
                   out.unrolled_to_component_indices(i));
                 out[indices] =
-                  Expression(sym + std::string("_") +
-                               internal::make_index_string(indices),
+                  Expression(sym + "_" + internal::make_index_string(indices),
                              args);
               }
             return out;
@@ -220,8 +217,7 @@ namespace Differentiation
                   const TableIndices<4> indices =
                     make_rank_4_tensor_indices<dim>(i, j);
                   out[indices] =
-                    Expression(sym + std::string("_") +
-                                 internal::make_index_string(indices),
+                    Expression(sym + "_" + internal::make_index_string(indices),
                                args);
                 }
             return out;
index a50cab110c16bd54837825b9afdc8ba7ca39732b..421013ae02258030b04cbc6cf5bcf88ac0e032bb 100644 (file)
@@ -230,9 +230,9 @@ namespace GridOutFlags
   void
   EpsFlagsBase::parse_parameters(ParameterHandler &param)
   {
-    if (param.get("Size by") == std::string("width"))
+    if (param.get("Size by") == "width")
       size_type = width;
-    else if (param.get("Size by") == std::string("height"))
+    else if (param.get("Size by") == "height")
       size_type = height;
     size                     = param.get_integer("Size");
     line_width               = param.get_double("Line width");
index b514f60b10d5b9143d0769e728dc73b317121157..998ed14981cb5573d50d9585b1d72f83ad3f6f6c 100644 (file)
@@ -224,9 +224,8 @@ namespace LinearAlgebra
               communication_pattern);
           AssertThrow(
             epetra_comm_pattern != nullptr,
-            ExcMessage(
-              std::string("The communication pattern is not of type ") +
-              "LinearAlgebra::EpetraWrappers::CommunicationPattern."));
+            ExcMessage("The communication pattern is not of type "
+                       "LinearAlgebra::EpetraWrappers::CommunicationPattern."));
         }
 
       Epetra_Import import_map(epetra_comm_pattern->get_epetra_import());
index 522fb10fd3c8f5829cc146e7e3730a9b26c6ee5f..d99cf9287f9568ab325641a5b10cb1ef9a1f2daf 100644 (file)
@@ -684,7 +684,7 @@ namespace TrilinosWrappers
 
     AssertThrow(Factory.Query(additional_data.solver_type.c_str()),
                 ExcMessage(
-                  std::string("You tried to select the solver type <") +
+                  "You tried to select the solver type <" +
                   additional_data.solver_type +
                   "> but this solver is not supported by Trilinos either "
                   "because it does not exist, or because Trilinos was not "
@@ -811,7 +811,7 @@ namespace TrilinosWrappers
 
     AssertThrow(Factory.Query(additional_data.solver_type.c_str()),
                 ExcMessage(
-                  std::string("You tried to select the solver type <") +
+                  "You tried to select the solver type <" +
                   additional_data.solver_type +
                   "> but this solver is not supported by Trilinos either "
                   "because it does not exist, or because Trilinos was not "

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.