]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix GeneralDataStorage::get_[or_add_]object_with_name for ICC 10700/head
authorDaniel Arndt <arndtd@ornl.gov>
Mon, 13 Jul 2020 02:08:16 +0000 (22:08 -0400)
committerDaniel Arndt <arndtd@ornl.gov>
Mon, 13 Jul 2020 13:17:38 +0000 (09:17 -0400)
include/deal.II/algorithms/general_data_storage.h
tests/algorithms/general_data_storage_01.output.intel [new file with mode: 0644]

index bdff0a196f2f7a095558177a06d65d5ade255537..9b59a0f9ada878c87baf2d5e474d0bdc0935bd01 100644 (file)
@@ -248,6 +248,17 @@ public:
                               Arg &              argument,
                               Args &... arguments);
 
+  /**
+   * Return a reference to the object with given name. If the object does
+   * not exist, then the input @p arguments will be used to construct an object
+   * of the given @p Type and a reference to this new object then be returned.
+   *
+   * Same as above for a single argument.
+   */
+  template <typename Type, typename Arg>
+  Type &
+  get_or_add_object_with_name(const std::string &name, Arg &argument);
+
   /**
    * Return a reference to the object with given name. If the object does
    * not exist, then the input @p arguments will be used to construct an object
@@ -264,6 +275,17 @@ public:
                               Arg &&             argument,
                               Args &&... arguments);
 
+  /**
+   * Return a reference to the object with given name. If the object does
+   * not exist, then the input @p arguments will be used to construct an object
+   * of the given @p Type and a reference to this new object then be returned.
+   *
+   * Same as above for a single argument.
+   */
+  template <typename Type, typename Arg>
+  Type &
+  get_or_add_object_with_name(const std::string &name, Arg &&argument);
+
   /**
    * Same as above for default constructors.
    */
@@ -452,6 +474,20 @@ GeneralDataStorage::get_object_with_name(const std::string &name) const
 }
 
 
+
+template <typename Type, typename Arg>
+Type &
+GeneralDataStorage::get_or_add_object_with_name(const std::string &name,
+                                                Arg &              argument)
+{
+  if (!stores_object_with_name(name))
+    add_unique_copy(name, Type(argument));
+
+  return get_object_with_name<Type>(name);
+}
+
+
+
 template <typename Type, typename Arg, typename... Args>
 Type &
 GeneralDataStorage::get_or_add_object_with_name(const std::string &name,
@@ -465,6 +501,20 @@ GeneralDataStorage::get_or_add_object_with_name(const std::string &name,
 }
 
 
+
+template <typename Type, typename Arg>
+Type &
+GeneralDataStorage::get_or_add_object_with_name(const std::string &name,
+                                                Arg &&             argument)
+{
+  if (!stores_object_with_name(name))
+    add_unique_copy(name, Type(std::forward<Arg>(argument)));
+
+  return get_object_with_name<Type>(name);
+}
+
+
+
 template <typename Type, typename Arg, typename... Args>
 Type &
 GeneralDataStorage::get_or_add_object_with_name(const std::string &name,
diff --git a/tests/algorithms/general_data_storage_01.output.intel b/tests/algorithms/general_data_storage_01.output.intel
new file mode 100644 (file)
index 0000000..9f73245
--- /dev/null
@@ -0,0 +1,75 @@
+
+DEAL::Add by copy
+DEAL::Size: 2
+DEAL::Add by reference
+DEAL::Size: 2
+DEAL::Add or construct
+DEAL::Size: 1
+DEAL::Merge
+DEAL::Data pre-merge:
+DEAL::value            double
+DEAL::Size: 1
+DEAL::Data 2 pre-merge:
+DEAL::value            double
+DEAL::value_2          double
+DEAL::Size: 2
+DEAL::Data post-merge:
+DEAL::value            double
+DEAL::value_2          double
+DEAL::Size: 2
+DEAL::Ambiguous construction
+DEAL::Try to overwrite existing entry: Copy
+DEAL::
+--------------------------------------------------------
+An error occurred in file <general_data_storage.h> in function
+    void dealii::GeneralDataStorage::add_unique_copy(const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> &, const Type &) [with Type = double]
+The violated condition was: 
+    !stores_object_with_name(name)
+Additional information: 
+    An entry with the name value already exists.
+--------------------------------------------------------
+
+DEAL::Try to overwrite existing entry: Reference
+DEAL::
+--------------------------------------------------------
+An error occurred in file <general_data_storage.h> in function
+    void dealii::GeneralDataStorage::add_unique_reference(const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> &, Type &) [with Type = const double]
+The violated condition was: 
+    !stores_object_with_name(name)
+Additional information: 
+    An entry with the name value already exists.
+--------------------------------------------------------
+
+DEAL::Fetch non-existing entry
+DEAL::
+--------------------------------------------------------
+An error occurred in file <general_data_storage.h> in function
+    Type &dealii::GeneralDataStorage::get_object_with_name(const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> &) [with Type = double]
+The violated condition was: 
+    stores_object_with_name(name)
+Additional information: 
+    No entry with the name value exists.
+--------------------------------------------------------
+
+DEAL::Access removed entry (reference)
+DEAL::
+--------------------------------------------------------
+An error occurred in file <general_data_storage.h> in function
+    Type &dealii::GeneralDataStorage::get_object_with_name(const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> &) [with Type = double]
+The violated condition was: 
+    stores_object_with_name(name)
+Additional information: 
+    No entry with the name value exists.
+--------------------------------------------------------
+
+DEAL::Access removed entry (copy)
+DEAL::
+--------------------------------------------------------
+An error occurred in file <general_data_storage.h> in function
+    Type &dealii::GeneralDataStorage::get_object_with_name(const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> &) [with Type = double]
+The violated condition was: 
+    stores_object_with_name(name)
+Additional information: 
+    No entry with the name value exists.
+--------------------------------------------------------
+

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.