Add use_future support for Microsoft Visual C++.

This commit is contained in:
Christopher Kohlhoff 2013-09-16 22:55:42 +10:00
parent ebe6cd7a97
commit f1f4ea75cd
3 changed files with 31 additions and 1 deletions

View File

@ -157,6 +157,31 @@
# endif // !defined(ASIO_DISABLE_VARIADIC_TEMPLATES)
#endif // !defined(ASIO_HAS_VARIADIC_TEMPLATES)
// Support constexpr on compilers known to allow it.
#if !defined(ASIO_HAS_CONSTEXPR)
# if !defined(ASIO_DISABLE_CONSTEXPR)
# if defined(__clang__)
# if __has_feature(__cxx_constexpr__)
# define ASIO_HAS_CONSTEXPR 1
# endif // __has_feature(__cxx_constexr__)
# endif // defined(__clang__)
# if defined(__GNUC__)
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define ASIO_HAS_CONSTEXPR 1
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4)
# endif // defined(__GNUC__)
# endif // !defined(ASIO_DISABLE_CONSTEXPR)
#endif // !defined(ASIO_HAS_CONSTEXPR)
#if !defined(ASIO_CONSTEXPR)
# if defined(ASIO_HAS_CONSTEXPR)
# define ASIO_CONSTEXPR constexpr
# else // defined(ASIO_HAS_CONSTEXPR)
# define ASIO_CONSTEXPR
# endif // defined(ASIO_HAS_CONSTEXPR)
#endif // !defined(ASIO_CONSTEXPR)
// Standard library support for system errors.
#if !defined(ASIO_HAS_STD_SYSTEM_ERROR)
# if !defined(ASIO_DISABLE_STD_SYSTEM_ERROR)

View File

@ -46,7 +46,7 @@ public:
typedef Allocator allocator_type;
/// Construct using default-constructed allocator.
constexpr use_future_t()
ASIO_CONSTEXPR use_future_t()
{
}
@ -77,7 +77,11 @@ private:
/**
* See the documentation for asio::use_future_t for a usage example.
*/
#if defined(ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION)
constexpr use_future_t<> use_future;
#elif defined(ASIO_MSVC)
__declspec(selectany) use_future_t<> use_future;
#endif
} // namespace asio

View File

@ -197,6 +197,7 @@ PREDEFINED = GENERATING_DOCUMENTATION \
ASIO_OS_ERROR(e1,e2)=implementation_defined \
ASIO_MOVE_ARG(a)=a \
ASIO_DECL= \
ASIO_CONSTEXPR=constexpr \
ASIO_INITFN_RESULT_TYPE(t,a)=void_or_deduced
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES