]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Allow copying Patterns::List and Patterns::Map objects.
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 25 Apr 2017 17:28:01 +0000 (11:28 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 25 Apr 2017 17:28:01 +0000 (11:28 -0600)
Avoid the memory corruption that otherwise happens.

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

index 739386d8f01406f910b4c6e2e1399832e4735bc8..3eb4225351692312d634a793ea41c46c5debc737 100644 (file)
@@ -414,6 +414,11 @@ namespace Patterns
           const unsigned int  max_elements = max_int_value,
           const std::string  &separator = ",");
 
+    /**
+     * Copy constructor.
+     */
+    List (const List &other);
+
     /**
      * Destructor.
      */
@@ -529,6 +534,11 @@ namespace Patterns
          const unsigned int  max_elements = max_int_value,
          const std::string  &separator = ",");
 
+    /**
+     * Copy constructor.
+     */
+    Map (const Map &other);
+
     /**
      * Destructor.
      */
index 9573cbee36c9283e7c960db706cbbf3ffa7054aa..d1c613e77f2a7be7393ee63d4870b532c5368aea 100644 (file)
@@ -587,6 +587,16 @@ namespace Patterns
 
 
 
+  List::List (const List &other)
+    :
+    pattern (other.pattern->clone()),
+    min_elements (other.min_elements),
+    max_elements (other.max_elements),
+    separator (other.separator)
+  {}
+
+
+
   List::~List ()
   {
     delete pattern;
@@ -767,6 +777,17 @@ namespace Patterns
 
 
 
+  Map::Map (const Map &other)
+    :
+    key_pattern (other.key_pattern->clone()),
+    value_pattern (other.value_pattern->clone()),
+    min_elements (other.min_elements),
+    max_elements (other.max_elements),
+    separator (other.separator)
+  {}
+
+
+
   Map::~Map ()
   {
     delete key_pattern;

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.