Make the 'any' works correctly with either C++17 or C++14

This commit is contained in:
antao 2019-01-30 09:37:30 +08:00
parent 42c23864c4
commit 6ebae287a3
2 changed files with 9 additions and 3 deletions

View File

@ -10,14 +10,17 @@ IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
stop()
elseif(version LESS 7.1.0)
set(CMAKE_CXX_STD_FLAGS c++14)
set(CXX_STD 14)
MESSAGE(STATUS "c++14")
else()
set(CMAKE_CXX_STD_FLAGS c++17)
set(CXX_STD 17)
MESSAGE(STATUS "c++17")
endif()
else()
#MacOS use c++17
set(CMAKE_CXX_STD_FLAGS c++17)
set(CXX_STD 17)
endif()
include_directories(${PROJECT_SOURCE_DIR}/trantor ${PROJECT_SOURCE_DIR}/lib/inc ${PROJECT_SOURCE_DIR}/orm_lib/inc)
@ -131,7 +134,7 @@ SET(CONFIG_HEADER "${PROJECT_SOURCE_DIR}/config.h")
file(WRITE "${CONFIG_HEADER}" "#pragma once\n")
file(APPEND "${CONFIG_HEADER}" "#include <trantor/utils/config.h>\n")
file(APPEND "${CONFIG_HEADER}" "#define CXX_STD " ${CXX_STD} "\n")
if(USE_ORM)
file(APPEND "${CONFIG_HEADER}" "#define USE_ORM 1\n")
if(PostgreSQL_FOUND)

View File

@ -88,8 +88,11 @@ void HttpServer::onConnection(const TcpConnectionPtr &conn)
{
_disconnectWebsocketCallback(requestParser->webSocketConn());
}
//conn->getMutableContext()->reset(); reset() is in c++17
conn->setContext(0);
#if (CXX_STD > 14)
conn->getMutableContext()->reset(); //reset(): since c++17
#else
conn->getMutableContext()->clear();
#endif
}
}
_connectionCallback(conn);