From fbfdda66fdc351d9d62d7ca2b44ae248a5800d3f Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Wed, 10 Apr 2024 12:28:57 +0100 Subject: [PATCH] Clean up #includes. --- include/boost/regex/config.hpp | 6 ++--- include/boost/regex/v5/match_flags.hpp | 2 ++ module/regex.cxx | 30 +++++++++++++++-------- test/module/credit_card_example.cpp | 4 +++ test/module/partial_regex_grep.cpp | 4 +++ test/module/partial_regex_iterate.cpp | 4 +++ test/module/partial_regex_match.cpp | 4 +++ test/module/regex_grep_example_1.cpp | 4 +++ test/module/regex_grep_example_2.cpp | 4 +++ test/module/regex_grep_example_3.cpp | 4 +++ test/module/regex_iterator_example.cpp | 4 +++ test/module/regex_match_example.cpp | 4 +++ test/module/regex_merge_example.cpp | 4 +++ test/module/regex_replace_example.cpp | 4 +++ test/module/regex_search_example.cpp | 4 +++ test/module/regex_split_example_1.cpp | 4 +++ test/module/regex_split_example_2.cpp | 4 +++ test/module/regex_token_iterator_eg_1.cpp | 4 +++ test/module/regex_token_iterator_eg_2.cpp | 6 +++-- 19 files changed, 89 insertions(+), 15 deletions(-) diff --git a/include/boost/regex/config.hpp b/include/boost/regex/config.hpp index 89faa02b..c2c4fd0f 100644 --- a/include/boost/regex/config.hpp +++ b/include/boost/regex/config.hpp @@ -58,9 +58,11 @@ #ifdef BOOST_REGEX_STANDALONE #ifndef BOOST_REGEX_AS_MODULE #include -#endif # define BOOST_REGEX_ASSERT(x) assert(x) #else +# define BOOST_REGEX_ASSERT(x) do{ if(x == 0) { std::printf("%s:%d Assertion Failed", __FILE__, __LINE__); std::abort(); } }while(0) +#endif +#else #include # define BOOST_REGEX_ASSERT(x) BOOST_ASSERT(x) #endif @@ -302,8 +304,6 @@ * If there are no exceptions then we must report critical-errors * the only way we know how; by terminating. */ -#include - # define BOOST_REGEX_NOEH_ASSERT(x) assert(x); #else /* diff --git a/include/boost/regex/v5/match_flags.hpp b/include/boost/regex/v5/match_flags.hpp index 7c4ee5f5..d653d172 100644 --- a/include/boost/regex/v5/match_flags.hpp +++ b/include/boost/regex/v5/match_flags.hpp @@ -19,9 +19,11 @@ #ifndef BOOST_REGEX_V5_MATCH_FLAGS #define BOOST_REGEX_V5_MATCH_FLAGS +#ifndef BOOST_REGEX_AS_MODULE #ifdef __cplusplus # include #endif +#endif #ifdef __cplusplus namespace boost{ diff --git a/module/regex.cxx b/module/regex.cxx index 3071f89a..4cf40f9f 100644 --- a/module/regex.cxx +++ b/module/regex.cxx @@ -1,18 +1,15 @@ module; +#if defined(__cpp_lib_modules) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 193933523)) +#define BOOST_REGEX_USE_STD_MODULE +#endif + #if defined(_WIN32) && __has_include() -// -// This has to appear *before* import std; otherwise the compiler chokes. -// #include #endif -#ifdef __cpp_lib_modules -import std; -#elif defined(MSVC_EXPERIMENTAL_STD_MODULE) -import std.core; -#else +#if !defined(BOOST_REGEX_USE_STD_MODULE) && !defined(MSVC_EXPERIMENTAL_STD_MODULE) #include #include #include @@ -47,10 +44,13 @@ import std.core; #ifdef BOOST_HAS_THREADS #include #endif -#endif - #include #include +#endif + +#if !defined(BOOST_REGEX_USE_STD_MODULE) && defined(MSVC_EXPERIMENTAL_STD_MODULE) +#include +#endif #if __has_include() #include @@ -64,6 +64,16 @@ import std.core; export module boost.regex; +#if defined(BOOST_REGEX_USE_STD_MODULE) +import std; +#elif defined(MSVC_EXPERIMENTAL_STD_MODULE) +import std.core; +#endif + +#ifdef _MSC_FULL_VER +#pragma warning(disable:5244) +#endif + #include #if __has_include() diff --git a/test/module/credit_card_example.cpp b/test/module/credit_card_example.cpp index 15f8aa09..611a8d4d 100644 --- a/test/module/credit_card_example.cpp +++ b/test/module/credit_card_example.cpp @@ -25,7 +25,11 @@ import std.core; #include #endif +#ifdef TEST_HEADERS +#include +#else import boost.regex; +#endif bool validate_card_format(const std::string& s) diff --git a/test/module/partial_regex_grep.cpp b/test/module/partial_regex_grep.cpp index 437c37f0..ab1ab7c3 100644 --- a/test/module/partial_regex_grep.cpp +++ b/test/module/partial_regex_grep.cpp @@ -28,7 +28,11 @@ import std.core; #include #endif +#ifdef TEST_HEADERS +#include +#else import boost.regex; +#endif // match some kind of html tag: boost::regex e("<[^>]*>"); diff --git a/test/module/partial_regex_iterate.cpp b/test/module/partial_regex_iterate.cpp index 887abdc2..f7af6f59 100644 --- a/test/module/partial_regex_iterate.cpp +++ b/test/module/partial_regex_iterate.cpp @@ -28,7 +28,11 @@ import std.core; #include #endif +#ifdef TEST_HEADERS +#include +#else import boost.regex; +#endif #ifdef BOOST_NO_STDC_NAMESPACE namespace std{ using ::memmove; } diff --git a/test/module/partial_regex_match.cpp b/test/module/partial_regex_match.cpp index fc7c2273..f262aeb7 100644 --- a/test/module/partial_regex_match.cpp +++ b/test/module/partial_regex_match.cpp @@ -28,7 +28,11 @@ import std.core; #include #endif +#ifdef TEST_HEADERS +#include +#else import boost.regex; +#endif boost::regex e("(\\d{3,4})[- ]?(\\d{4})[- ]?(\\d{4})[- ]?(\\d{4})"); diff --git a/test/module/regex_grep_example_1.cpp b/test/module/regex_grep_example_1.cpp index f8cf35a1..d7b7bcfc 100644 --- a/test/module/regex_grep_example_1.cpp +++ b/test/module/regex_grep_example_1.cpp @@ -28,7 +28,11 @@ import std.core; #endif +#ifdef TEST_HEADERS +#include +#else import boost.regex; +#endif // purpose: // takes the contents of a file in the form of a string diff --git a/test/module/regex_grep_example_2.cpp b/test/module/regex_grep_example_2.cpp index dd27c1be..e25724b1 100644 --- a/test/module/regex_grep_example_2.cpp +++ b/test/module/regex_grep_example_2.cpp @@ -28,7 +28,11 @@ import std.core; #include #endif +#ifdef TEST_HEADERS +#include +#else import boost.regex; +#endif // purpose: // takes the contents of a file in the form of a string diff --git a/test/module/regex_grep_example_3.cpp b/test/module/regex_grep_example_3.cpp index c796497d..4b3040ee 100644 --- a/test/module/regex_grep_example_3.cpp +++ b/test/module/regex_grep_example_3.cpp @@ -29,7 +29,11 @@ import std.core; #include #endif +#ifdef TEST_HEADERS +#include +#else import boost.regex; +#endif // purpose: // takes the contents of a file in the form of a string diff --git a/test/module/regex_iterator_example.cpp b/test/module/regex_iterator_example.cpp index 29803f1a..c061425d 100644 --- a/test/module/regex_iterator_example.cpp +++ b/test/module/regex_iterator_example.cpp @@ -29,7 +29,11 @@ import std.core; #include #endif +#ifdef TEST_HEADERS +#include +#else import boost.regex; +#endif using namespace std; diff --git a/test/module/regex_match_example.cpp b/test/module/regex_match_example.cpp index b42a198f..99da2252 100644 --- a/test/module/regex_match_example.cpp +++ b/test/module/regex_match_example.cpp @@ -27,7 +27,11 @@ import std.core; #include #endif +#ifdef TEST_HEADERS +#include +#else import boost.regex; +#endif using namespace std; using namespace boost; diff --git a/test/module/regex_merge_example.cpp b/test/module/regex_merge_example.cpp index bced4db9..5110b74b 100644 --- a/test/module/regex_merge_example.cpp +++ b/test/module/regex_merge_example.cpp @@ -31,7 +31,11 @@ import std.core; #include #endif +#ifdef TEST_HEADERS +#include +#else import boost.regex; +#endif // purpose: // takes the contents of a file and transform to diff --git a/test/module/regex_replace_example.cpp b/test/module/regex_replace_example.cpp index 65d94623..03fcc464 100644 --- a/test/module/regex_replace_example.cpp +++ b/test/module/regex_replace_example.cpp @@ -31,7 +31,11 @@ import std.core; #include #endif +#ifdef TEST_HEADERS +#include +#else import boost.regex; +#endif // purpose: // takes the contents of a file and transform to diff --git a/test/module/regex_search_example.cpp b/test/module/regex_search_example.cpp index 05fa08ee..6d644562 100644 --- a/test/module/regex_search_example.cpp +++ b/test/module/regex_search_example.cpp @@ -27,7 +27,11 @@ import std.core; #include #endif +#ifdef TEST_HEADERS +#include +#else import boost.regex; +#endif // purpose: // takes the contents of a file in the form of a string diff --git a/test/module/regex_split_example_1.cpp b/test/module/regex_split_example_1.cpp index 905d2a02..b4935809 100644 --- a/test/module/regex_split_example_1.cpp +++ b/test/module/regex_split_example_1.cpp @@ -27,7 +27,11 @@ import std.core; #include #endif +#ifdef TEST_HEADERS +#include +#else import boost.regex; +#endif unsigned tokenise(std::list& l, std::string& s) { diff --git a/test/module/regex_split_example_2.cpp b/test/module/regex_split_example_2.cpp index b146291d..e96724c0 100644 --- a/test/module/regex_split_example_2.cpp +++ b/test/module/regex_split_example_2.cpp @@ -28,7 +28,11 @@ import std.core; #include #endif +#ifdef TEST_HEADERS +#include +#else import boost.regex; +#endif boost::regex e("<\\s*A\\s+[^>]*href\\s*=\\s*\"([^\"]*)\"", boost::regex::normal | boost::regex::icase); diff --git a/test/module/regex_token_iterator_eg_1.cpp b/test/module/regex_token_iterator_eg_1.cpp index df38d02c..0eebca93 100644 --- a/test/module/regex_token_iterator_eg_1.cpp +++ b/test/module/regex_token_iterator_eg_1.cpp @@ -26,7 +26,11 @@ import std.core; #include #endif +#ifdef TEST_HEADERS +#include +#else import boost.regex; +#endif using namespace std; diff --git a/test/module/regex_token_iterator_eg_2.cpp b/test/module/regex_token_iterator_eg_2.cpp index b493636f..0304cad0 100644 --- a/test/module/regex_token_iterator_eg_2.cpp +++ b/test/module/regex_token_iterator_eg_2.cpp @@ -16,8 +16,11 @@ * DESCRIPTION: regex_token_iterator example: spit out linked URL's. */ - +#ifdef TEST_HEADERS +#include +#else import boost.regex; +#endif #ifdef __cpp_lib_modules import std; @@ -28,7 +31,6 @@ import std.core; #include #include #endif - boost::regex e("<\\s*A\\s+[^>]*href\\s*=\\s*\"([^\"]*)\"", boost::regex::normal | boost::regex::icase);