Menu

#8 Implicit Conversion Operators

Next Release
closed
None
5
2018-01-02
2015-05-04
Me
No

Adding implicit conversion operators from ValueArg<T> and SwitchArg to T and bool, respectively, would enable extracting the values from these arguments more concisely.

It is particularly handy for SwitchArg, in that it enables clean syntax like "if(switchOpt) { ... }".

Please see the attached diff for a proposed trivial implementation.

1 Attachments

Discussion

  • Daniel Aarno

    Daniel Aarno - 2015-05-10

    I tend to be a bit conservative when it comes to using operator overloading, and go the "less is more" path. However, I think in this case it could be warranted, at least the SwitchArg looks appealing to me. What's your thought mes5k?

     
  • Mike Smoot

    Mike Smoot - 2015-05-10

    I'm not familiar enough with implicit conversion operators to know if there are any "gotchas." However, if the correct implementation is as simple as the patch indicates, then I'd be fine with this.

     
  • Daniel Aarno

    Daniel Aarno - 2015-05-11
    • status: open --> accepted
    • assigned_to: Daniel Aarno
     
  • Daniel Aarno

    Daniel Aarno - 2015-05-11

    Added in b162f59fcbdeef31dffa212eea8def5bf138cfb0

     
  • Daniel Aarno

    Daniel Aarno - 2015-05-11
    • status: accepted --> closed
     

Log in to post a comment.