generic_visitor constructor with perfect forwarding