comparing Expression* to GenericFunction*

Asked by Chaffra Affouda on 2013-03-14

I am trying to make the comparison

function == expression

in c++ where,

boost::shared_ptr<const GenericFunction> function;
boost::shared_ptr<const Expression> expression;

but gcc gives me the error below. The comparison compiles when using
boost::shared_ptr<const Function> expression;

And also Expression and Function are both children of GenericFunction

 In function ‘bool boost::operator==(const boost::shared_ptr<T>&, const boost::shared_ptr<U>&) [with T = const dolfin::GenericFunction, U = const dolfin::Expression]’:
/home/chaffra/Projects/Fenics/dolfin/dolfin/plot/VTKPlottableGenericFunction1D.cpp:84:59: instantiated from here
/usr/lib/cmake/Trilinos/../../../include/boost/smart_ptr/shared_ptr.hpp:481:29: error: comparison between distinct pointer types ‘const dolfin::GenericFunction*’ and ‘const dolfin::Expression*’ lacks a cast

Question information

Language:
English Edit question
Status:
Answered
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Last query:
2013-03-14
Last reply:
2013-03-14
Johan Hake (johan-hake) said : #1

Not sure what you are doing but try:

  function.id() == expression.id()

Johan

On 03/14/2013 04:41 PM, Chaffra Affouda wrote:
> Question #224295 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/224295
>
> Description changed to:
> I am trying to make the comparison
>
> function == expression
>
> in c++ where,
>
> boost::shared_ptr<const GenericFunction> function;
> boost::shared_ptr<const Expression> expression;
>
> but gcc gives me the error below. The comparison compiles when using
> boost::shared_ptr<const Function> expression;
>
> And also Expression and Function are both children of GenericFunction
>
>
> In function ‘bool boost::operator==(const boost::shared_ptr<T>&, const boost::shared_ptr<U>&) [with T = const dolfin::GenericFunction, U = const dolfin::Expression]’:
> /home/chaffra/Projects/Fenics/dolfin/dolfin/plot/VTKPlottableGenericFunction1D.cpp:84:59: instantiated from here
> /usr/lib/cmake/Trilinos/../../../include/boost/smart_ptr/shared_ptr.hpp:481:29: error: comparison between distinct pointer types ‘const dolfin::GenericFunction*’ and ‘const dolfin::Expression*’ lacks a cast
>

Can you help with this problem?

Provide an answer of your own, or ask Chaffra Affouda for more information if necessary.

To post a message you must log in.