Skip to content

Commit

Permalink
Fix #33: Use _MSVC_LANG to determine the actual C++ standard version …
Browse files Browse the repository at this point in the history
…of Microsoft compilers.
  • Loading branch information
tkem committed Aug 2, 2021
1 parent d689403 commit 5240fd3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
19 changes: 13 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
6 changes: 3 additions & 3 deletions src/fsm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -357,7 +357,7 @@ namespace fsmlite {
}
};

#if __cplusplus >= 201703L
#if __cplusplus >= 201703L || _MSVC_LANG >= 201703L
/**
* Generic transition class template (requires C++17).
*
Expand Down
6 changes: 0 additions & 6 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/test_row.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "fsm.h"

#if __cplusplus >= 201703L
#if __cplusplus >= 201703L || _MSVC_LANG >= 201703L

int value = 0;

Expand Down Expand Up @@ -55,7 +55,7 @@ class state_machine: public fsmlite::fsm<state_machine> {

int main()
{
#if __cplusplus >= 201703L
#if __cplusplus >= 201703L || _MSVC_LANG >= 201703L
state_machine m;
assert(m.current_state() == state_machine::Init);
assert(value == 0);
Expand Down

0 comments on commit 5240fd3

Please sign in to comment.