Return types of the methods of a struct

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jun 19 06:38:46 PDT 2015


On 6/19/15 9:27 AM, Quentin Ladeveze wrote:
> On Friday, 19 June 2015 at 13:26:03 UTC, Steven Schveighoffer wrote:
>> On 6/19/15 9:13 AM, Quentin Ladeveze wrote:
>>> On Friday, 19 June 2015 at 13:12:08 UTC, Quentin Ladeveze wrote:
>>>> Hi,
>>>>
>>>>   I have a struct with some methods int it, let's say
>>>>
>>>> ```
>>>> struct Example{
>>>>    int intValue(){
>>>
>>> Hum. How can I delete a post ?
>>
>> You can't. The forum is backed by a newsgroup, just post the full
>> corrected version :)
>>
>> -Steve
>
> Thank you :)
>
> Here is th corrected version :
>
> Hi,
>
>    I have a struct with some methods int it, let's say
>
> ```
> struct Example{
>     int a(){
>           return someValue;
>     }
>
>     float b(){
>        return someOtherValue;
>     }
>
>     string stringValue(){
>        return c;
>     }
> }
>
> Is there any way to have a asTuple method in this struct that would
> returns something like :
>
> Tuple!(int, "a", float, "b", string, "c")
>
> and that will contain the values of the methods of the struct ?

Does this work for you, or is there a further expectation?

auto asTuple() { return Tuple!(int, "a", ...)(a, b, stringValue);}

-Steve


More information about the Digitalmars-d-learn mailing list