[dune-functions] [Dune-functions-commit] [Commit] dune-functions - 0d929aa: Add staticForLoop

Steffen Müthing steffen.muething at iwr.uni-heidelberg.de
Wed Sep 23 14:28:47 CEST 2015


> Am 23.09.2015 um 14:23 schrieb Christian Engwer <christian.engwer at uni-muenster.de>:
> 
> typetree for the time being:-)

And we all wait for C++17 and fold expressions… ;-)

> 
> On Wed, Sep 23, 2015 at 02:05:07PM +0200, Carsten Gräser wrote:
>> New commit, appeared at Wed Sep 23 14:05:07 2015 +0200
>> as part of the following ref changes:
>> 
>>    branch refs/heads/master    updated from 9137cfb -> c682840
>> 
>> Browsable version: http://cgit.dune-project.org/repositories/dune-functions/commit/?id=0d929aa3cbc49d5d6c50d3c478457ac66d7ae255
>> 
>> ======================================================================
>> 
>> commit 0d929aa3cbc49d5d6c50d3c478457ac66d7ae255
>> Author: Carsten Gräser <graeser at mi.fu-berlin.de>
>> Date:   Wed Sep 23 13:56:53 2015 +0200
>> 
>>    Add staticForLoop
>> 
>>    In contrast to the one from dune-common this does not include
>>    the end and can be used with generic lambdas making code much
>>    more readable. Maybe we'd like to have this in dune-common or
>>    dune-typetree.
>> 
>> dune/functions/common/CMakeLists.txt   |  1 +
>> dune/functions/common/staticforloop.hh | 57 ++++++++++++++++++++++++++++++++++
>> 2 files changed, 58 insertions(+)
>> create mode 100644 dune/functions/common/staticforloop.hh
>> 
>> 
>> 
>> diff --git a/dune/functions/common/CMakeLists.txt b/dune/functions/common/CMakeLists.txt
>> index a3ee6f6..e321baf 100644
>> --- a/dune/functions/common/CMakeLists.txt
>> +++ b/dune/functions/common/CMakeLists.txt
>> @@ -15,6 +15,7 @@ install(FILES
>>         optional.hh
>>         polymorphicsmallobject.hh
>>         signature.hh
>> +        staticforloop.hh
>>         treedata.hh
>>         type_traits.hh
>>         typeerasure.hh
>> diff --git a/dune/functions/common/staticforloop.hh b/dune/functions/common/staticforloop.hh
>> new file mode 100644
>> index 0000000..17ecc51
>> --- /dev/null
>> +++ b/dune/functions/common/staticforloop.hh
>> @@ -0,0 +1,57 @@
>> +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
>> +// vi: set et ts=4 sw=2 sts=2:
>> +#ifndef DUNE_FUNCTIONS_COMMON_STATICFORLOOP_HH
>> +#define DUNE_FUNCTIONS_COMMON_STATICFORLOOP_HH
>> +
>> +
>> +#include <dune/functions/common/concept.hh>
>> +#include <dune/functions/common/type_traits.hh>
>> +#include <dune/functions/functionspacebases/concepts.hh>
>> +
>> +
>> +namespace Dune {
>> +namespace Functions {
>> +
>> +
>> +
>> +template<class ST, ST begin, ST end>
>> +struct StaticForLoop
>> +{
>> +  template<class F, class...Args>
>> +  static void apply(F&& f, Args&&... args)
>> +  {
>> +    f(std::integral_constant<ST, begin>(), std::forward<Args>(args)...);
>> +    StaticForLoop<ST, begin+1, end>::apply(std::forward<F>(f), std::forward<Args>(args)...);
>> +  }
>> +};
>> +
>> +template<class ST, ST end>
>> +struct StaticForLoop<ST, end, end>
>> +{
>> +  template<class F, class...Args>
>> +  static void apply(F&& f, Args&&...)
>> +  {}
>> +};
>> +
>> +/**
>> + * \brief Static for loop
>> + *
>> + * Run static for-loop from 'begin' to 'end-1' with functor.
>> + * The functor is called with TypeTree::index_constant<i>
>> + * as first argument. All other arguments of this method
>> + * are forwarded to the functor.
>> + */
>> +template<std::size_t begin_t, std::size_t end_t, class F, class... Args>
>> +void staticForLoop(F&& f, Args&&... args)
>> +{
>> +  StaticForLoop<std::size_t, begin_t, end_t>::apply(std::forward<F>(f), std::forward<Args>(args)...);
>> +}
>> +
>> +
>> +
>> +} // namespace Dune::Functions
>> +} // namespace Dune
>> +
>> +
>> +
>> +#endif //DUNE_FUNCTIONS_COMMON_STATICFORLOOP_HH
>> 
>> _______________________________________________
>> Dune-functions-commit mailing list
>> Dune-functions-commit at dune-project.org
>> http://lists.dune-project.org/mailman/listinfo/dune-functions-commit
> 
> --
> Prof. Dr. Christian Engwer
> Institut für Numerische und Angewandte Mathematik
> Fachbereich Mathematik und Informatik der Universität Münster
> Einsteinstrasse 62
> 48149 Münster
> 
> E-Mail  christian.engwer at uni-muenster.de
> Telefon +49 251 83-35067
> FAX     +49 251 83-32729
> 
> _______________________________________________
> dune-functions mailing list
> dune-functions at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune-functions
> 

-------------- 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-functions/attachments/20150923/9f1eabfb/attachment.sig>


More information about the dune-functions mailing list