Skip to content

Commit

Permalink
Prevent errors from nano-span's size checking
Browse files Browse the repository at this point in the history
- Prefer use of range-v3 instead, even if they are noisy.
  • Loading branch information
ThePhD committed Aug 24, 2020
1 parent f0818b7 commit 69b997e
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 20 deletions.
7 changes: 4 additions & 3 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ function (make_example example_source_name itsy_bitsy_target target_suffix)
endif()
target_compile_definitions(${example_target} PRIVATE
__STDC_WANT_LIB_EXT1__=1
ITSY_BITSY_USE_NONSTD_SPAN=1)
ITSY_BITSY_USE_RANGEV3_SPAN=1
ITSY_BITSY_USE_NONSTD_SPAN=0)
target_link_libraries(${example_target}
PRIVATE
${itsy_bitsy_target}
Expand All @@ -38,8 +39,8 @@ function (make_example example_source_name itsy_bitsy_target target_suffix)
include
)
target_include_directories(${example_target} SYSTEM PRIVATE
../vendor/span-lite/include/
)
../vendor/span-lite/include
../vendor/range-v3/include)
if (ITSY_BITSY_TESTS)
add_test(NAME ${example_target} COMMAND ${example_target})
endif()
Expand Down
4 changes: 2 additions & 2 deletions include/itsy/detail/span.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace ITSY_BITSY_SOURCE_NAMESPACE
using ::std::span;
}

#elif (defined(__has_include) && __has_include(<nonstd/span.hpp>)) || ITSY_BITSY_IS_ON(ITSY_BITSY_USE_NONSTD_SPAN_I_)
#elif ITSY_BITSY_IS_ON(ITSY_BITSY_USE_NONSTD_SPAN_I_)

#include <nonstd/span.hpp>

Expand All @@ -33,7 +33,7 @@ namespace ITSY_BITSY_SOURCE_NAMESPACE
using ::nonstd::span;
}

#elif defined(__has_include) && __has_include(<range/v3/view/span.hpp>)
#elif ITSY_BITSY_IS_ON(ITSY_BITSY_USE_RANGEV3_SPAN_I_)

#include <range/v3/view/span.hpp>

Expand Down
38 changes: 28 additions & 10 deletions include/itsy/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,6 @@
#endif
#endif

#if defined(ITSY_BITSY_USE_NONSTD_SPAN)
#if ITSY_BITSY_USE_NONSTD_SPAN != 0
#define ITSY_BITSY_USE_NONSTD_SPAN_I_ ITSY_BITSY_ON
#else
#define ITSY_BITSY_USE_NONSTD_SPAN_I_ ITSY_BITSY_OFF
#endif
#else
#define ITSY_BITSY_USE_NONSTD_SPAN_I_ ITSY_BITSY_DEFAULT_OFF
#endif

#if defined(ITSY_BITSY_NONPORTABLE_MSVC_INTRINSICS)
#if ITSY_BITSY_NONPORTABLE_MSVC_INTRINSICS != 0
#define ITSY_BITSY_NONPORTABLE_MSVC_INTRINSICS_I_ ITSY_BITSY_ON
Expand Down Expand Up @@ -165,6 +155,34 @@
#define ITSY_BITSY_STD_LIB_SPAN_I_ ITSY_BITSY_DEFAULT_OFF
#endif

#if defined(ITSY_BITSY_USE_RANGEV3_SPAN)
#if ITSY_BITSY_USE_RANGEV3_SPAN != 0
#define ITSY_BITSY_USE_RANGEV3_SPAN_I_ ITSY_BITSY_ON
#else
#define ITSY_BITSY_USE_RANGEV3_SPAN_I_ ITSY_BITSY_OFF
#endif
#else
#if defined(__has_include) && __has_include(<range/v3/view/span.hpp>)
#define ITSY_BITSY_USE_RANGEV3_SPAN_I_ ITSY_BITSY_DEFAULT_ON
#else
#define ITSY_BITSY_USE_RANGEV3_SPAN_I_ ITSY_BITSY_DEFAULT_OFF
#endif
#endif

#if defined(ITSY_BITSY_USE_NONSTD_SPAN)
#if ITSY_BITSY_USE_NONSTD_SPAN != 0
#define ITSY_BITSY_USE_NONSTD_SPAN_I_ ITSY_BITSY_ON
#else
#define ITSY_BITSY_USE_NONSTD_SPAN_I_ ITSY_BITSY_OFF
#endif
#else
#if defined(__has_include) && __has_include(<nonstd/span.hpp>)
#define ITSY_BITSY_USE_NONSTD_SPAN_I_ ITSY_BITSY_DEFAULT_ON
#else
#define ITSY_BITSY_USE_NONSTD_SPAN_I_ ITSY_BITSY_DEFAULT_OFF
#endif
#endif

// clang-format on

namespace bitsy
Expand Down
3 changes: 2 additions & 1 deletion tests/compile_failure/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ foreach (test_name ${itsy-bitsy-tests-fail-sources})
${CMAKE_DL_LIBS}
)
target_compile_definitions(${test-target} PRIVATE
ITSY_BITSY_USE_NONSTD_SPAN=1)
ITSY_BITSY_USE_RANGEV3_SPAN=1
ITSY_BITSY_USE_NONSTD_SPAN=0)
add_test(NAME ${test-target} COMMAND cmake --build . --target ${test-target}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_tests_properties(${test-target}
Expand Down
5 changes: 3 additions & 2 deletions tests/compile_time/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ target_include_directories(itsy_bitsy.tests.compilation
PRIVATE
../include
../../vendor/span-lite/include
)
../../vendor/range-v3/include)
target_compile_definitions(itsy_bitsy.tests.compilation PRIVATE
ITSY_BITSY_USE_NONSTD_SPAN=1)
ITSY_BITSY_USE_RANGEV3_SPAN=1
ITSY_BITSY_USE_NONSTD_SPAN=0)
if (MSVC)
target_compile_options(itsy_bitsy.tests.compilation
PRIVATE
Expand Down
3 changes: 2 additions & 1 deletion tests/run_time/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ function (make_run_time_tests itsy_bitsy_target target_suffix)
${CMAKE_DL_LIBS}
)
target_compile_definitions(${test-target-name} PRIVATE
ITSY_BITSY_USE_NONSTD_SPAN=1)
ITSY_BITSY_USE_RANGEV3_SPAN=1
ITSY_BITSY_USE_NONSTD_SPAN=0)
if (MSVC)
target_compile_options(${test-target-name} PRIVATE
/std:c++17
Expand Down
2 changes: 1 addition & 1 deletion vendor/range-v3
Submodule range-v3 updated 312 files

0 comments on commit 69b997e

Please sign in to comment.