]> https://gitweb.dealii.org/ - dealii.git/commitdiff
typo in anydata removed and new function try_read tested
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Fri, 16 May 2014 07:49:06 +0000 (07:49 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Fri, 16 May 2014 07:49:06 +0000 (07:49 +0000)
git-svn-id: https://svn.dealii.org/trunk@32919 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/include/deal.II/algorithms/any_data.h
tests/algorithms/any_data_01.cc
tests/algorithms/any_data_01.output

index 8e6275ff0b9f450c755948cd302e17d4ce40fe8f..180f5f88d7b78672686777c3a9dbca06da84507b 100644 (file)
@@ -148,7 +148,14 @@ inconvenience this causes.
 <h3>Specific improvements</h3>
 
 <ol>
-  <li> New: The GMRES solver of deal.II can now write an estimate of
+<li> New: AnyData::try_read() is a function that allows users to check
+whether an entry exists and get a pointer to it without throwing an
+exception in case of failure.
+<br>
+(Guido Kanschat, 2014/05/16)
+</li>
+
+<li> New: The GMRES solver of deal.II can now write an estimate of
   eigenvalues to the log file, in analogy to the CG solver. This is enabled
   by the flag SolverGMRES<>::AdditionalData::compute_eigenvalues.
   <br>
index 8eab3cb3f1ba9bbbbf6037ba7e715cff1bf80f09..4f5550e9e35944216d9d36f77a568e18bab520b3 100644 (file)
@@ -274,7 +274,7 @@ AnyData::try_read(const std::string& n) const
   // Compute index and return casted pointer
   unsigned int i=it-names.begin();
   const type* p = boost::any_cast<type>(&data[i]);
-  return *p;
+  return p;
 }
 
 
index 6f8a3de80c800097eb1b91ce910b1c494a36d4f2..eb284c9f5cec89a1efc23180b572bb9506960207 100644 (file)
@@ -62,7 +62,11 @@ void extract(const AnyData& data)
          << d  << std::endl
          << *p2 << std::endl
          << *p3 << std::endl;
-  // try
+
+  deallog << *data.try_read<double>(" d  17.") << std::endl
+         << data.try_read<char *>(" d  17.") << std::endl
+         << data.try_read<double>("does not exist") << std::endl;
+// try
   //   {
   //     double* p3a = data.entry<double*>("cd* 17.");
   //     deallog << p3a;
index 0a9f80057efc8671a4bbd5cd610a7f5a856ad1fb..9e180107c237b74638ce9d9d28ddf6f5b55106c8 100644 (file)
@@ -12,3 +12,6 @@ DEAL::7
 DEAL::17.0000
 DEAL::18.0000
 DEAL::18.0000
+DEAL::17.0000
+DEAL::0
+DEAL::0

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.