[Dune-devel] [Dune-Commit] dune-common r7032 - trunk/dune/common
Oliver Sander
sander at mi.fu-berlin.de
Wed Oct 10 14:42:06 CEST 2012
Hi Matthias,
well, in this case there are two feet and I got to choose in which one to
shoot. If there is no warning then people will never receive a hint that
the Power_m_p class has moved to another file (unless they read the
documentation,
of course). So working code will fail to compile eventually.
My compromise plan was to have the warning, but only for a limited time
(say, two weeks). This way, at least people working on the trunk are
warned,
but the annoyance is only temporary.
best,
Oliver
Am 10.10.2012 14:34, schrieb Matthias Wohlmuth:
> Hi, is the warning really necessary? I now get several warnings just by
> the yaspgrid.hh include statements :-(
>
> Best,
> Matthias
>
>
> Am 10/09/2012 06:16 PM, schrieb sander at dune-project.org:
>> Author: sander
>> Date: 2012-10-09 18:16:27 +0200 (Tue, 09 Oct 2012)
>> New Revision: 7032
>>
>> Added:
>> trunk/dune/common/power.hh
>> Modified:
>> trunk/dune/common/Makefile.am
>> trunk/dune/common/misc.hh
>> Log:
>> Add a new header power.hh for static computations of the power functions
>>
>> There are lots of power implementations all over our code.
>> This is the first step of some cleanup. It moves the class Power_m_p
>> from misc.hh (like who's ever gonna find it there...) to a separate
>> header power.hh. Other implementations will be collected there as
>> well, if appropriate.
>>
>> With the patch, including misc.hh will issue a cpp warning that people
>> who include misc.hh only for Power_m_p should now include power.hh
>> instead. This is not great, because it also affects people who include
>> misc.hh for something else. Bear with this for a while; I couldn't
>> think of a better solution.
>>
>>
>> Modified: trunk/dune/common/Makefile.am
>> ===================================================================
>> --- trunk/dune/common/Makefile.am 2012-10-08 17:10:46 UTC (rev 7031)
>> +++ trunk/dune/common/Makefile.am 2012-10-09 16:16:27 UTC (rev 7032)
>> @@ -70,6 +70,7 @@
>> parametertreeparser.hh \
>> path.hh \
>> poolallocator.hh \
>> + power.hh \
>> precision.hh \
>> promotiontraits.hh \
>> propertymap.hh \
>>
>> Modified: trunk/dune/common/misc.hh
>> ===================================================================
>> --- trunk/dune/common/misc.hh 2012-10-08 17:10:46 UTC (rev 7031)
>> +++ trunk/dune/common/misc.hh 2012-10-09 16:16:27 UTC (rev 7032)
>> @@ -20,6 +20,8 @@
>> #include<dune/common/deprecated.hh>
>> #include "exceptions.hh"
>> #include<dune/common/typetraits.hh>
>> +#warning If you have included misc.hh only for the Power_m_p class
>> please include power.hh instead.
>> +#include<dune/common/power.hh>
>>
>> namespace Dune {
>>
>> @@ -65,22 +67,6 @@
>> return t*t;
>> }
>>
>> -//! Calculates m^p at compile time
>> -template<int m, int p>
>> -struct Power_m_p
>> -{
>> - // power stores m^p
>> - enum { power = (m * Power_m_p<m,p-1>::power ) };
>> -};
>> -
>> -//! end of recursion via specialization
>> -template<int m>
>> -struct Power_m_p< m , 0>
>> -{
>> - // m^0 = 1
>> - enum { power = 1 };
>> -};
>> -
>> //! Calculates the factorial of m at compile time
>> template<int m>
>> struct Factorial
>>
>> Added: trunk/dune/common/power.hh
>> ===================================================================
>> --- trunk/dune/common/power.hh (rev 0)
>> +++ trunk/dune/common/power.hh 2012-10-09 16:16:27 UTC (rev 7032)
>> @@ -0,0 +1,35 @@
>> +// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
>> +// vi: set ts=8 sw=2 et sts=2:
>> +#ifndef DUNE_COMMON_POWER_HH
>> +#define DUNE_COMMON_POWER_HH
>> +
>> +/** \file
>> + \brief Various implementations of the power function for run-time
>> and static arguments
>> +*/
>> +
>> +namespace Dune {
>> +
>> + /** @addtogroup Common
>> +
>> + @{
>> + */
>> +
>> + //! Calculates m^p at compile time
>> + template<int m, int p>
>> + struct Power_m_p
>> + {
>> + /** \brief power stores m^p */
>> + enum { power = (m * Power_m_p<m,p-1>::power ) };
>> + };
>> +
>> + //! end of recursion via specialization
>> + template<int m>
>> + struct Power_m_p< m , 0>
>> + {
>> + /** \brief m^0 = 1 */
>> + enum { power = 1 };
>> + };
>> +
>> +}
>> +
>> +#endif
>>
>>
>> _______________________________________________
>> Dune-Commit mailing list
>> Dune-Commit at dune-project.org
>> http://lists.dune-project.org/mailman/listinfo/dune-commit
>>
>
>
More information about the Dune-devel
mailing list