AnyData::entry (const unsigned int i)
{
AssertIndexRange(i, size());
- Assert(data[i].type() == typeid(type),
+ type* p = boost::any_cast<type>(&data[i]);
+ Assert(p != 0,
ExcTypeMismatch(typeid(type).name(),data[i].type().name()));
- return boost::any_cast<type>(data[i]);
+ return *p;
}
AnyData::read(const unsigned int i) const
{
AssertIndexRange(i, size());
- Assert(data[i].type() == typeid(type),
+ const type* p = boost::any_cast<type>(&data[i]);
+ Assert(p != 0,
ExcTypeMismatch(typeid(type).name(),data[i].type().name()));
- return boost::any_cast<const type>(data[i]);
+ return *p;
}
AnyData::entry (const std::string& n)
{
const unsigned int i = find(n);
- /* Assert(dynamic_cast<type*>(&data[i]) != 0, */
- /* ExcTypeMismatch(typeid(type).name(),data[i].type().name())); */
- return boost::any_cast<type>(data[i]);
+ type* p = boost::any_cast<type>(&data[i]);
+ Assert(p != 0,
+ ExcTypeMismatch(typeid(type).name(),data[i].type().name()));
+ return *p;
}
AnyData::entry (const std::string& n) const
{
const unsigned int i = find(n);
- Assert(data[i].type() == typeid(type),
+ const type* p = boost::any_cast<type>(&data[i]);
+ Assert(p != 0,
ExcTypeMismatch(typeid(type).name(),data[i].type().name()));
- return boost::any_cast<const type>(data[i]);
+ return *p;
}
AnyData::read(const std::string& n) const
{
const unsigned int i = find(n);
- Assert(data[i].type() == typeid(type),
+ const type* p = boost::any_cast<type>(&data[i]);
+ Assert(p != 0,
ExcTypeMismatch(typeid(type).name(),data[i].type().name()));
- return boost::any_cast<const type>(data[i]);
+ return *p;
}
#include "../tests.h"
-#include <deal.II/base/any_data.h>
+#include <deal.II/algorithms/any_data.h>
#include <deal.II/base/logstream.h>
#include <fstream>
<< d << std::endl
<< *p2 << std::endl
<< *p3 << std::endl;
- try
- {
- double* p3a = data.entry<double*>("cd* 17.");
- deallog << p3a;
- }
- // catch(ExceptionBase e)
+ // try
// {
- // deallog << e.what() << std::endl;
+ // double* p3a = data.entry<double*>("cd* 17.");
+ // deallog << p3a;
+ // }
+ // // catch(ExceptionBase e)
+ // // {
+ // // deallog << e.what() << std::endl;
+ // // }
+ // catch(...)
+ // {
+ // deallog << "Exception duly thrown" << std::endl;
// }
- catch(...)
- {
- deallog << "Exception duly thrown" << std::endl;
- }
}