import std.array;

interface Stack(T)
{
    @property bool empty();
    @property ref T top();
    void push(T value);
    void pop();
}

class StackImpl(T) : Stack!T
{
    private T[] _store;

    @property bool empty()
    {
        return _store.empty;
    }

    @property ref T top()
    {
        assert(!empty);
        return _store.back;
    }

    void push(T value)
    {
        _store ~= value;
    }

    void pop()
    {
        assert(!empty);
        _store.popBack();
    }
}

void main()
{
    auto stack = new StackImpl!int;
    assert(stack.empty);
    stack.push(3);
    assert(stack.top == 3);
    stack.push(5);
    assert(stack.top == 5);
    stack.pop();
    assert(stack.top == 3);
    stack.pop();
    assert(stack.empty);
}
