diff --git a/asio/include/asio/detail/config.hpp b/asio/include/asio/detail/config.hpp index fc13899c..de15e9a0 100644 --- a/asio/include/asio/detail/config.hpp +++ b/asio/include/asio/detail/config.hpp @@ -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) diff --git a/asio/include/asio/use_future.hpp b/asio/include/asio/use_future.hpp index f883eef1..0ffc50d9 100644 --- a/asio/include/asio/use_future.hpp +++ b/asio/include/asio/use_future.hpp @@ -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 diff --git a/asio/src/doc/reference.dox b/asio/src/doc/reference.dox index 36c99402..e55b8399 100644 --- a/asio/src/doc/reference.dox +++ b/asio/src/doc/reference.dox @@ -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