Fix #33: Use _MSVC_LANG to determine the actual C++ standard version of Microsoft compilers.

This commit is contained in:
Thomas Kemmer 2021-07-29 16:02:59 +02:00
parent d689403d3a
commit 5240fd3bbe
5 changed files with 19 additions and 18 deletions

View File

@ -40,12 +40,19 @@ jobs:
CXXFLAGS: -std=${{ matrix.std }}
run: ./configure && make && make check
msvc:
name: MSVC on windows-latest
name: Windows ${{ matrix.config }} build (C++${{ matrix.standard }})
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
config: [Debug, Release]
standard: [11, 17]
steps:
- uses: actions/checkout@v2
- name: Build and run tests
run: |
cmake -S . -B .
cmake --build .
ctest -C Debug
- name: Configure CMake
run: cmake -B build -D CMAKE_CXX_STANDARD=${{ matrix.standard }}
- name: Build
run: cmake --build build --config ${{ matrix.config }}
- name: Run tests
working-directory: build
run: ctest -C ${{ matrix.config }}

View File

@ -34,13 +34,13 @@
namespace fsmlite {
namespace detail {
#if __cplusplus >= 201703L
#if __cplusplus >= 201703L || _MSVC_LANG >= 201703L
template<class F, class... Args>
using invoke_result_t = std::invoke_result_t<F, Args...>;
template <class F, class... Args>
using is_invocable = std::is_invocable<F, Args...>;
#elif __cplusplus >= 201103L
#elif __cplusplus >= 201103L || _MSVC_LANG >= 201103L
template<class F, class... Args>
using invoke_result_t = typename std::result_of<F&&(Args&&...)>::type;
@ -357,7 +357,7 @@ namespace fsmlite {
}
};
#if __cplusplus >= 201703L
#if __cplusplus >= 201703L || _MSVC_LANG >= 201703L
/**
* Generic transition class template (requires C++17).
*

View File

@ -1,12 +1,6 @@
macro(fsmlite_add_test TESTNAME)
add_executable(${TESTNAME} ${CMAKE_CURRENT_SOURCE_DIR}/${TESTNAME}.cpp)
target_link_libraries(${TESTNAME} PRIVATE fsmlite)
if (MSVC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.14)
target_compile_options(${TESTNAME}
PRIVATE
/Zc:__cplusplus
)
endif()
add_test(NAME ${PROJECT_NAME}_${TESTNAME} COMMAND ${TESTNAME})
endmacro(fsmlite_add_test)

View File

@ -4,7 +4,7 @@
#include <iostream>
#include <string>
#if __cplusplus >= 201703L
#if __cplusplus >= 201703L || _MSVC_LANG >= 201703L
class player: public fsmlite::fsm<player> {
friend class fsmlite::fsm<player>; // base class needs access to transition_table

View File

@ -2,7 +2,7 @@
#include "fsm.h"
#if __cplusplus >= 201703L
#if __cplusplus >= 201703L || _MSVC_LANG >= 201703L
int value = 0;
@ -55,7 +55,7 @@ private:
int main()
{
#if __cplusplus >= 201703L
#if __cplusplus >= 201703L || _MSVC_LANG >= 201703L
state_machine m;
assert(m.current_state() == state_machine::Init);
assert(value == 0);