[dune-pdelab] [dune-pdelab-commit] [Commit] dune-typetree - 8a50506: [TreePath] Add hybrid TreePath

Steffen Müthing steffen.muething at iwr.uni-heidelberg.de
Wed Sep 16 13:54:11 CEST 2015


HI Christian,

> Am 15.09.2015 um 22:15 schrieb christi at dune-project.org:
> 
> Hi Steffen,
> 
>> +#ifndef DOXYGEN
>> +
>> +      // I can't be bothered to make all the external accessors friends of HybridTreePath,
>> +      // so we'll only hide the data tuple from the user in Doxygen.
>> +
>> +      using Data = std::tuple<T...>;
>> +      Data _data;
>> +
>> +#endif // DOXYGEN
> 
> wouldn't it be better to derive from tuple, instead of a public
> member? We would have the same access rules, but a cleaner statement,
> as we explicitly tell people what they are dealing with...
> ... std::tuple + syntactic sugar

I explicitly don’t want the HybridTreePath to be a std::tuple in the is-a terms of inheritance, mainly because

 - it has some special meaning and behaviors attached
- the type is used in a number of function overloads for algorithm lookup, which are already horribly complex,
  and I want to avoid possible ambiguities because of slicing to base classes
- I don’t want people to be able to use std::get and muck around with the state of the path

The _data member is public because creating all those friend declarations would have been a ton of work, but
we can of course still do that and make _data private (on the other hand, if a user messes around with it and
shoots himself in the foot, he probably knows that he’s done a naughty thing and won’t complain … ;-)

> 
> and ...
> ... does the HybridTreePath obsolete the other implementations?

Unfortunately, it doesn’t:

- DynamicTreePath is for when you can / must provide all information dynamically. It’s typically used in the visitors
  because there dynamic information tends to be sufficient and having an object that can be manipulated purely using
  „standard“ run time expressions is more convenient.
- Sometimes you absolutely must have all index information available at compile time. That’s what TreePath gives you.
- HybridTreePath combines the two on a best-effort basis.

It would probably be possible to get rid of TreePath and use HybridTreePath instead, but that involves quite a bit of work,
and we’d have to think a little about avoiding usability regressions (because HybridTreePath requires specifying the
index_constant in a lot of places).

The DynamicTreePath probably won’t go away, because it behaves much better in the context of iteration, where new TreePath
objects get constructed all the time. DynamicTreePath has an optimization that avoids copying the actual data around (it uses
some kind of shared storage for multiple instances).

Steffen


> 
> Christian
> 
> _______________________________________________
> dune-pdelab mailing list
> dune-pdelab at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune-pdelab

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.dune-project.org/pipermail/dune-pdelab/attachments/20150916/80706469/attachment.sig>


More information about the dune-pdelab mailing list