Boost logo

Boost Users :

Subject: Re: [Boost-users] [GIL] Why does 'get_color' take a tag object instead of its type only?
From: Mateusz Loskot (mateusz_at_[hidden])
Date: 2013-01-29 11:42:45


On 29 January 2013 15:59, TONGARI <tongari95_at_[hidden]> wrote:
> 2013/1/29 Christian Henning <chhenning_at_[hidden]>
>>
>> By tag is useful when dealing with swapped channels, like rgb and bgr.
>> For instance when reading a bmp file I read it as bgr but the end user
>> most likely wants the rgb format.
>
>
> Uh... maybe I didn't express clearly.
> It's currently defined as:
>
> template <typename ColorBase, typename Color>
> get_color(ColorBase& cb, Color=Color())
>
> I just want to know why not just take Color by the type, e.g.
>
> template <typename Color, typename ColorBase>
> get_color(ColorBase& cb)

One of reasons, because then you couldn't utilise the fantastic
feature of template argument deduction.

Learn about "don't try help the compiler" principle from STL, at 10:00 min:
http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-2-of-n

Best regards,

--
Mateusz Loskot, http://mateusz.loskot.net

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net