[petsc-dev] macro wrappers around functions to caste suck
Barry Smith
bsmith at mcs.anl.gov
Sun Apr 7 17:06:35 CDT 2013
On Apr 7, 2013, at 5:02 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
> Barry Smith <bsmith at mcs.anl.gov> writes:
>
>> Seems inconsistent to only handle the cast automatically for
>> some. We should do it all or nothing. That is be C++ish and let the
>> user always pass a subclass where the class is expected or be C ish
>> and always require the cast.
>
> Unfortunately, there is no way to allow implicit conversion for
> subclasses without implicitly converting everything.
True, people could pass any crazy thing in there. The only hope is that the runtime checking of PetscObjects would get any non-PetscObjects passed in.
> The explicit cast
> is visually jarring enough to make it obvious at the call site that that
> argument must be a PetscObject. I'm pretty indifferent about changing
> it.
I am fine with leaving the code as is at this time.
Presumably the cast for function pointers IS needed for certain C++ compilers and cannot (or should not?) be done manually by users so we would do the trick for those?
Barry
More information about the petsc-dev
mailing list