Skip to content

Commit e182d9d

Browse files
committed
更新ASIO
1 parent 0fd1dd0 commit e182d9d

26 files changed

+303
-139
lines changed

include/asio/buffer.hpp

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <string>
2424
#include <vector>
2525
#include "asio/detail/array_fwd.hpp"
26-
#include "asio/detail/is_buffer_sequence.hpp"
2726
#include "asio/detail/string_view.hpp"
2827
#include "asio/detail/throw_exception.hpp"
2928
#include "asio/detail/type_traits.hpp"
@@ -346,41 +345,6 @@ class const_buffers_1
346345

347346
#endif // !defined(ASIO_NO_DEPRECATED)
348347

349-
/// Trait to determine whether a type satisfies the MutableBufferSequence
350-
/// requirements.
351-
template <typename T>
352-
struct is_mutable_buffer_sequence
353-
#if defined(GENERATING_DOCUMENTATION)
354-
: integral_constant<bool, automatically_determined>
355-
#else // defined(GENERATING_DOCUMENTATION)
356-
: asio::detail::is_buffer_sequence<T, mutable_buffer>
357-
#endif // defined(GENERATING_DOCUMENTATION)
358-
{
359-
};
360-
361-
/// Trait to determine whether a type satisfies the ConstBufferSequence
362-
/// requirements.
363-
template <typename T>
364-
struct is_const_buffer_sequence
365-
#if defined(GENERATING_DOCUMENTATION)
366-
: integral_constant<bool, automatically_determined>
367-
#else // defined(GENERATING_DOCUMENTATION)
368-
: asio::detail::is_buffer_sequence<T, const_buffer>
369-
#endif // defined(GENERATING_DOCUMENTATION)
370-
{
371-
};
372-
373-
/// Trait to determine whether a type satisfies the DynamicBuffer requirements.
374-
template <typename T>
375-
struct is_dynamic_buffer
376-
#if defined(GENERATING_DOCUMENTATION)
377-
: integral_constant<bool, automatically_determined>
378-
#else // defined(GENERATING_DOCUMENTATION)
379-
: asio::detail::is_dynamic_buffer<T>
380-
#endif // defined(GENERATING_DOCUMENTATION)
381-
{
382-
};
383-
384348
/// (Deprecated: Use the socket/descriptor wait() and async_wait() member
385349
/// functions.) An implementation of both the ConstBufferSequence and
386350
/// MutableBufferSequence concepts to represent a null buffer sequence.
@@ -1403,7 +1367,7 @@ inline ASIO_MUTABLE_BUFFER buffer(
14031367
);
14041368
}
14051369

