[dune-functions] [Dune-functions-commit] [Commit] dune-functions - 3979792: Add helper to directly access the type of nested children

Carsten Gräser graeser at mi.fu-berlin.de
Thu Sep 10 00:01:46 CEST 2015


Am 09.09.2015 um 23:32 schrieb Christian Engwer:
> shouldn't parts of these changes go to typetree?
Yes, of course. This is true for most stuff in this header, but:

a) I'm not sure, if I have write access.
b) I'd like to discuss this with Steffen before.
c) I can imagine that typetree already contains such functionality
   and I just don't know where to find and how to use it.

The latter also applies to the hybrid index stuff. In fact
treepath.hh looks really scary to me. So I quickly stopped
trying to understand it and cooked up the std::tuple solution.
For me this seems to do all that's needed in a very simple
and intuitive way, but -> b).

Best,
Carsten


> 
> Christian
> 
> On Wed, Sep 09, 2015 at 11:28:30PM +0200, Carsten Gräser wrote:
>> New commit, appeared at Wed Sep  9 23:28:30 2015 +0200
>> as part of the following ref changes:
>>
>>     branch refs/heads/master    updated from 3c6f97c -> 4d7b5b3
>>
>> Browsable version: http://cgit.dune-project.org/repositories/dune-functions/commit/?id=3979792d3142a7e4301cf4a8a870efaad82d3972
>>
>> ======================================================================
>>
>> commit 3979792d3142a7e4301cf4a8a870efaad82d3972
>> Author: Carsten Gräser <graeser at mi.fu-berlin.de>
>> Date:   Wed Sep 9 23:24:05 2015 +0200
>>
>>     Add helper to directly access the type of nested children
>>     
>>     To get the type of the child with relative tree path (3,7,1)
>>     you can now use ChildType<Node, 3, 7, 1>
>>
>>  dune/functions/functionspacebases/tupletreepath.hh | 25 ++++++++++++++++++++++
>>  1 file changed, 25 insertions(+)
>>
>>
>>
>> diff --git a/dune/functions/functionspacebases/tupletreepath.hh b/dune/functions/functionspacebases/tupletreepath.hh
>> index e4f6bc8..7504caf 100644
>> --- a/dune/functions/functionspacebases/tupletreepath.hh
>> +++ b/dune/functions/functionspacebases/tupletreepath.hh
>> @@ -196,6 +196,31 @@ auto getChild(Tree&& tree, const std::tuple<I...>& tp)
>>  
>>  
>>  
>> +namespace Imp {
>> +
>> +template<class Node, int... Path>
>> +struct ChildTypeHelper{};
>> +
>> +template<class Node, int FirstChild, int... Path>
>> +struct ChildTypeHelper<Node, FirstChild, Path...>
>> +{
>> +  using Type = typename ChildTypeHelper<typename Node::template Child<FirstChild>::Type, Path...>::Type;
>> +};
>> +
>> +template<class Node>
>> +struct ChildTypeHelper<Node>
>> +{
>> +  using Type = Node;
>> +};
>> +
>> +
>> +}
>> +
>> +// Simplify access to type of child
>> +template<class Node, int... Path>
>> +using ChildType = typename Imp::ChildTypeHelper<Node, Path...>::Type;
>> +
>> +
>>  } // namespace Functions
>>  } // namespace Dune

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <https://lists.dune-project.org/pipermail/dune-functions/attachments/20150910/f220596a/attachment.sig>


More information about the dune-functions mailing list