library defined typedef

Trass3r un at known.com
Thu Dec 2 10:52:00 PST 2010


Bump.

> We had a thread where a suggestion was made for a library defined  
> typedef:
>
> enum Type
> {
>      Independent,
>      Super,
>      Sub,
>      Parallel,
> }
>
> struct Typedef( T, Type type = Type.Sub, T init = T.init, string _f =  
> __FILE__, int _l = __LINE__ )
> {
>      T payload = init;
>
>      static if ( type != Type.Independent )
>      {
>          this( T value )
>          {
>              payload = value;
>          }
>      }
>      static if ( type == Type.Sub || type == Type.Parallel )
>      {
>          alias payload this;
>      }
>      static if ( type == Type.Super )
>      {
>          typeof( this ) opAssign( T value )
>          {
>              payload = value;
>              return this;
>          }
>      }
>      else static if ( type == Type.Sub )
>      {
>          @disable void opAssign( T value );
>      }
> }
>
> One problem is it still lacks proper support for explicit and implicit  
> casting.
> But will it be included in typecons?
> I certainly need a proper solution to this for my coding.


More information about the Digitalmars-d mailing list