-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
18 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,6 @@ | |
# | ||
# Lightweight header-only C++20 enum reflection | ||
# | ||
# Parts based on magic_enum <https://github.com/Neargye/magic_enum> | ||
# Copyright (c) 2019 - 2024 Daniil Goncharov <[email protected]>. | ||
# | ||
# Licensed under the MIT License <http://opensource.org/licenses/MIT>. | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
|
@@ -37,10 +34,16 @@ project (conjure_enum | |
VERSION 1.0.0 | ||
) | ||
|
||
# to disable warnings: | ||
# cmake -DBUILD_ALL_WARNINGS=false .. | ||
option(BUILD_ALL_WARNINGS "enable building with all warnings" true) | ||
message("-- Build with all warnings : ${BUILD_ALL_WARNINGS}") | ||
|
||
# to disable building unit tests: | ||
# cmake -DBUILD_UNITTESTS=false .. | ||
option(BUILD_UNITTESTS "enable building unit tests" true) | ||
message("-- Build unit tests: ${BUILD_UNITTESTS}") | ||
|
||
if(BUILD_UNITTESTS) | ||
include(FetchContent) | ||
FetchContent_Declare(Catch2 | ||
|
@@ -62,6 +65,11 @@ 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 examples) | ||
if(BUILD_ALL_WARNINGS) | ||
target_compile_options(${target} PRIVATE | ||
$<$<CXX_COMPILER_ID:MSVC>:/W4> | ||
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic>) | ||
endif() | ||
if(BUILD_UNITTESTS) | ||
target_link_libraries(${target} PRIVATE Catch2::Catch2WithMain) | ||
endif() | ||
|
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 |
---|---|---|
|
@@ -7,9 +7,6 @@ | |
// | ||
// Lightweight header-only C++20 enum reflection | ||
// | ||
// Parts based on magic_enum <https://github.com/Neargye/magic_enum> | ||
// Copyright (c) 2019 - 2024 Daniil Goncharov <[email protected]>. | ||
// | ||
// Licensed under the MIT License <http://opensource.org/licenses/MIT>. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
|
@@ -71,7 +68,7 @@ const std::string demangle() noexcept | |
return typeid(T).name(); | ||
} | ||
|
||
int main(int argc, char *argv[]) | ||
int main(void) | ||
{ | ||
int total{}; | ||
auto myfunc { conjure_enum<component>::for_each([](component val, int other, int& tot) | ||
|
@@ -197,7 +194,7 @@ int main(int argc, char *argv[]) | |
const foo bar; | ||
ek.for_each(std::bind(&foo::printer, &bar, std::placeholders::_1, 10)); | ||
ek.for_each(&foo::printer, &bar, 10); | ||
enum_bitset<numbers&> er("one|three|four|eight"sv, true); | ||
//enum_bitset<numbers&> er("one|three|four|eight"sv, true); | ||
|
||
for (const auto pp : iterator_adaptor<numbers>()) | ||
std::cout << static_cast<int>(std::get<0>(pp)) << '\n'; | ||
|
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 |
---|---|---|
|
@@ -7,9 +7,6 @@ | |
// | ||
// Lightweight header-only C++20 enum reflection | ||
// | ||
// Parts based on magic_enum <https://github.com/Neargye/magic_enum> | ||
// Copyright (c) 2019 - 2024 Daniil Goncharov <[email protected]>. | ||
// | ||
// Licensed under the MIT License <http://opensource.org/licenses/MIT>. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
|
@@ -263,7 +260,7 @@ TEST_CASE("for_each") | |
TEST_CASE("enum_bitset") | ||
{ | ||
enum_bitset<numbers> eb; | ||
enum_bitset<numbers&> ebr; | ||
//enum_bitset<numbers&> ebr; | ||
eb.set_all<numbers::zero,numbers::two,numbers::five,numbers::nine>(); | ||
REQUIRE(eb.test_all<numbers::zero,numbers::two,numbers::five,numbers::nine>()); | ||
eb.reset<numbers::FIVE>(); // use alias | ||
|
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