Added FMT_IMPORT_STD feature macro (#3928)

This commit is contained in:
Matthias Moulin 2024-04-10 20:48:32 +02:00 committed by GitHub
parent 5eb68c0ef2
commit 116a9ce488
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 137 additions and 98 deletions

View File

@ -8,9 +8,11 @@
#ifndef FMT_ARGS_H_ #ifndef FMT_ARGS_H_
#define FMT_ARGS_H_ #define FMT_ARGS_H_
#include <functional> // std::reference_wrapper #ifndef FMT_IMPORT_STD
#include <memory> // std::unique_ptr # include <functional> // std::reference_wrapper
#include <vector> # include <memory> // std::unique_ptr
# include <vector>
#endif
#include "format.h" // std_string_view #include "format.h" // std_string_view

View File

@ -12,9 +12,13 @@
#include <stdio.h> // FILE #include <stdio.h> // FILE
#include <string.h> // strlen #include <string.h> // strlen
#ifndef FMT_IMPORT_STD
// <cstddef> is also included transitively from <type_traits>. // <cstddef> is also included transitively from <type_traits>.
#include <cstddef> // std::byte # include <cstddef> // std::byte
#include <type_traits> // std::enable_if # include <type_traits> // std::enable_if
#else
import std;
#endif
// The fmt library version in the form major * 10000 + minor * 100 + patch. // The fmt library version in the form major * 10000 + minor * 100 + patch.
#define FMT_VERSION 100202 #define FMT_VERSION 100202

View File

@ -8,15 +8,17 @@
#ifndef FMT_CHRONO_H_ #ifndef FMT_CHRONO_H_
#define FMT_CHRONO_H_ #define FMT_CHRONO_H_
#include <algorithm> #ifndef FMT_IMPORT_STD
#include <chrono> # include <algorithm>
#include <cmath> // std::isfinite # include <chrono>
#include <cstring> // std::memcpy # include <cmath> // std::isfinite
#include <ctime> # include <cstring> // std::memcpy
#include <iterator> # include <ctime>
#include <locale> # include <iterator>
#include <ostream> # include <locale>
#include <type_traits> # include <ostream>
# include <type_traits>
#endif
#include "format.h" #include "format.h"

View File

@ -8,7 +8,9 @@
#ifndef FMT_COMPILE_H_ #ifndef FMT_COMPILE_H_
#define FMT_COMPILE_H_ #define FMT_COMPILE_H_
#include <iterator> // std::back_inserter #ifndef FMT_IMPORT_STD
# include <iterator> // std::back_inserter
#endif
#include "format.h" #include "format.h"

View File

@ -8,13 +8,15 @@
#ifndef FMT_FORMAT_INL_H_ #ifndef FMT_FORMAT_INL_H_
#define FMT_FORMAT_INL_H_ #define FMT_FORMAT_INL_H_
#include <algorithm> #ifndef FMT_IMPORT_STD
# include <algorithm>
# include <cmath>
# include <exception>
#endif
#include <cerrno> // errno #include <cerrno> // errno
#include <climits> #include <climits>
#include <cmath>
#include <exception>
#ifndef FMT_STATIC_THOUSANDS_SEPARATOR #if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) && !defined(FMT_IMPORT_STD)
# include <locale> # include <locale>
#endif #endif

View File

@ -38,30 +38,35 @@
# define FMT_REMOVE_TRANSITIVE_INCLUDES # define FMT_REMOVE_TRANSITIVE_INCLUDES
#endif #endif
#include <cmath> // std::signbit #ifndef FMT_IMPORT_STD
#include <cstdint> // uint32_t # include <cmath> // std::signbit
#include <cstring> // std::memcpy # include <cstdint> // uint32_t
#include <initializer_list> // std::initializer_list # include <cstring> // std::memcpy
#include <limits> // std::numeric_limits # include <initializer_list> // std::initializer_list
#if defined(__GLIBCXX__) && !defined(_GLIBCXX_USE_DUAL_ABI) # include <limits> // std::numeric_limits
# if defined(__GLIBCXX__) && !defined(_GLIBCXX_USE_DUAL_ABI)
// Workaround for pre gcc 5 libstdc++. // Workaround for pre gcc 5 libstdc++.
# include <memory> // std::allocator_traits # include <memory> // std::allocator_traits
# endif
# include <stdexcept> // std::runtime_error
# include <string> // std::string
# include <system_error> // std::system_error
#endif #endif
#include <stdexcept> // std::runtime_error
#include <string> // std::string
#include <system_error> // std::system_error
#include "base.h" #include "base.h"
// Checking FMT_CPLUSPLUS for warning suppression in MSVC. // Checking FMT_CPLUSPLUS for warning suppression in MSVC.
#if FMT_HAS_INCLUDE(<bit>) && FMT_CPLUSPLUS > 201703L #if FMT_HAS_INCLUDE(<bit>) && FMT_CPLUSPLUS > 201703L && \
!defined(FMT_IMPORT_STD)
# include <bit> // std::bit_cast # include <bit> // std::bit_cast
#endif #endif
// libc++ supports string_view in pre-c++17. // libc++ supports string_view in pre-c++17.
#if FMT_HAS_INCLUDE(<string_view>) && \ #if FMT_HAS_INCLUDE(<string_view>) && \
(FMT_CPLUSPLUS >= 201703L || defined(_LIBCPP_VERSION)) (FMT_CPLUSPLUS >= 201703L || defined(_LIBCPP_VERSION))
# include <string_view> # ifndef FMT_IMPORT_STD
# include <string_view>
# endif
# define FMT_USE_STRING_VIEW # define FMT_USE_STRING_VIEW
#endif #endif

View File

@ -9,9 +9,11 @@
#define FMT_OS_H_ #define FMT_OS_H_
#include <cerrno> #include <cerrno>
#include <cstddef> #ifndef FMT_IMPORT_STD
#include <cstdio> # include <cstddef>
#include <system_error> // std::system_error # include <cstdio>
# include <system_error> // std::system_error
#endif
#include "format.h" #include "format.h"

View File

@ -8,7 +8,9 @@
#ifndef FMT_OSTREAM_H_ #ifndef FMT_OSTREAM_H_
#define FMT_OSTREAM_H_ #define FMT_OSTREAM_H_
#include <fstream> // std::filebuf #ifndef FMT_IMPORT_STD
# include <fstream> // std::filebuf
#endif
#ifdef _WIN32 #ifdef _WIN32
# ifdef __GLIBCXX__ # ifdef __GLIBCXX__

View File

@ -8,8 +8,10 @@
#ifndef FMT_PRINTF_H_ #ifndef FMT_PRINTF_H_
#define FMT_PRINTF_H_ #define FMT_PRINTF_H_
#include <algorithm> // std::max #ifndef FMT_IMPORT_STD
#include <limits> // std::numeric_limits # include <algorithm> // std::max
# include <limits> // std::numeric_limits
#endif
#include "format.h" #include "format.h"

View File

@ -8,10 +8,12 @@
#ifndef FMT_RANGES_H_ #ifndef FMT_RANGES_H_
#define FMT_RANGES_H_ #define FMT_RANGES_H_
#include <initializer_list> #ifndef FMT_IMPORT_STD
#include <iterator> # include <initializer_list>
#include <tuple> # include <iterator>
#include <type_traits> # include <tuple>
# include <type_traits>
#endif
#include "format.h" #include "format.h"

View File

@ -8,17 +8,19 @@
#ifndef FMT_STD_H_ #ifndef FMT_STD_H_
#define FMT_STD_H_ #define FMT_STD_H_
#include <atomic> #ifndef FMT_IMPORT_STD
#include <bitset> # include <atomic>
#include <complex> # include <bitset>
#include <cstdlib> # include <complex>
#include <exception> # include <cstdlib>
#include <memory> # include <exception>
#include <thread> # include <memory>
#include <type_traits> # include <thread>
#include <typeinfo> # include <type_traits>
#include <utility> # include <typeinfo>
#include <vector> # include <utility>
# include <vector>
#endif
#include "format.h" #include "format.h"
#include "ostream.h" #include "ostream.h"
@ -26,25 +28,28 @@
#if FMT_HAS_INCLUDE(<version>) #if FMT_HAS_INCLUDE(<version>)
# include <version> # include <version>
#endif #endif
#ifndef FMT_IMPORT_STD
// Checking FMT_CPLUSPLUS for warning suppression in MSVC. // Checking FMT_CPLUSPLUS for warning suppression in MSVC.
#if FMT_CPLUSPLUS >= 201703L # if FMT_CPLUSPLUS >= 201703L
# if FMT_HAS_INCLUDE(<filesystem>) # if FMT_HAS_INCLUDE(<filesystem>)
# include <filesystem> # include <filesystem>
# endif
# if FMT_HAS_INCLUDE(<variant>)
# include <variant>
# endif
# if FMT_HAS_INCLUDE(<optional>)
# include <optional>
# endif
# endif # endif
# if FMT_HAS_INCLUDE(<variant>)
# include <variant>
# endif
# if FMT_HAS_INCLUDE(<optional>)
# include <optional>
# endif
#endif
#if FMT_HAS_INCLUDE(<expected>) && FMT_CPLUSPLUS > 202002L # if FMT_HAS_INCLUDE(<expected>) && FMT_CPLUSPLUS > 202002L
# include <expected> # include <expected>
#endif # endif
#if FMT_CPLUSPLUS > 201703L && FMT_HAS_INCLUDE(<source_location>) # if FMT_CPLUSPLUS > 201703L && FMT_HAS_INCLUDE(<source_location>)
# include <source_location> # include <source_location>
# endif
#endif #endif
// GCC 4 does not support FMT_HAS_INCLUDE. // GCC 4 does not support FMT_HAS_INCLUDE.

View File

@ -8,13 +8,15 @@
#ifndef FMT_XCHAR_H_ #ifndef FMT_XCHAR_H_
#define FMT_XCHAR_H_ #define FMT_XCHAR_H_
#include <cwchar> #ifndef FMT_IMPORT_STD
# include <cwchar>
#endif
#include "color.h" #include "color.h"
#include "format.h" #include "format.h"
#include "ranges.h" #include "ranges.h"
#ifndef FMT_STATIC_THOUSANDS_SEPARATOR #if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) && !defined(FMT_IMPORT_STD)
# include <locale> # include <locale>
#endif #endif

View File

@ -2,37 +2,44 @@ module;
// Put all implementation-provided headers into the global module fragment // Put all implementation-provided headers into the global module fragment
// to prevent attachment to this module. // to prevent attachment to this module.
#include <algorithm> #ifndef FMT_IMPORT_STD
# include <algorithm>
# include <chrono>
# include <cmath>
# include <cstddef>
# include <cstdint>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <ctime>
# include <exception>
# include <filesystem>
# include <fstream>
# include <functional>
# include <iterator>
# include <limits>
# include <locale>
# include <memory>
# include <optional>
# include <ostream>
# include <stdexcept>
# include <string>
# include <string_view>
# include <system_error>
# include <thread>
# include <type_traits>
# include <typeinfo>
# include <utility>
# include <variant>
# include <vector>
#else
# include <limits.h>
# include <stdint.h>
# include <stdio.h>
# include <time.h>
#endif
#include <cerrno> #include <cerrno>
#include <chrono>
#include <climits> #include <climits>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <exception>
#include <filesystem>
#include <fstream>
#include <functional>
#include <iterator>
#include <limits>
#include <locale>
#include <memory>
#include <optional>
#include <ostream>
#include <stdexcept>
#include <string>
#include <string_view>
#include <system_error>
#include <thread>
#include <type_traits>
#include <typeinfo>
#include <utility>
#include <variant>
#include <vector>
#include <version> #include <version>
#if __has_include(<cxxabi.h>) #if __has_include(<cxxabi.h>)