Frist Draft (in this forum): Enum Parameters
    IchorDev 
    zxinsworld at gmail.com
       
    Wed Jul 31 08:15:31 UTC 2024
    
    
  
On Thursday, 25 April 2024 at 17:56:59 UTC, Quirin Schroll wrote:
> **Abstract**
> On function templates, allow `enum` to be used as a function 
> parameter storage class and a member function attribute. 
> Arguments binding to `enum` parameters must be compile-time 
> constants, as if template value parameters. With `auto enum`, 
> “compile-time-ness” is determined from argument (cf. `auto 
> ref`) and queried via a trait.
I have been dying to have this feature in my hands for since I 
first read about it nearly 2 years ago. The fact that this DIP 
keeps getting left in limbo is very disappointing.
I’m a library author, I write a lot of compile-time code, and in 
private I have written my own `std.traits`-style library before. 
This DIP solves one of my most longstanding frustrations with 
writing functions that have a compile-time optimised variant. The 
possibility of enhancing IES is also really exciting. I haven’t 
commented on this DIP here until now because I actually didn’t 
notice this thread.
My only real gripe with the DIP is that `isEnum` should only work 
for enum parameters. Having it check for enum membership will 
surely create bugs in generic code somewhere.
    
    
More information about the dip.development
mailing list