-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make version with no-exception support (#27)
May need additional changes.
- Loading branch information
1 parent
96ae9ec
commit 857ee52
Showing
7 changed files
with
258 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) 2016-2019 Martin Moene | ||
// | ||
// https://github.com/martinmoene/expected-lite | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#include "nonstd/expected.hpp" | ||
|
||
template< typename T > | ||
void use( T const & /*x*/) {} | ||
|
||
int main() | ||
{ | ||
nonstd::expected<int, char> e; | ||
nonstd::unexpected_type<int> ut(7); | ||
|
||
use(e); | ||
use(ut); | ||
|
||
#if nsel_CPP17_OR_GREATER && nsel_COMPILER_MSVC_VERSION > 141 | ||
nonstd::unexpected<int> u(3); u; | ||
use(u); | ||
#endif | ||
|
||
nonstd::expected<int, char> eu( nonstd:: make_unexpected('a') ); | ||
|
||
return eu.value(); | ||
} | ||
|
||
// end of file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
@echo off & setlocal enableextensions enabledelayedexpansion | ||
:: | ||
:: t.bat - compile & run tests (MSVC). | ||
:: | ||
|
||
set unit=expected | ||
|
||
:: if no std is given, use compiler default | ||
|
||
set std=%1 | ||
if not "%std%"=="" set std=-std:%std% | ||
|
||
call :CompilerVersion version | ||
echo VC%version%: %args% | ||
|
||
set UCAP=%unit% | ||
call :toupper UCAP | ||
|
||
set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_DEFAULT | ||
::set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_NONSTD | ||
::set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_STD | ||
|
||
set unit_config= | ||
|
||
set msvc_defines=^ | ||
-Dlest_FEATURE_AUTO_REGISTER=1 ^ | ||
-D_CRT_SECURE_NO_WARNINGS ^ | ||
-D_SCL_SECURE_NO_WARNINGS ^ | ||
-Dnsel_CONFIG_NO_EXCEPTIONS=1 | ||
|
||
set CppCoreCheckInclude=%VCINSTALLDIR%\Auxiliary\VS\include | ||
|
||
:: -EHsc | ||
cl -W3 %std% %unit_select% %unit_config% %msvc_defines% -I"%CppCoreCheckInclude%" -I../include %unit%-noexcept.t.cpp && %unit%-noexcept.t.exe | ||
endlocal & goto :EOF | ||
|
||
:: subroutines: | ||
|
||
:CompilerVersion version | ||
@echo off & setlocal enableextensions | ||
set tmpprogram=_getcompilerversion.tmp | ||
set tmpsource=%tmpprogram%.c | ||
|
||
echo #include ^<stdio.h^> >%tmpsource% | ||
echo int main(){printf("%%d\n",_MSC_VER);} >>%tmpsource% | ||
|
||
cl /nologo %tmpsource% >nul | ||
for /f %%x in ('%tmpprogram%') do set version=%%x | ||
del %tmpprogram%.* >nul | ||
set offset=0 | ||
if %version% LSS 1900 set /a offset=1 | ||
set /a version="version / 10 - 10 * ( 5 + offset )" | ||
endlocal & set %1=%version%& goto :EOF | ||
|
||
:: toupper; makes use of the fact that string | ||
:: replacement (via SET) is not case sensitive | ||
:toupper | ||
for %%L IN (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO SET %1=!%1:%%L=%%L! | ||
goto :EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
@echo off & setlocal enableextensions enabledelayedexpansion | ||
:: | ||
:: tc.bat - compile & run tests (clang). | ||
:: | ||
|
||
set unit=expected | ||
|
||
:: if no std is given, use c++14 | ||
|
||
set std=%1 | ||
if "%std%"=="" set std=c++14 | ||
|
||
set clang=clang | ||
|
||
call :CompilerVersion version | ||
echo %clang% %version%: %std% | ||
|
||
set UCAP=%unit% | ||
call :toupper UCAP | ||
|
||
set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_DEFAULT | ||
::set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_NONSTD | ||
::set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_STD | ||
|
||
set unit_config= | ||
|
||
rem -flto / -fwhole-program | ||
set optflags=-O2 -fno-exceptions | ||
set warnflags=-Wall -Wextra -Wpedantic -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded -Wno-missing-noreturn -Wno-documentation-unknown-command -Wno-documentation-deprecated-sync -Wno-documentation -Wno-weak-vtables -Wno-missing-prototypes -Wno-missing-variable-declarations -Wno-exit-time-destructors -Wno-global-constructors | ||
|
||
"%clang%" -m32 -std=%std% %optflags% %warnflags% %unit_select% %unit_config% -Dlest_FEATURE_AUTO_REGISTER=1 -fms-compatibility-version=19.00 -isystem "%VCInstallDir%include" -isystem "%WindowsSdkDir_71A%include" -I../include -o %unit%-main.t.exe %unit%-noexcept.t.cpp && %unit%-noexcept.t.exe | ||
endlocal & goto :EOF | ||
|
||
:: subroutines: | ||
|
||
:CompilerVersion version | ||
echo off & setlocal enableextensions | ||
set tmpprogram=_getcompilerversion.tmp | ||
set tmpsource=%tmpprogram%.c | ||
|
||
echo #include ^<stdio.h^> > %tmpsource% | ||
echo int main(){printf("%%d.%%d.%%d\n",__clang_major__,__clang_minor__,__clang_patchlevel__);} >> %tmpsource% | ||
|
||
"%clang%" -m32 -o %tmpprogram% %tmpsource% >nul | ||
for /f %%x in ('%tmpprogram%') do set version=%%x | ||
del %tmpprogram%.* >nul | ||
endlocal & set %1=%version%& goto :EOF | ||
|
||
:: toupper; makes use of the fact that string | ||
:: replacement (via SET) is not case sensitive | ||
:toupper | ||
for %%L IN (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO SET %1=!%1:%%L=%%L! | ||
goto :EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
@echo off & setlocal enableextensions enabledelayedexpansion | ||
:: | ||
:: tg.bat - compile & run tests (GNUC). | ||
:: | ||
|
||
set unit=expected | ||
|
||
:: if no std is given, use c++11 | ||
|
||
set std=%1 | ||
set args=%2 %3 %4 %5 %6 %7 %8 %9 | ||
if "%1" == "" set std=c++11 | ||
|
||
set gpp=g++ | ||
|
||
call :CompilerVersion version | ||
echo %gpp% %version%: %std% %args% | ||
|
||
set UCAP=%unit% | ||
call :toupper UCAP | ||
|
||
set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_DEFAULT | ||
::set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_NONSTD | ||
::set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_STD | ||
|
||
set unit_config=-Dnsel_CONFIG_NO_EXCEPTIONS=1 | ||
|
||
rem -flto / -fwhole-program | ||
set optflags=-O2 -fno-exceptions | ||
set warnflags=-Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wno-padded -Wno-missing-noreturn | ||
|
||
%gpp% -std=%std% %optflags% %warnflags% %unit_select% %unit_config% -o %unit%-main.t.exe -Dlest_FEATURE_AUTO_REGISTER=1 -I../include %unit%-noexcept.t.cpp && %unit%-main.t.exe | ||
|
||
endlocal & goto :EOF | ||
|
||
:: subroutines: | ||
|
||
:CompilerVersion version | ||
echo off & setlocal enableextensions | ||
set tmpprogram=_getcompilerversion.tmp | ||
set tmpsource=%tmpprogram%.c | ||
|
||
echo #include ^<stdio.h^> > %tmpsource% | ||
echo int main(){printf("%%d.%%d.%%d\n",__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__);} >> %tmpsource% | ||
|
||
%gpp% -o %tmpprogram% %tmpsource% >nul | ||
for /f %%x in ('%tmpprogram%') do set version=%%x | ||
del %tmpprogram%.* >nul | ||
endlocal & set %1=%version%& goto :EOF | ||
|
||
:: toupper; makes use of the fact that string | ||
:: replacement (via SET) is not case sensitive | ||
:toupper | ||
for %%L IN (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO SET %1=!%1:%%L=%%L! | ||
goto :EOF |