[Dune] [Dune-Commit] dune-common r7037 - trunk/dune/common

Martin Nolte nolte at mathematik.uni-freiburg.de
Sun Oct 14 00:13:43 CEST 2012


Hi Oli,

unfortunately, T has to come before m. The change allows for T = unsigned long 
long (which can take values greater than an enum). It also allows setting T = 
char and using the overflow on purpose.

Finally, it is in line with the stl integral_constant.

Sorry about sending the file directly. I'll send a patch next time.

Best,

Martin

On 10/13/2012 09:42 PM, Oliver Sander wrote:
> Hi Martin,
>
>> I like your new solution. It's clean and we can deprecate the original
>> implementation.
>>
> credits actually go to Christoph. He nagged me long enough to change this.
>
>> Since we are changing the implementation, I have a small suggestions
>> (attached).
>>
> So basically you suggest an additional obligatory template parameter to
> be able also take powers of integer number types that are not 'int'?
> I don't mind, but how about
>
> StaticPower< T m, int p, class T=int >
>
> instead? (Does that even work?)
>
> Please send me a patch rather than a file next time.
>
> best,
> Oliver
>
>> Best,
>>
>> Martin
>>
>> On 10/13/2012 09:11 PM, sander at dune-project.org wrote:
>>> Author: sander
>>> Date: 2012-10-13 21:11:40 +0200 (Sat, 13 Oct 2012)
>>> New Revision: 7037
>>>
>>> Modified:
>>> trunk/dune/common/power.hh
>>> Log:
>>> Rename Power_m_p to StaticPower, which is a bit more telling, and
>>> conforms better to the Dune naming scheme
>>>
>>> Modified: trunk/dune/common/power.hh
>>> ===================================================================
>>> --- trunk/dune/common/power.hh 2012-10-13 19:09:45 UTC (rev 7036)
>>> +++ trunk/dune/common/power.hh 2012-10-13 19:11:40 UTC (rev 7037)
>>> @@ -16,15 +16,15 @@
>>>
>>> //! Calculates m^p at compile time
>>> template<int m, int p>
>>> - struct Power_m_p
>>> + struct StaticPower
>>> {
>>> /** \brief power stores m^p */
>>> - enum { power = (m * Power_m_p<m,p-1>::power ) };
>>> + enum { power = (m * StaticPower<m,p-1>::power ) };
>>> };
>>>
>>> //! end of recursion via specialization
>>> template<int m>
>>> - struct Power_m_p< m , 0>
>>> + struct StaticPower< m , 0>
>>> {
>>> /** \brief m^0 = 1 */
>>> enum { power = 1 };
>>>
>>>
>>> _______________________________________________
>>> Dune-Commit mailing list
>>> Dune-Commit at dune-project.org
>>> http://lists.dune-project.org/mailman/listinfo/dune-commit
>>
>>
>>
>> _______________________________________________
>> Dune mailing list
>> Dune at dune-project.org
>> http://lists.dune-project.org/mailman/listinfo/dune

-- 
Dr. Martin Nolte <nolte at mathematik.uni-freiburg.de>

Universität Freiburg                                   phone: +49-761-203-5630
Abteilung für angewandte Mathematik                    fax:   +49-761-203-5632
Hermann-Herder-Straße 10
79104 Freiburg, Germany




More information about the Dune mailing list