diff --git a/include/gsl/algorithm b/include/gsl/algorithm index c67f35ab..8ba677d5 100644 --- a/include/gsl/algorithm +++ b/include/gsl/algorithm @@ -20,9 +20,13 @@ #include "./assert" // for Expects #include "./span" // for dynamic_extent, span -#include // for copy_n -#include // for ptrdiff_t -#include // for is_assignable +#if defined(GSL_BUILD_USING_STD_MODULE) + import std; +#else + #include // for copy_n + #include // for ptrdiff_t + #include // for is_assignable +#endif #ifdef _MSC_VER #pragma warning(push) diff --git a/include/gsl/assert b/include/gsl/assert index d3e6ccdd..25aef788 100644 --- a/include/gsl/assert +++ b/include/gsl/assert @@ -36,7 +36,11 @@ #else // defined(_MSC_VER) && (defined(_KERNEL_MODE) || (defined(_HAS_EXCEPTIONS) && // !_HAS_EXCEPTIONS)) -#include +#if defined(GSL_BUILD_USING_STD_MODULE) + import std; +#else + #include +#endif #endif // defined(_MSC_VER) && (defined(_KERNEL_MODE) || (defined(_HAS_EXCEPTIONS) && // !_HAS_EXCEPTIONS)) diff --git a/include/gsl/byte b/include/gsl/byte index fe9b2866..c220e0cc 100644 --- a/include/gsl/byte +++ b/include/gsl/byte @@ -19,7 +19,11 @@ #include "./util" // for GSL_DEPRECATED -#include +#if defined(GSL_BUILD_USING_STD_MODULE) + import std; +#else + #include +#endif #ifdef _MSC_VER @@ -45,7 +49,9 @@ #else // _MSC_VER #ifndef GSL_USE_STD_BYTE -#include /* __cpp_lib_byte */ +#if !defined(GSL_BUILD_USING_STD_MODULE) + #include /* __cpp_lib_byte */ +#endif // this tests if we are under GCC or Clang with enough -std=c++1z power to get us std::byte // also check if libc++ version is sufficient (> 5.0) or libstdc++ actually contains std::byte #if defined(__cplusplus) && (__cplusplus >= 201703L) && \ @@ -75,7 +81,9 @@ #endif // defined __clang__ || defined __GNUC__ #if GSL_USE_STD_BYTE -#include +#if !defined(GSL_BUILD_USING_STD_MODULE) + #include +#endif #endif namespace gsl diff --git a/include/gsl/narrow b/include/gsl/narrow index bee29a1a..b6e753b6 100644 --- a/include/gsl/narrow +++ b/include/gsl/narrow @@ -18,7 +18,13 @@ #define GSL_NARROW_H #include "./assert" // for GSL_SUPPRESS #include "./util" // for narrow_cast -#include // for std::exception + +#if defined(GSL_BUILD_USING_STD_MODULE) + import std; +#else + #include // for std::exception +#endif + namespace gsl { struct narrowing_error : public std::exception diff --git a/include/gsl/pointers b/include/gsl/pointers index 5e69f589..a196af8a 100644 --- a/include/gsl/pointers +++ b/include/gsl/pointers @@ -20,15 +20,19 @@ #include "./assert" // for Ensures, Expects #include "./util" // for GSL_DEPRECATED -#include // for ptrdiff_t, nullptr_t, size_t -#include // for less, greater -#include // for shared_ptr, unique_ptr, hash -#include // for enable_if_t, is_convertible, is_assignable -#include // for declval, forward - -#if !defined(GSL_NO_IOSTREAMS) -#include // for ostream -#endif // !defined(GSL_NO_IOSTREAMS) +#if defined(GSL_BUILD_USING_STD_MODULE) + import std; +#else + #include // for ptrdiff_t, nullptr_t, size_t + #include // for less, greater + #include // for shared_ptr, unique_ptr, hash + #include // for enable_if_t, is_convertible, is_assignable + #include // for declval, forward + + #if !defined(GSL_NO_IOSTREAMS) + #include // for ostream + #endif // !defined(GSL_NO_IOSTREAMS) +#endif namespace gsl { diff --git a/include/gsl/span b/include/gsl/span index cef8a774..8e23e77e 100644 --- a/include/gsl/span +++ b/include/gsl/span @@ -22,11 +22,15 @@ #include "./span_ext" // for span specialization of gsl::at and other span-related extensions #include "./util" // for narrow_cast -#include // for array -#include // for ptrdiff_t, size_t, nullptr_t -#include // for reverse_iterator, distance, random_access_... -#include // for pointer_traits -#include // for enable_if_t, declval, is_convertible, inte... +#if defined(GSL_BUILD_USING_STD_MODULE) + import std; +#else + #include // for array + #include // for ptrdiff_t, size_t, nullptr_t + #include // for reverse_iterator, distance, random_access_... + #include // for pointer_traits + #include // for enable_if_t, declval, is_convertible, inte... +#endif #if defined(__has_include) && __has_include() #include diff --git a/include/gsl/span_ext b/include/gsl/span_ext index 8b2c2c94..ef9d0785 100644 --- a/include/gsl/span_ext +++ b/include/gsl/span_ext @@ -30,12 +30,16 @@ #include "./assert" // GSL_KERNEL_MODE #include "./util" // for narrow_cast, narrow -#include // for ptrdiff_t, size_t -#include - -#ifndef GSL_KERNEL_MODE -#include // for lexicographical_compare -#endif // GSL_KERNEL_MODE +#if defined(GSL_BUILD_USING_STD_MODULE) + import std; +#else + #include // for ptrdiff_t, size_t + #include + + #ifndef GSL_KERNEL_MODE + #include // for lexicographical_compare + #endif // GSL_KERNEL_MODE +#endif namespace gsl { diff --git a/include/gsl/util b/include/gsl/util index 7a3caed4..f3451133 100644 --- a/include/gsl/util +++ b/include/gsl/util @@ -19,17 +19,23 @@ #include "./assert" // for Expects -#include -#include // for ptrdiff_t, size_t -#include // for numeric_limits -#include // for initializer_list -#include // for is_signed, integral_constant -#include // for exchange, forward +#if defined(GSL_BUILD_USING_STD_MODULE) + import std; +#else + #include + #include // for ptrdiff_t, size_t + #include // for numeric_limits + #include // for initializer_list + #include // for is_signed, integral_constant + #include // for exchange, forward +#endif #if defined(__has_include) && __has_include() -#include + #include #if defined(__cpp_lib_span) && __cpp_lib_span >= 202002L -#include +#if !defined(GSL_BUILD_USING_STD_MODULE) + #include +#endif #endif // __cpp_lib_span >= 202002L #endif //__has_include() diff --git a/include/gsl/zstring b/include/gsl/zstring index f00aa055..a66622f7 100644 --- a/include/gsl/zstring +++ b/include/gsl/zstring @@ -19,7 +19,11 @@ #include "./span_ext" // for dynamic_extent -#include // for size_t, nullptr_t +#if defined(GSL_BUILD_USING_STD_MODULE) + import std; +#else + #include // for size_t, nullptr_t +#endif namespace gsl {