[Boost-bugs] [Boost C++ Libraries] #8989: asio::ip namespace issues, and proposed solution

Subject: [Boost-bugs] [Boost C++ Libraries] #8989: asio::ip namespace issues, and proposed solution
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-08-09 15:22:47


#8989: asio::ip namespace issues, and proposed solution
----------------------------+------------------------------
 Reporter: vinnie.falco@… | Type: Feature Requests
   Status: new | Milestone: To Be Determined
Component: None | Version: Boost 1.54.0
 Severity: Problem | Keywords:
----------------------------+------------------------------
 Given an
 [http://www.boost.org/doc/libs/1_54_0/doc/html/boost_asio/reference/InternetProtocol.html
 InternetProtocol] (usually
 [http://www.boost.org/doc/libs/1_54_0/doc/html/boost_asio/reference/ip__tcp.html
 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
 [http://www.boost.org/doc/libs/1_54_0/doc/html/boost_asio/reference/InternetProtocol.html
 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
 [http://www.boost.org/doc/libs/1_54_0/doc/html/boost_asio/reference/InternetProtocol.html
 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);
     }
 };
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8989>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:13 UTC