octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: templated bitwise operators


From: Jordi Gutiérrez Hermoso
Subject: Re: templated bitwise operators
Date: Fri, 25 May 2012 13:10:15 -0400

On 25 May 2012 12:59, c. <address@hidden> wrote:
>
> On 25 May 2012, at 17:51, Jordi Gutiérrez Hermoso wrote:
>
>> On 25 May 2012 11:22, c. <address@hidden> wrote:
>>> this changeset:
>>>
>>> changeset:   14631:57e4ff70b7c1
>>> user:        Jordi Gutiérrez Hermoso <address@hidden>
>>> date:        Sun May 13 21:17:19 2012 -0400
>>> summary:     Use more templates in bitwise operators. Death to macros! ☠
>>>
>>>
>>> introduced use of std::bit_and<T>, std::bit_or<T>, etc. which were
>>> introduced in gcc only in version 4.3. but I'm stuck with 4.2.1 on
>>> my system so that breaks the build for me ...
>>
>>> would it be OK to add a configure check to go back to the
>>> macro-based version if any of those templates is undefined?
>>
>> Death to macros! No more macros!
>>
>> How about defining those templates instead? They're all pretty simple,
>> e.g.:
>>
>>    template<typename T>
>>    T bit_and<T>(T a, T b)
>>    {
>>      return a & b;
>>    }
>>
>> This isn't exactly the same as std::bit_and, but I think it should
>> work for this case.

> OK, here is a changeset that works for me, shall I push it?

Looks good to me. This type of cross-platform correctness is something
jwe knows more about, so I'd like to see if he thinks this is ok.

Btw, the simpler template I suggested without operator() didn't work?
Perhaps with an inline keyword?

- Jordi G. H.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]