1406-
/// Create a new non-modifiable buffer that represents the given string.
1370+
/// Create a new modifiable buffer that represents the given string.
14071371
/**
14081372
* @returns A mutable_buffer value equivalent to:
14091373
* @code mutable_buffer(
@@ -2157,6 +2121,49 @@ inline std::size_t buffer_copy(const MutableBufferSequence& target,
21572121

21582122
} // namespace asio
21592123

2124+
#include "asio/detail/pop_options.hpp"
2125+
#include "asio/detail/is_buffer_sequence.hpp"
2126+
#include "asio/detail/push_options.hpp"
2127+
2128+
namespace asio {
2129+
2130+
/// Trait to determine whether a type satisfies the MutableBufferSequence
2131+
/// requirements.
2132+
template <typename T>
2133+
struct is_mutable_buffer_sequence
2134+
#if defined(GENERATING_DOCUMENTATION)
2135+
: integral_constant<bool, automatically_determined>
2136+
#else // defined(GENERATING_DOCUMENTATION)
2137+
: asio::detail::is_buffer_sequence<T, mutable_buffer>
2138+
#endif // defined(GENERATING_DOCUMENTATION)
2139+
{
2140+
};
2141+
2142+
/// Trait to determine whether a type satisfies the ConstBufferSequence
2143+
/// requirements.
2144+
template <typename T>
2145+
struct is_const_buffer_sequence
2146+
#if defined(GENERATING_DOCUMENTATION)
2147+
: integral_constant<bool, automatically_determined>
2148+
#else // defined(GENERATING_DOCUMENTATION)
2149+
: asio::detail::is_buffer_sequence<T, const_buffer>
2150+
#endif // defined(GENERATING_DOCUMENTATION)
2151+
{
2152+
};
2153+
2154+
/// Trait to determine whether a type satisfies the DynamicBuffer requirements.
2155+
template <typename T>
2156+
struct is_dynamic_buffer
2157+
#if defined(GENERATING_DOCUMENTATION)
2158+
: integral_constant<bool, automatically_determined>
2159+
#else // defined(GENERATING_DOCUMENTATION)
2160+
: asio::detail::is_dynamic_buffer<T>
2161+
#endif // defined(GENERATING_DOCUMENTATION)
2162+
{
2163+
};
2164+
2165+
} // namespace asio
2166+
21602167
#include "asio/detail/pop_options.hpp"
21612168

21622169
#endif // ASIO_BUFFER_HPP

include/asio/connect.hpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ struct is_endpoint_sequence
5858
/**
5959
* @defgroup connect asio::connect
6060
*
61-
* @brief Establishes a socket connection by trying each endpoint in a sequence.
61+
* @brief The @c connect function is a composed operation that establishes a
62+
* socket connection by trying each endpoint in a sequence.
6263
*/
6364
/*@{*/
6465

@@ -131,8 +132,8 @@ typename Protocol::endpoint connect(
131132
EndpointSequence>::value>::type* = 0);
132133

133134
#if !defined(ASIO_NO_DEPRECATED)
134-
/// (Deprecated.) Establishes a socket connection by trying each endpoint in a
135-
/// sequence.
135+
/// (Deprecated: Use range overload.) Establishes a socket connection by trying
136+
/// each endpoint in a sequence.
136137
/**
137138
* This function attempts to connect a socket to one of a sequence of
138139
* endpoints. It does this by repeated calls to the socket's @c connect member
@@ -159,8 +160,8 @@ template <typename Protocol ASIO_SVC_TPARAM, typename Iterator>
159160
Iterator connect(basic_socket<Protocol ASIO_SVC_TARG>& s, Iterator begin,
160161
typename enable_if<!is_endpoint_sequence<Iterator>::value>::type* = 0);
161162

162-
/// (Deprecated.) Establishes a socket connection by trying each endpoint in a
163-
/// sequence.
163+
/// (Deprecated: Use range overload.) Establishes a socket connection by trying
164+
/// each endpoint in a sequence.
164165
/**
165166
* This function attempts to connect a socket to one of a sequence of
166167
* endpoints. It does this by repeated calls to the socket's @c connect member
@@ -386,8 +387,8 @@ typename Protocol::endpoint connect(
386387
EndpointSequence>::value>::type* = 0);
387388

388389
#if !defined(ASIO_NO_DEPRECATED)
389-
/// (Deprecated.) Establishes a socket connection by trying each endpoint in a
390-
/// sequence.
390+
/// (Deprecated: Use range overload.) Establishes a socket connection by trying
391+
/// each endpoint in a sequence.
391392
/**
392393
* This function attempts to connect a socket to one of a sequence of
393394
* endpoints. It does this by repeated calls to the socket's @c connect member
@@ -427,8 +428,8 @@ Iterator connect(basic_socket<Protocol ASIO_SVC_TARG>& s,
427428
Iterator begin, ConnectCondition connect_condition,
428429
typename enable_if<!is_endpoint_sequence<Iterator>::value>::type* = 0);
429430

430-
/// (Deprecated.) Establishes a socket connection by trying each endpoint in a
431-
/// sequence.
431+
/// (Deprecated: Use range overload.) Establishes a socket connection by trying
432+
/// each endpoint in a sequence.
432433
/**
433434
* This function attempts to connect a socket to one of a sequence of
434435
* endpoints. It does this by repeated calls to the socket's @c connect member
@@ -602,8 +603,8 @@ Iterator connect(basic_socket<Protocol ASIO_SVC_TARG>& s,
602603
/**
603604
* @defgroup async_connect asio::async_connect
604605
*
605-
* @brief Asynchronously establishes a socket connection by trying each
606-
* endpoint in a sequence.
606+
* @brief The @c async_connect function is a composed asynchronous operation
607+
* that establishes a socket connection by trying each endpoint in a sequence.
607608
*/
608609
/*@{*/
609610

