Templates class member functions not conditional?

Jonathan M Davis jmdavisProg at gmx.com
Tue Sep 11 14:44:47 PDT 2012


On Tuesday, September 11, 2012 20:39:55 monarch_dodra wrote:
> Is one of these what you are suggesting?
> 
> //One
> static if(isAssignable!(T,T)) @property void front(T value)
> {
>      enforce(someCondition)
>      value = value;
> }
> 
> or
> 
> //Two
> static if(isAssignable!(T,T))
>      @property void front(T value)
> {
>      enforce(someCondition)
>      value = value;
> }
> 
> or
> 
> //Three
> static if(isAssignable!(T,T))
> @property void front(T value)
> {
>      enforce(someCondition)
>      value = value;
> }
> 
> 
> (or just plain)
> 
> //Four
> static if(isAssignable!(T,T))
> {
>      @property void front(T value)
>      {
>          enforce(someCondition)
>          value = value;
>      }
> }
> 
> Which do YOU think reads best in this case? That the style I'll
> use in my submit.
> 
> I like //Three because it reads like an attribute.
> 
> Of course, I have no problem submitting it with the default
> //Four if you think that is best. I'm just trying to do as best
> possible.

I'd use either one or four. I would definitely _not_ use three, precisely 
because it's using no indentation at all. Either the signature should be one 
line, or it needs indentation.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list