Working on a library: request for code review

Rene Zwanenburg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jun 18 06:46:29 PDT 2014


On Wednesday, 18 June 2014 at 13:42:32 UTC, Rene Zwanenburg wrote:
> On Wednesday, 18 June 2014 at 09:41:01 UTC, Marc Schütz wrote:
>> On Tuesday, 17 June 2014 at 18:35:34 UTC, Mike wrote:
>>> Thanks, will work on fixes tonight.
>>>
>>>
>>>> The current method will not detect an error when the image 
>>>> type
>>>> is not mapped  but a color map is present.
>>>> At least I assume that is not a valid TGA file?
>>>
>>> A non-mapped image may contain a color map ;-0 it's simply 
>>> discarded.
>>>
>>>
>>> As per your ideas
>>>
>>>>return to!bool(isColorMapped(header)
>>>>                     ? header.colorMapDepth.among(16, 32)
>>>>                     : header.pixelDepth.among(16, 32));
>>>
>>> this is not nothrow, but as you can see there is nothing that 
>>> can ever throw.. so perhaps I'll stick to the cast(bool) 
>>> thing.. Any idea?
>>
>> Perhaps `return !!(...);` ?
>
> test

The web interface didn't work for me for about a day. It seems to 
be over now.

Yeah I didn't take nothrow into account. AFAIK using !!() to 
convert to bool in a context where it doesn't happen implicitly 
is indeed idiomatic. At least it's used in Phobos.


More information about the Digitalmars-d-learn mailing list