Skip to content

Commit f1f4ea7

Browse files
committed
Add use_future support for Microsoft Visual C++.
1 parent ebe6cd7 commit f1f4ea7

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

asio/include/asio/detail/config.hpp

+25
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,31 @@
157157
# endif // !defined(ASIO_DISABLE_VARIADIC_TEMPLATES)
158158
#endif // !defined(ASIO_HAS_VARIADIC_TEMPLATES)
159159

160+
// Support constexpr on compilers known to allow it.
161+
#if !defined(ASIO_HAS_CONSTEXPR)
162+
# if !defined(ASIO_DISABLE_CONSTEXPR)
163+
# if defined(__clang__)
164+
# if __has_feature(__cxx_constexpr__)
165+
# define ASIO_HAS_CONSTEXPR 1
166+
# endif // __has_feature(__cxx_constexr__)
167+
# endif // defined(__clang__)
168+
# if defined(__GNUC__)
169+
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4)
170+
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
171+
# define ASIO_HAS_CONSTEXPR 1
172+
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
173+
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4)
174+
# endif // defined(__GNUC__)
175+
# endif // !defined(ASIO_DISABLE_CONSTEXPR)
176+
#endif // !defined(ASIO_HAS_CONSTEXPR)
177+
#if !defined(ASIO_CONSTEXPR)
178+
# if defined(ASIO_HAS_CONSTEXPR)
179+
# define ASIO_CONSTEXPR constexpr
180+
# else // defined(ASIO_HAS_CONSTEXPR)
181+
# define ASIO_CONSTEXPR
182+
# endif // defined(ASIO_HAS_CONSTEXPR)
183+
#endif // !defined(ASIO_CONSTEXPR)
184+
160185
// Standard library support for system errors.
161186
#if !defined(ASIO_HAS_STD_SYSTEM_ERROR)
162187
# if !defined(ASIO_DISABLE_STD_SYSTEM_ERROR)

asio/include/asio/use_future.hpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class use_future_t
4646
typedef Allocator allocator_type;
4747

4848
/// Construct using default-constructed allocator.
49-
constexpr use_future_t()
49+
ASIO_CONSTEXPR use_future_t()
5050
{
5151
}
5252

@@ -77,7 +77,11 @@ class use_future_t
7777
/**
7878
* See the documentation for asio::use_future_t for a usage example.
7979
*/
80+
#if defined(ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION)
8081
constexpr use_future_t<> use_future;
82+
#elif defined(ASIO_MSVC)
83+
__declspec(selectany) use_future_t<> use_future;
84+
#endif
8185

8286
} // namespace asio
8387

asio/src/doc/reference.dox

+1
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ PREDEFINED = GENERATING_DOCUMENTATION \
197197
ASIO_OS_ERROR(e1,e2)=implementation_defined \
198198
ASIO_MOVE_ARG(a)=a \
199199
ASIO_DECL= \
200+
ASIO_CONSTEXPR=constexpr \
200201
ASIO_INITFN_RESULT_TYPE(t,a)=void_or_deduced
201202
EXPAND_AS_DEFINED =
202203
SKIP_FUNCTION_MACROS = YES

0 commit comments

Comments
 (0)