move typed_reference into a new header