@@ -679,8 +680,8 @@ async_connect(basic_socket<Protocol ASIO_SVC_TARG>& s,
679680
EndpointSequence>::value>::type* = 0);
680681

681682
#if !defined(ASIO_NO_DEPRECATED)
682-
/// (Deprecated.) Asynchronously establishes a socket connection by trying each
683-
/// endpoint in a sequence.
683+
/// (Deprecated: Use range overload.) Asynchronously establishes a socket
684+
/// connection by trying each endpoint in a sequence.
684685
/**
685686
* This function attempts to connect a socket to one of a sequence of
686687
* endpoints. It does this by repeated calls to the socket's @c async_connect
@@ -886,8 +887,8 @@ async_connect(basic_socket<Protocol ASIO_SVC_TARG>& s,
886887
EndpointSequence>::value>::type* = 0);
887888

888889
#if !defined(ASIO_NO_DEPRECATED)
889-
/// (Deprecated.) Asynchronously establishes a socket connection by trying each
890-
/// endpoint in a sequence.
890+
/// (Deprecated: Use range overload.) Asynchronously establishes a socket
891+
/// connection by trying each endpoint in a sequence.
891892
/**
892893
* This function attempts to connect a socket to one of a sequence of
893894
* endpoints. It does this by repeated calls to the socket's @c async_connect

include/asio/detail/config.hpp

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@
7070
# define ASIO_MSVC _MSC_VER
7171
# endif // defined(ASIO_HAS_BOOST_CONFIG) && defined(BOOST_MSVC)
7272
#endif // !defined(ASIO_MSVC)
73-
#if defined(ASIO_MSVC)
74-
# include <ciso646> // Needed for _HAS_CXX17.
75-
#endif // defined(ASIO_MSVC)
7673

7774
// Clang / libc++ detection.
7875
#if defined(__clang__)
@@ -111,6 +108,14 @@
111108
# define ASIO_HAS_MOVE 1
112109
# endif // (_MSC_VER >= 1700)
113110
# endif // defined(ASIO_MSVC)
111+
# if defined(__INTEL_CXX11_MODE__)
112+
# if defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1500)
113+
# define BOOST_ASIO_HAS_MOVE 1
114+
# endif // defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1500)
115+
# if defined(__ICL) && (__ICL >= 1500)
116+
# define BOOST_ASIO_HAS_MOVE 1
117+
# endif // defined(__ICL) && (__ICL >= 1500)
118+
# endif // defined(__INTEL_CXX11_MODE__)
114119
# endif // !defined(ASIO_DISABLE_MOVE)
115120
#endif // !defined(ASIO_HAS_MOVE)
116121

@@ -229,7 +234,7 @@
229234
// Support noexcept on compilers known to allow it.
230235
#if !defined(ASIO_NOEXCEPT)
231236
# if !defined(ASIO_DISABLE_NOEXCEPT)
232-
# if (BOOST_VERSION >= 105300)
237+
# if defined(ASIO_HAS_BOOST_CONFIG) && (BOOST_VERSION >= 105300)
233238
# define ASIO_NOEXCEPT BOOST_NOEXCEPT
234239
# define ASIO_NOEXCEPT_OR_NOTHROW BOOST_NOEXCEPT_OR_NOTHROW
235240
# elif defined(__clang__)
@@ -761,9 +766,7 @@
761766
# if defined(__GNUC__)
762767
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4)
763768
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
764-
# if defined(_GLIBCXX_HAS_GTHREADS)
765-
# define ASIO_HAS_STD_FUTURE 1
766-
# endif // defined(_GLIBCXX_HAS_GTHREADS)
769+
# define ASIO_HAS_STD_FUTURE 1
767770
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
768771
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4)
769772
# endif // defined(__GNUC__)
@@ -779,23 +782,29 @@
779782
#if !defined(ASIO_HAS_STD_STRING_VIEW)
780783
# if !defined(ASIO_DISABLE_STD_STRING_VIEW)
781784
# if defined(__clang__)
782-
# if (__cplusplus >= 201703)
783-
# if __has_include(<string_view>)
784-
# define ASIO_HAS_STD_STRING_VIEW 1
785-
# endif // __has_include(<string_view>)
786-
# endif // (__cplusplus >= 201703)
787-
# endif // defined(__clang__)
788-
# if defined(__GNUC__)
785+
# if defined(ASIO_HAS_CLANG_LIBCXX)
786+
# if (__cplusplus >= 201402)
787+
# if __has_include(<string_view>)
788+
# define ASIO_HAS_STD_STRING_VIEW 1
789+
# endif // __has_include(<string_view>)
790+
# endif // (__cplusplus >= 201402)
791+
# else // defined(ASIO_HAS_CLANG_LIBCXX)
792+
# if (__cplusplus >= 201703)
793+
# if __has_include(<string_view>)
794+
# define ASIO_HAS_STD_STRING_VIEW 1
795+
# endif // __has_include(<string_view>)
796+
# endif // (__cplusplus >= 201703)
797+
# endif // defined(ASIO_HAS_CLANG_LIBCXX)
798+
# elif defined(__GNUC__)
789799
# if (__GNUC__ >= 7)
790800
# if (__cplusplus >= 201703)
791801
# define ASIO_HAS_STD_STRING_VIEW 1
792802
# endif // (__cplusplus >= 201703)
793803
# endif // (__GNUC__ >= 7)
794-
# endif // defined(__GNUC__)
795-
# if defined(ASIO_MSVC)
796-
# if (_MSC_VER >= 1910 && _HAS_CXX17)
797-
# define ASIO_HAS_STD_STRING_VIEW
798-
# endif // (_MSC_VER >= 1910 && _HAS_CXX17)
804+
# elif defined(ASIO_MSVC)
805+
# if (_MSC_VER >= 1910 && _MSVC_LANG >= 201703)
806+
# define ASIO_HAS_STD_STRING_VIEW 1
807+
# endif // (_MSC_VER >= 1910 && _MSVC_LANG >= 201703)
799808
# endif // defined(ASIO_MSVC)
800809
# endif // !defined(ASIO_DISABLE_STD_STRING_VIEW)
801810
#endif // !defined(ASIO_HAS_STD_STRING_VIEW)
@@ -804,11 +813,21 @@
804813
#if !defined(ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
805814
# if !defined(ASIO_DISABLE_STD_EXPERIMENTAL_STRING_VIEW)
806815
# if defined(__clang__)
807-
# if (__cplusplus >= 201402)
808-
# if __has_include(<experimental/string_view>)
809-
# define ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW 1
810-
# endif // __has_include(<experimental/string_view>)
811-
# endif // (__cplusplus >= 201402)
816+
# if defined(ASIO_HAS_CLANG_LIBCXX)
817+
# if (_LIBCPP_VERSION < 7000)
818+
# if (__cplusplus >= 201402)
819+
# if __has_include(<experimental/string_view>)
820+
# define ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW 1
821+
# endif // __has_include(<experimental/string_view>)
822+
# endif // (__cplusplus >= 201402)
823+
# endif // (_LIBCPP_VERSION < 7000)
824+
# else // defined(ASIO_HAS_CLANG_LIBCXX)
825+
# if (__cplusplus >= 201402)
826+
# if __has_include(<experimental/string_view>)
827+
# define ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW 1
828+
# endif // __has_include(<experimental/string_view>)
829+
# endif // (__cplusplus >= 201402)
830+
# endif // // defined(ASIO_HAS_CLANG_LIBCXX)
812831
# endif // defined(__clang__)
813832
# if defined(__GNUC__)
814833
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 9)) || (__GNUC__ > 4)
@@ -853,9 +872,9 @@
853872
#if !defined(ASIO_HAS_STD_INVOKE_RESULT)
854873
# if !defined(ASIO_DISABLE_STD_INVOKE_RESULT)
855874
# if defined(ASIO_MSVC)
856-
# if (_MSC_VER >= 1910 && _HAS_CXX17)
875+
# if (_MSC_VER >= 1911 && _MSVC_LANG >= 201703)
857876
# define ASIO_HAS_STD_INVOKE_RESULT 1
858-
# endif // (_MSC_VER >= 1910 && _HAS_CXX17)
877+
# endif // (_MSC_VER >= 1911 && _MSVC_LANG >= 201703)
859878
# endif // defined(ASIO_MSVC)
860879
# endif // !defined(ASIO_DISABLE_STD_INVOKE_RESULT)
861880
#endif // !defined(ASIO_HAS_STD_INVOKE_RESULT)

include/asio/detail/future.hpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// detail/future.hpp
3+
// ~~~~~~~~~~~~~~~~~
4+
//
5+
// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6+
//
7+
// Distributed under the Boost Software License, Version 1.0. (See accompanying
8+
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9+
//
10+
11+
#ifndef ASIO_DETAIL_FUTURE_HPP
12+
#define ASIO_DETAIL_FUTURE_HPP
13+
14+
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15+
# pragma once
16+
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17+
18+
#include "asio/detail/config.hpp"
19+
#if defined(ASIO_HAS_STD_FUTURE)
20+
# include <future>
21+
// Even though the future header is available, libstdc++ may not implement the
22+
// std::future class itself. However, we need to have already included the
23+
// future header to reliably test for _GLIBCXX_HAS_GTHREADS.
24+
# if defined(__GNUC__) && !defined(ASIO_HAS_CLANG_LIBCXX)
25+
# if defined(_GLIBCXX_HAS_GTHREADS)
26+
# define ASIO_HAS_STD_FUTURE_CLASS 1
27+
# endif // defined(_GLIBCXX_HAS_GTHREADS)
28+
# else // defined(__GNUC__) && !defined(ASIO_HAS_CLANG_LIBCXX)
29+
# define ASIO_HAS_STD_FUTURE_CLASS 1
30+
# endif // defined(__GNUC__) && !defined(ASIO_HAS_CLANG_LIBCXX)
31+
#endif // defined(ASIO_HAS_STD_FUTURE)
32+
33+
#endif // ASIO_DETAIL_FUTURE_HPP

include/asio/detail/impl/socket_ops.ipp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2114,7 +2114,7 @@ const char* inet_ntop(int af, const void* src, char* dest, size_t length,
21142114
if (result != 0 && af == ASIO_OS_DEF(AF_INET6) && scope_id != 0)
21152115
{
21162116
using namespace std; // For strcat and sprintf.
2117-
char if_name[IF_NAMESIZE + 1] = "%";
2117+
char if_name[(IF_NAMESIZE > 21 ? IF_NAMESIZE : 21) + 1] = "%";
21182118
const in6_addr_type* ipv6_address = static_cast<const in6_addr_type*>(src);
21192119
bool is_link_local = ((ipv6_address->s6_addr[0] == 0xfe)
21202120
&& ((ipv6_address->s6_addr[1] & 0xc0) == 0x80));

0 commit comments

Comments
 (0)