Skip to content

Commit

Permalink
Add 'Tweak header' support via <nonstd/any.tweak.hpp>
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmoene committed Nov 27, 2020
1 parent 2e25d46 commit f5880d4
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ any: Allows to default construct any
any: Allows to copy-construct from any
any: Allows to move-construct from any (C++11)
any: Allows to copy-construct from literal value
any: Allows to copy-construct from value
any: Allows to copy-construct from const value
any: Allows to copy-construct from lvalue references
any: Allows to move-construct from value (C++11)
any: Allows to in-place construct from literal value (C++11)
any: Allows to in-place copy-construct from value (C++11)
Expand Down Expand Up @@ -272,4 +273,5 @@ any_cast: Throws bad_any_cast if requested type differs from content type (any c
any_cast: Throws bad_any_cast if requested type differs from content type (any &)
any_cast: Throws bad_any_cast if requested type differs from content type (any &&)
any_cast: Throws bad_any_cast with non-empty what()
tweak header: reads tweak header if supported [tweak]
```
14 changes: 14 additions & 0 deletions include/nonstd/any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@
#define any_ANY_NONSTD 1
#define any_ANY_STD 2

// tweak header support:

#ifdef __has_include
# if __has_include(<nonstd/any.tweak.hpp>)
# include <nonstd/any.tweak.hpp>
# endif
#define any_HAVE_TWEAK_HEADER 1
#else
#define any_HAVE_TWEAK_HEADER 0
//# pragma message("any.hpp: Note: Tweak header not supported.")
#endif

// any selection and configuration:

#if !defined( any_CONFIG_SELECT_ANY )
# define any_CONFIG_SELECT_ANY ( any_HAVE_STD_ANY ? any_ANY_STD : any_ANY_NONSTD )
#endif
Expand Down
2 changes: 2 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ set( unit_name "any" )
set( PACKAGE ${unit_name}-lite )
set( PROGRAM ${unit_name}-lite )
set( SOURCES ${unit_name}-main.t.cpp ${unit_name}.t.cpp )
set( TWEAKD "." )

message( STATUS "Subproject '${PROJECT_NAME}', programs '${PROGRAM}-*'")

Expand Down Expand Up @@ -124,6 +125,7 @@ function( make_target target std )
message( STATUS "Make target: '${std}'" )

add_executable ( ${target} ${SOURCES} )
target_include_directories( ${target} PRIVATE ${TWEAKD} )
target_link_libraries ( ${target} PRIVATE ${PACKAGE} )
target_compile_options ( ${target} PRIVATE ${OPTIONS} )
target_compile_definitions( ${target} PRIVATE ${DEFINITIONS} )
Expand Down
9 changes: 9 additions & 0 deletions test/any.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,4 +662,13 @@ CASE( "any_cast: Throws bad_any_cast with non-empty what()" )
}
}

CASE( "tweak header: reads tweak header if supported " "[tweak]" )
{
#if any_HAVE_TWEAK_HEADER
EXPECT( ANY_TWEAK_VALUE == 42 );
#else
EXPECT( !!"Tweak header is not available (any_HAVE_TWEAK_HEADER: 0)." );
#endif
}

// end of file
1 change: 1 addition & 0 deletions test/nonstd/any.tweak.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define ANY_TWEAK_VALUE 42
2 changes: 1 addition & 1 deletion test/t.bat
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ set msvc_defines=^

set CppCoreCheckInclude=%VCINSTALLDIR%\Auxiliary\VS\include

cl -W3 -EHsc %std% %unit_select% %unit_config% %msvc_defines% -I../include %unit%-main.t.cpp %unit%.t.cpp && %unit%-main.t.exe
cl -W3 -EHsc %std% %unit_select% %unit_config% %msvc_defines% -I../include -I. %unit%-main.t.cpp %unit%.t.cpp && %unit%-main.t.exe
endlocal & goto :EOF

:: subroutines:
Expand Down
2 changes: 1 addition & 1 deletion test/tc.bat
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ rem -flto / -fwhole-program
set optflags=-O2
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% -fms-compatibility-version=19.00 -isystem "%VCInstallDir%include" -isystem "%WindowsSdkDir_71A%include" -I../include -o %unit%-main.t.exe %unit%-main.t.cpp %unit%.t.cpp && %unit%-main.t.exe
"%clang%" -m32 -std=%std% %optflags% %warnflags% %unit_select% %unit_config% -fms-compatibility-version=19.00 -isystem "%VCInstallDir%include" -isystem "%WindowsSdkDir_71A%include" -I../include -I. -o %unit%-main.t.exe %unit%-main.t.cpp %unit%.t.cpp && %unit%-main.t.exe
endlocal & goto :EOF

:: subroutines:
Expand Down
2 changes: 1 addition & 1 deletion test/tg.bat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ rem -flto / -fwhole-program
set optflags=-O2
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 -I../include %unit%-main.t.cpp %unit%.t.cpp && %unit%-main.t.exe
%gpp% -std=%std% %optflags% %warnflags% %unit_select% %unit_config% -o %unit%-main.t.exe -I../include -I. %unit%-main.t.cpp %unit%.t.cpp && %unit%-main.t.exe

endlocal & goto :EOF

Expand Down

0 comments on commit f5880d4

Please sign in to comment.