add C++11 nullptr support detection

This commit is contained in:
Peter Thorson
2014-02-02 17:03:41 -06:00
parent 6ee7c368bb
commit c7ec97795a
2 changed files with 26 additions and 3 deletions

View File

@@ -53,6 +53,9 @@
#ifndef _WEBSOCKETPP_INITIALIZER_LISTS_
#define _WEBSOCKETPP_INITIALIZER_LISTS_
#endif
#ifndef _WEBSOCKETPP_NULLPTR_TOKEN_
#define _WEBSOCKETPP_NULLPTR_TOKEN_ nullptr
#endif
#else
// Test for noexcept
#ifndef _WEBSOCKETPP_NOEXCEPT_TOKEN_
@@ -90,6 +93,25 @@
#if __has_feature(cxx_generalized_initializers) && !defined(_WEBSOCKETPP_INITIALIZER_LISTS_)
#define _WEBSOCKETPP_INITIALIZER_LISTS_
#endif
// Test for nullptr
#ifndef _WEBSOCKETPP_NULLPTR_TOKEN_
#ifdef _WEBSOCKETPP_NULLPTR_
// build system says we have constexpr
#define _WEBSOCKETPP_NULLPTR_TOKEN_ nullptr
#else
#if __has_feature(cxx_nullptr)
// clang feature detect says we have constexpr
#define _WEBSOCKETPP_NULLPTR_TOKEN_ nullptr
#elif _MSC_VER >= 1600
// Visual Studio version that has nullptr
#define _WEBSOCKETPP_NULLPTR_TOKEN_ nullptr
#else
// assume we don't have constexpr
#define _WEBSOCKETPP_NULLPTR_TOKEN_ 0
#endif
#endif
#endif
#endif
#endif // WEBSOCKETPP_COMMON_CPP11_HPP

View File

@@ -28,6 +28,7 @@
#ifndef WEBSOCKETPP_TRANSPORT_ASIO_CON_HPP
#define WEBSOCKETPP_TRANSPORT_ASIO_CON_HPP
#include <websocketpp/common/cpp11.hpp>
#include <websocketpp/common/memory.hpp>
#include <websocketpp/common/functional.hpp>
#include <websocketpp/common/connection_hdl.hpp>
@@ -934,9 +935,9 @@ protected:
// Reset cached handlers now that we won't be reading or writing anymore
// These cached handlers store shared pointers to this connection and will leak
// the connection if not destroyed.
m_async_read_handler = 0;
m_async_write_handler = 0;
m_init_handler = 0;
m_async_read_handler = _WEBSOCKETPP_NULLPTR_TOKEN_;
m_async_write_handler = _WEBSOCKETPP_NULLPTR_TOKEN_;
m_init_handler = _WEBSOCKETPP_NULLPTR_TOKEN_;
timer_ptr shutdown_timer;
shutdown_timer = set_timer(