www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Phobos enhancement: add method to convert UnknownAddressReference to

Many functions in std.socket, such as getAddress or parseAddress 
return the UnknownAddressReference Address subtype instead of 
InternetAddress or InternetAddress6.

While in many cases this is sufficient (e.g., when you just need 
to do Socket.sendTo), in some cases it is not, especially when 
accessing the specific addresses (like InternetAddress.addr) is 

Converting UnknownAddressReference into the proper non-opaque 
type requires messy casting in user code, exposing non-portable 
imports like core.sys.posix.netinet.in_:

Address address = getAddress("www.google.com",80);
if(address.addressFamily == AddressFamily.INET)
     address = new 
     address = new 

Can this be moved into a method of UnknownAddressReference?

Or, as a cleaner solution, have an abstract override method (like 
"subtype") in Address, which returns the proper subtype for 
UnknownAddressReference, and this for the other subtypes.
Jun 28 2016