]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Lazily initialize additional_assert_output
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sun, 18 Nov 2018 11:37:07 +0000 (12:37 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sun, 18 Nov 2018 11:37:07 +0000 (12:37 +0100)
source/base/exceptions.cc

index 817bd1cd68f346e62d412d6f1ad496c5983dc606..0d17ae45d2481a5f9633a1ce3db7cb59592368fb 100644 (file)
@@ -43,7 +43,12 @@ namespace deal_II_exceptions
 {
   namespace internals
   {
-    std::string additional_assert_output;
+    std::string &
+    get_additional_assert_output()
+    {
+      static std::string additional_assert_output;
+      return additional_assert_output;
+    }
 
     bool show_stacktrace = true;
 
@@ -51,9 +56,9 @@ namespace deal_II_exceptions
   } // namespace internals
 
   void
-  set_additional_assert_output(const char *const p)
+  set_additional_assert_output(const std::string &p)
   {
-    internals::additional_assert_output = p;
+    internals::get_additional_assert_output() = p;
   }
 
   void
@@ -324,12 +329,13 @@ ExceptionBase::generate_message() const
       print_info(converter);
       print_stack_trace(converter);
 
-      if (!deal_II_exceptions::internals::additional_assert_output.empty())
+      if (!deal_II_exceptions::internals::get_additional_assert_output()
+             .empty())
         {
           converter
             << "--------------------------------------------------------"
             << std::endl
-            << deal_II_exceptions::internals::additional_assert_output
+            << deal_II_exceptions::internals::get_additional_assert_output()
             << std::endl;
         }
 

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.