⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 variant_stream.hpp

📁 LINUX下
💻 HPP
📖 第 1 页 / 共 2 页
字号:
// Copyright Daniel Wallin and Arvid Norberg 2007.// Use, modification and distribution is// subject to the Boost Software License, Version 1.0. (See accompanying// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)#ifndef VARIANT_STREAM_070211_HPP# define VARIANT_STREAM_070211_HPP# include <boost/variant.hpp># include <boost/mpl/vector.hpp># include <boost/mpl/void.hpp># include <boost/mpl/remove.hpp># include <boost/mpl/transform.hpp># include <boost/mpl/size.hpp># include <boost/preprocessor/repetition/enum_params.hpp># include <boost/preprocessor/repetition/enum_binary_params.hpp># include <boost/preprocessor/facilities/intercept.hpp># include <boost/type_traits/add_pointer.hpp># include <boost/noncopyable.hpp>#include <asio/io_service.hpp># define NETWORK_VARIANT_STREAM_LIMIT 5namespace libtorrent {namespace aux{  struct delete_visitor    : boost::static_visitor<>  {      template <class T>      void operator()(T* p) const      {          delete p;      }      void operator()(boost::blank) const      {}  };// -------------- io_control -----------  template<class IO_Control_Command>  struct io_control_visitor_ec: boost::static_visitor<>  {      io_control_visitor_ec(IO_Control_Command& ioc, asio::error_code& ec_)          : ioc(ioc), ec(ec_) {}      template <class T>      void operator()(T* p) const      {          p->io_control(ioc, ec);      }      void operator()(boost::blank) const      {}      IO_Control_Command& ioc;		asio::error_code& ec;  };  template<class IO_Control_Command>  struct io_control_visitor      : boost::static_visitor<>  {      io_control_visitor(IO_Control_Command& ioc)          : ioc(ioc) {}      template <class T>      void operator()(T* p) const      {          p->io_control(ioc);      }      void operator()(boost::blank) const      {}      IO_Control_Command& ioc;  };// -------------- async_connect -----------  template <class EndpointType, class Handler>  struct async_connect_visitor    : boost::static_visitor<>  {      async_connect_visitor(EndpointType const& endpoint, Handler const& handler)        : endpoint(endpoint)        , handler(handler)      {}      template <class T>      void operator()(T* p) const      {          p->async_connect(endpoint, handler);      }      void operator()(boost::blank) const      {}      EndpointType const& endpoint;      Handler const& handler;  };// -------------- bind -----------  template <class EndpointType>  struct bind_visitor_ec    : boost::static_visitor<>  {      bind_visitor_ec(EndpointType const& ep, asio::error_code& ec_)        : endpoint(ep)        , ec(ec_)      {}      template <class T>      void operator()(T* p) const      { p->bind(endpoint, ec); }      void operator()(boost::blank) const {}      EndpointType const& endpoint;		asio::error_code& ec;  };  template <class EndpointType>  struct bind_visitor    : boost::static_visitor<>  {      bind_visitor(EndpointType const& ep)        : endpoint(ep)      {}      template <class T>      void operator()(T* p) const      { p->bind(endpoint); }      void operator()(boost::blank) const {}      EndpointType const& endpoint;  };// -------------- open -----------  template <class Protocol>  struct open_visitor_ec    : boost::static_visitor<>  {      open_visitor_ec(Protocol const& p, asio::error_code& ec_)        : proto(p)        , ec(ec_)      {}      template <class T>      void operator()(T* p) const      { p->open(proto, ec); }      void operator()(boost::blank) const {}      Protocol const& proto;		asio::error_code& ec;  };  template <class Protocol>  struct open_visitor    : boost::static_visitor<>  {      open_visitor(Protocol const& p)        : proto(p)      {}      template <class T>      void operator()(T* p) const      { p->open(proto); }      void operator()(boost::blank) const {}      Protocol const& proto;  };// -------------- close -----------  struct close_visitor_ec    : boost::static_visitor<>  {      close_visitor_ec(asio::error_code& ec_)        : ec(ec_)      {}      template <class T>      void operator()(T* p) const      { p->close(ec); }      void operator()(boost::blank) const {}		asio::error_code& ec;  };  struct close_visitor    : boost::static_visitor<>  {      template <class T>      void operator()(T* p) const      { p->close(); }      void operator()(boost::blank) const {}  };// -------------- remote_endpoint -----------  template <class EndpointType>  struct remote_endpoint_visitor_ec    : boost::static_visitor<EndpointType>  {      remote_endpoint_visitor_ec(asio::error_code& ec)        : error_code(ec)      {}      template <class T>      EndpointType operator()(T* p) const      { return p->remote_endpoint(error_code); }      EndpointType operator()(boost::blank) const      { return EndpointType(); }		asio::error_code& error_code;  };  template <class EndpointType>  struct remote_endpoint_visitor    : boost::static_visitor<EndpointType>  {      template <class T>      EndpointType operator()(T* p) const      { return p->remote_endpoint(); }      EndpointType operator()(boost::blank) const      { return EndpointType(); }  };// -------------- local_endpoint -----------  template <class EndpointType>  struct local_endpoint_visitor_ec    : boost::static_visitor<EndpointType>  {      local_endpoint_visitor_ec(asio::error_code& ec)        : error_code(ec)      {}      template <class T>      EndpointType operator()(T* p) const      {          return p->local_endpoint(error_code);      }      EndpointType operator()(boost::blank) const      {          return EndpointType();      }		asio::error_code& error_code;  };  template <class EndpointType>  struct local_endpoint_visitor    : boost::static_visitor<EndpointType>  {      template <class T>      EndpointType operator()(T* p) const      {          return p->local_endpoint();      }      EndpointType operator()(boost::blank) const      {          return EndpointType();      }  };// -------------- async_read_some -----------  template <class Mutable_Buffers, class Handler>  struct async_read_some_visitor    : boost::static_visitor<>  {      async_read_some_visitor(Mutable_Buffers const& buffers, Handler const& handler)        : buffers(buffers)        , handler(handler)      {}      template <class T>      void operator()(T* p) const      {          p->async_read_some(buffers, handler);      }      void operator()(boost::blank) const      {}      Mutable_Buffers const& buffers;      Handler const& handler;  };// -------------- read_some -----------  template <class Mutable_Buffers>  struct read_some_visitor    : boost::static_visitor<std::size_t>  {      read_some_visitor(Mutable_Buffers const& buffers)        : buffers(buffers)      {}      template <class T>      std::size_t operator()(T* p) const      { return p->read_some(buffers); }		std::size_t operator()(boost::blank) const      { return 0; }      Mutable_Buffers const& buffers;  };  template <class Mutable_Buffers>  struct read_some_visitor_ec    : boost::static_visitor<std::size_t>  {      read_some_visitor_ec(Mutable_Buffers const& buffers, asio::error_code& ec_)        : buffers(buffers)        , ec(ec_)      {}      template <class T>      std::size_t operator()(T* p) const      { return p->read_some(buffers, ec); }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -