From: Guido Kanschat <dr.guido.kanschat@gmail.com>
Date: Fri, 16 May 2014 07:49:06 +0000 (+0000)
Subject: typo in anydata removed and new function try_read tested
X-Git-Tag: v8.2.0-rc1~487
X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70976f49ff743636ee0f0f2d19d37139d9b7597c;p=dealii.git

typo in anydata removed and new function try_read tested

git-svn-id: https://svn.dealii.org/trunk@32919 0785d39b-7218-0410-832d-ea1e28bc413d
---

diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h
index 8e6275ff0b..180f5f88d7 100644
--- a/deal.II/doc/news/changes.h
+++ b/deal.II/doc/news/changes.h
@@ -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>
diff --git a/deal.II/include/deal.II/algorithms/any_data.h b/deal.II/include/deal.II/algorithms/any_data.h
index 8eab3cb3f1..4f5550e9e3 100644
--- a/deal.II/include/deal.II/algorithms/any_data.h
+++ b/deal.II/include/deal.II/algorithms/any_data.h
@@ -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;
 }
 
 
diff --git a/tests/algorithms/any_data_01.cc b/tests/algorithms/any_data_01.cc
index 6f8a3de80c..eb284c9f5c 100644
--- a/tests/algorithms/any_data_01.cc
+++ b/tests/algorithms/any_data_01.cc
@@ -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;
diff --git a/tests/algorithms/any_data_01.output b/tests/algorithms/any_data_01.output
index 0a9f80057e..9e180107c2 100644
--- a/tests/algorithms/any_data_01.output
+++ b/tests/algorithms/any_data_01.output
@@ -12,3 +12,6 @@ DEAL::7
 DEAL::17.0000
 DEAL::18.0000
 DEAL::18.0000
+DEAL::17.0000
+DEAL::0
+DEAL::0