Something like that?

struct PrimitiveRef(T)
{
        private T* _value;

        @property
        ref inout(T) get() inout pure nothrow {
                assert(_value);
                
                return *_value;
        }
        
        alias get this;
        
        this(T val) {
                _value = new T(val);
        }
}

alias BoolRef = PrimitiveRef!bool;

void test(BoolRef b)
{
        b = true;
}

void main()
{
        BoolRef b = false;
        test(b);
        assert(b == true);      
}

Reply via email to