Why tuples? [was: Why tuple Re: Why are unsigned to signed conversions implicit...?]

spir denis.spir at gmail.com
Mon Apr 11 00:22:50 PDT 2011


On 04/11/2011 01:47 AM, Andrej Mitrovic wrote:
> alias Tuple!(byte, "red", byte, "green", byte, "blue") RGBTuple;
>
> RGBTuple GetRGB(COLORREF cref)
> {
>      RGBTuple rgb;
>      rgb.red   = GetRValue(cref);
>      rgb.green = GetGValue(cref);
>      rgb.blue  = GetBValue(cref);
>
>      return rgb;
> }

[O your T]
Hello, andrej,

I'm trying to understand why people use tuples (outside multiple return values 
and variadic typetuples). Why do you prefere the above to:

struct RGBColor { byte red, green, blue; }

RGRColor GetRGB (COLORREF cref)
{
      RGBColor rgb;
      rgb.red   = GetRValue(cref);
      rgb.green = GetGValue(cref);
      rgb.blue  = GetBValue(cref);
      return rgb;
}

?
[/O your T]

Denis
-- 
_________________
vita es estrany
spir.wikidot.com



More information about the Digitalmars-d-learn mailing list