Replace static_cast by static_as() in as()