From 23e97bcc113dbbfe2cf01c8ebacc2d6dda21d054 Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Sat, 13 Dec 2014 06:24:52 -0500 Subject: [PATCH] Better C++11 detection for visual studio --- websocketpp/common/functional.hpp | 13 +++++++++++++ websocketpp/common/memory.hpp | 13 +++++++++++++ websocketpp/common/platforms.hpp | 5 +++++ websocketpp/common/random.hpp | 14 ++++++++++++++ websocketpp/common/system_error.hpp | 18 +++++++++++++++++- 5 files changed, 62 insertions(+), 1 deletion(-) diff --git a/websocketpp/common/functional.hpp b/websocketpp/common/functional.hpp index d1c2b80..97afd6f 100644 --- a/websocketpp/common/functional.hpp +++ b/websocketpp/common/functional.hpp @@ -30,12 +30,25 @@ #include +// If we've determined that we're in full C++11 mode and the user hasn't +// explicitly disabled the use of C++11 functional header, then prefer it to +// boost. #if defined _WEBSOCKETPP_CPP11_INTERNAL_ && !defined _WEBSOCKETPP_NO_CPP11_FUNCTIONAL_ #ifndef _WEBSOCKETPP_CPP11_FUNCTIONAL_ #define _WEBSOCKETPP_CPP11_FUNCTIONAL_ #endif #endif +// If we're on Visual Studio 2010 or higher and haven't explicitly disabled +// the use of C++11 functional header then prefer it to boost. +#if _MSC_VER >= 1600 && !defined _WEBSOCKETPP_NO_CPP11_FUNCTIONAL_ + #ifndef _WEBSOCKETPP_CPP11_FUNCTIONAL_ + #define _WEBSOCKETPP_CPP11_FUNCTIONAL_ + #endif +#endif + + + #ifdef _WEBSOCKETPP_CPP11_FUNCTIONAL_ #include #else diff --git a/websocketpp/common/memory.hpp b/websocketpp/common/memory.hpp index 65cd459..10e7cd0 100644 --- a/websocketpp/common/memory.hpp +++ b/websocketpp/common/memory.hpp @@ -30,12 +30,25 @@ #include +// If we've determined that we're in full C++11 mode and the user hasn't +// explicitly disabled the use of C++11 memory header, then prefer it to +// boost. #if defined _WEBSOCKETPP_CPP11_INTERNAL_ && !defined _WEBSOCKETPP_NO_CPP11_MEMORY_ #ifndef _WEBSOCKETPP_CPP11_MEMORY_ #define _WEBSOCKETPP_CPP11_MEMORY_ #endif #endif +// If we're on Visual Studio 2010 or higher and haven't explicitly disabled +// the use of C++11 functional header then prefer it to boost. +#if _MSC_VER >= 1600 && !defined _WEBSOCKETPP_NO_CPP11_MEMORY_ + #ifndef _WEBSOCKETPP_CPP11_MEMORY_ + #define _WEBSOCKETPP_CPP11_MEMORY_ + #endif +#endif + + + #ifdef _WEBSOCKETPP_CPP11_MEMORY_ #include #else diff --git a/websocketpp/common/platforms.hpp b/websocketpp/common/platforms.hpp index d934a03..69e8d25 100644 --- a/websocketpp/common/platforms.hpp +++ b/websocketpp/common/platforms.hpp @@ -38,4 +38,9 @@ #define NOMINMAX #endif +// Bump up the variadic parameter max for Visual Studio 2012 +#if _MSC_VER == 1700 + #define _VARIADIC_MAX 8 +#endif + #endif // WEBSOCKETPP_COMMON_PLATFORMS_HPP diff --git a/websocketpp/common/random.hpp b/websocketpp/common/random.hpp index 5361131..ea088f3 100644 --- a/websocketpp/common/random.hpp +++ b/websocketpp/common/random.hpp @@ -30,12 +30,26 @@ #include +// If we've determined that we're in full C++11 mode and the user hasn't +// explicitly disabled the use of C++11 random header, then prefer it to +// boost. #if defined _WEBSOCKETPP_CPP11_INTERNAL_ && !defined _WEBSOCKETPP_NO_CPP11_RANDOM_DEVICE_ #ifndef _WEBSOCKETPP_CPP11_RANDOM_DEVICE_ #define _WEBSOCKETPP_CPP11_RANDOM_DEVICE_ #endif #endif + +// If we're on Visual Studio 2010 or higher and haven't explicitly disabled +// the use of C++11 random header then prefer it to boost. +#if _MSC_VER >= 1600 && !defined _WEBSOCKETPP_NO_CPP11_MEMORY_ + #ifndef _WEBSOCKETPP_CPP11_MEMORY_ + #define _WEBSOCKETPP_CPP11_MEMORY_ + #endif +#endif + + + #ifdef _WEBSOCKETPP_CPP11_RANDOM_DEVICE_ #include #else diff --git a/websocketpp/common/system_error.hpp b/websocketpp/common/system_error.hpp index 4bfa73d..f03fef1 100644 --- a/websocketpp/common/system_error.hpp +++ b/websocketpp/common/system_error.hpp @@ -28,12 +28,28 @@ #ifndef WEBSOCKETPP_COMMON_SYSTEM_ERROR_HPP #define WEBSOCKETPP_COMMON_SYSTEM_ERROR_HPP -#if defined _WEBSOCKETPP_CPP11_STL_ && !defined _WEBSOCKETPP_NO_CPP11_SYSTEM_ERROR_ + +#include + +// If we've determined that we're in full C++11 mode and the user hasn't +// explicitly disabled the use of C++11 system_error header, then prefer it to +// boost. +#if defined _WEBSOCKETPP_CPP11_INTERNAL_ && !defined _WEBSOCKETPP_NO_CPP11_SYSTEM_ERROR_ #ifndef _WEBSOCKETPP_CPP11_SYSTEM_ERROR_ #define _WEBSOCKETPP_CPP11_SYSTEM_ERROR_ #endif #endif +// If we're on Visual Studio 2010 or higher and haven't explicitly disabled +// the use of C++11 system_error header then prefer it to boost. +#if _MSC_VER >= 1600 && !defined _WEBSOCKETPP_NO_CPP11_SYSTEM_ERROR_ + #ifndef _WEBSOCKETPP_CPP11_SYSTEM_ERROR_ + #define _WEBSOCKETPP_CPP11_SYSTEM_ERROR_ + #endif +#endif + + + #ifdef _WEBSOCKETPP_CPP11_SYSTEM_ERROR_ #include #else