Opened 9 years ago

Last modified 9 years ago

#8989 new Feature Requests

asio::ip namespace issues, and proposed solution

Reported by: vinnie.falco@… Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
Version: Boost 1.54.0 Severity: Problem
Keywords: Cc:

Description

Given an InternetProtocol (usually ip::tcp), there's no generic way to get access to these classes:

class boost::asio::ip::address_v4;
class boost::asio::ip::address_v6;

The reason is that boost::tcp::ip is a namespace and not a type.

I propose adding these to the requirements for InternetProtocol:

X::address_v4, return type boost::asio::ip::address_v4
X::address_v6, return type boost::asio::ip::address_v6

This would enable template classes parameterized on InternetProtocol to be able to choose an address type. For example:

template <typename InternetProtcol>
struct Details
{
    typedef InternetProtocol          protocol_type;
    typedef protocol_type::endpoint   endpoint_type;

    // Good, with this proposal
    typedef protocol_type::address_v4 address_v4;
    endpoint_type get_endpoint ()
    {
        return endpoint_type (address_v4::any (), 1053);
    }

    // Bad, the only current solution
    typedef boost::asio::ip::address_v4 address_v4;
    endpoint_type get_endpoint_bad ()
    {
        return endpoint_type (address_v4::any (), 1053);
    }
};

Change History (1)

comment:1 by viboes, 9 years ago

Component: Noneasio
Owner: set to chris_kohlhoff
Note: See TracTickets for help on using tickets.