Skip to content

Commit

Permalink
pre-v1.0h-update
Browse files Browse the repository at this point in the history
  • Loading branch information
dakka committed Apr 15, 2024
1 parent 26d03c4 commit f06507d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ project (conjure_enum
VERSION 1.0.0
)

# to enable conservative C++20 build:
# cmake -DBUILD_CONSRVCPP20=true ..
option(BUILD_CONSRVCPP20 "enable conservative C++20 build" false)
message("-- Build conservative C++20: ${BUILD_CONSRVCPP20}")

# to disable warnings:
# cmake -DBUILD_ALL_WARNINGS=false ..
option(BUILD_ALL_WARNINGS "enable building with all warnings" true)
Expand Down Expand Up @@ -65,6 +70,9 @@ foreach(x IN LISTS files)
add_executable(${target} examples/${x})
set_target_properties(${target} PROPERTIES CXX_STANDARD 20 CXX_STANDARD_REQUIRED true)
target_include_directories(${target} PRIVATE include)
if (BUILD_CONSRVCPP20)
target_compile_definitions(${target} PRIVATE BUILD_CONSRVCPP20)
endif()
if(BUILD_ALL_WARNINGS)
target_compile_options(${target} PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/W4>
Expand Down
4 changes: 2 additions & 2 deletions include/fix8/conjure_enum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class conjure_enum final
return false;
}

#if defined(__clang__) && defined(__apple_build_version__) // std::count_if not constexpr in xcode/clang
#if defined BUILD_CONSRVCPP20
template<std::size_t N>
static constexpr auto count_if_constexpr(const bool (&valid)[N]) noexcept
{
Expand All @@ -207,7 +207,7 @@ class conjure_enum final
template<std::size_t... I>
static constexpr auto _values(std::index_sequence<I...>) noexcept
{
#if defined(__clang__) && defined(__apple_build_version__)
#if defined BUILD_CONSRVCPP20
constexpr bool valid[sizeof...(I)] { _is_valid<static_cast<T>(enum_min_value + I)>()... };
constexpr auto num_valid { count_if_constexpr(valid) };
#else
Expand Down

0 comments on commit f06507d

Please sign in to comment.