Merge pull request #40 from mat007/fix-c++17-compliance

Fix c++17 compliance
This commit is contained in:
Mathieu Champlon 2018-03-25 13:58:19 +02:00 committed by GitHub
commit 07c73ad616
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 4 deletions

View file

@ -9,11 +9,16 @@ skip_branch_with_pr: true
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
BOOST_ROOT: C:\Libraries\boost_1_59_0
BOOST: 1_59_0
TOOLSET: msvc-14.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
BOOST_ROOT: C:\Libraries\boost_1_65_1
BOOST: 1_65_1
TOOLSET: msvc-14.1
CXX_STANDARD: 14
# - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
# BOOST: 1_65_1
# TOOLSET: msvc-14.1
# CXX_STANDARD: 17
platform:
- 32
@ -36,7 +41,9 @@ install:
- xsltproc -V
build_script:
- set BOOST_ROOT=C:\Libraries\boost_%BOOST%
- cd %BOOST_ROOT%
- call bootstrap.bat
- cd C:\projects\turtle\build
- call build.bat --toolset=%TOOLSET% address-model=%PLATFORM% --build-type=complete %CONFIGURATION%
- if NOT "%CXX_STANDARD%"=="" set CXX_FLAGS=cxxflags=/std:c++%CXX_STANDARD%
- call build.bat --toolset=%TOOLSET% address-model=%PLATFORM% %CXX_FLAGS% --build-type=complete %CONFIGURATION%

View file

@ -17,6 +17,7 @@ Not yet released
* Fixed move-only type support in constraints
* Added support for dereferencing in mock::equal
* Added support for movable objects in mock::retrieve
* Fixed deprecation warning about std::uncaught_exception in c++17 for msvc
[endsect]

View file

@ -94,4 +94,11 @@
# endif
#endif
#if defined(__cplusplus) && (__cplusplus >= 201703L) || \
defined(_MSC_VER) && (_MSC_VER >= 1900)
# ifndef MOCK_NO_UNCAUGHT_EXCEPTIONS
# define MOCK_UNCAUGHT_EXCEPTIONS
# endif
#endif
#endif // MOCK_CONFIG_HPP_INCLUDED

View file

@ -86,6 +86,15 @@ namespace detail
E* e_;
};
inline int uncaught_exceptions()
{
#ifdef MOCK_UNCAUGHT_EXCEPTIONS
return std::uncaught_exceptions();
#else
return std::uncaught_exception() ? 1 : 0;
#endif
}
}
} // mock

View file

@ -44,10 +44,11 @@ namespace detail
: context_( 0 )
, valid_( true )
, mutex_( boost::make_shared< mutex >() )
, exceptions_( uncaught_exceptions() )
{}
virtual ~function_impl()
{
if( valid_ && ! std::uncaught_exception() )
if( valid_ && exceptions_ >= uncaught_exceptions() )
for( expectations_cit it = expectations_.begin();
it != expectations_.end(); ++it )
if( ! it->verify() )
@ -300,6 +301,7 @@ namespace detail
expectations_type expectations_;
context* context_;
mutable bool valid_;
const int exceptions_;
const boost::shared_ptr< mutex > mutex_;
};
}