On 2014-06-19 3:11 PM, H. S. Teoh via Digitalmars-d wrote:

        safeDeref(obj).subobj.prop.field.failsafe!val(defaultVal)

where the last element is passed as an alias to the failsafe template,
which then does the .init-replacement magic. It looks a lot uglier,
though. :-(


T


meh, this works:


writeln(currAssignment.safeDeref.typeInfo.ident.or("meh"));

..
        static struct SafeDeref {
                T t;
                
                // Make the wrapper as transparent as possible.
                alias t this;

                // this overrides if null
                T or(T defVal){
                        if (t is t.init)
                        {
                                return defVal;
                        }
                        else
                        {
                                return t;
                        }
                        
                }
..

Reply via email to