Skip to content

Commit

Permalink
Merge pull request cppfastio#869 from ikspress/simplify
Browse files Browse the repository at this point in the history
Simplify the handling of macros and warnings
  • Loading branch information
trcrsired authored Oct 2, 2024
2 parents 3e11ed3 + 8f37ac5 commit 32a43da
Show file tree
Hide file tree
Showing 25 changed files with 264 additions and 439 deletions.
37 changes: 18 additions & 19 deletions include/fast_io.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
#pragma once
#if !defined(__cplusplus)
#error "You are not using a C++ compiler"
#endif

#if !defined(__cpp_concepts)
#error "fast_io requires at least C++20 standard compiler."
#else
#include "fast_io_hosted.h"

#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(push)
#pragma warning(disable : 4514)
#endif
#include "fast_io_legacy_impl/io.h"
#endif
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#endif
#pragma once
#if !defined(__cplusplus)
#error "You are not using a C++ compiler"
#endif

#if !defined(__cpp_concepts)
#error "fast_io requires at least C++20 standard compiler."
#else

#include "fast_io_hosted.h"

#include "fast_io_dsal/impl/misc/push_warnings.h"

#include "fast_io_legacy_impl/io.h"

#include "fast_io_dsal/impl/misc/pop_warnings.h"

#endif
21 changes: 7 additions & 14 deletions include/fast_io_concept.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
#pragma once
#undef min
#undef max
// fast_io_concept.h allows you define your device and type without compilation time penalty
#if !defined(__cplusplus)
#error "You must be using a C++ compiler"
#endif
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(push)
#pragma warning(disable : 4514)
#pragma warning(disable : 4623)
#pragma warning(disable : 4626)
#pragma warning(disable : 4668)
#pragma warning(disable : 4820)
#pragma warning(disable : 5027)
#endif
#if !defined(__cpp_concepts)
#error "fast_io requires at least a C++20 standard compiler."
#else
Expand All @@ -23,10 +12,14 @@
#include <type_traits>
#include <concepts>
#include <cstdint>

#include "fast_io_dsal/impl/misc/push_macros.h"
#include "fast_io_dsal/impl/misc/push_warnings.h"

#include "fast_io_core_impl/freestanding/addressof.h"
#include "fast_io_core_impl/concepts/impl.h"
#endif

#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#include "fast_io_dsal/impl/misc/pop_macros.h"
#include "fast_io_dsal/impl/misc/pop_warnings.h"

#endif
32 changes: 6 additions & 26 deletions include/fast_io_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,17 @@
#if !defined(__cpp_concepts)
#error "fast_io requires at least C++20 standard compiler."
#else
#include "fast_io_concept.h"
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(push)
#pragma warning(disable : 4711)
#endif
#include <bit> //for ::std::endian, ::std::rotl and ::std::bit_cast etc
#include <bit>
#include <limits>
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#endif

#include <cstdint>

#if __cpp_lib_three_way_comparison >= 201907L
#include <compare>
#endif

#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(push)
#pragma warning(disable : 4365)
#pragma warning(disable : 4514)
#pragma warning(disable : 4623)
#pragma warning(disable : 4626)
#pragma warning(disable : 4668)
#pragma warning(disable : 4710)
#pragma warning(disable : 4711)
#pragma warning(disable : 4820)
#pragma warning(disable : 5027)
#pragma warning(disable : 5045)
#endif
#include "fast_io_concept.h"

#include "fast_io_dsal/impl/misc/push_warnings.h"

#include "fast_io_core_impl/empty.h"
#if defined(_MSC_VER) && !defined(__clang__)
Expand Down Expand Up @@ -113,8 +95,6 @@
#include "fast_io_core_impl/http_header.h"
#include "fast_io_core_impl/io_lockable.h"

#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#endif
#include "fast_io_dsal/impl/misc/pop_warnings.h"

#endif
12 changes: 2 additions & 10 deletions include/fast_io_crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,12 @@

#include "fast_io_core.h"

#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(push)
#pragma warning(disable : 4514)
#pragma warning(disable : 4623)
#pragma warning(disable : 4710)
#pragma warning(disable : 4668)
#endif
#include "fast_io_dsal/impl/misc/push_warnings.h"

// #include"fast_io_crypto/symmetric_crypto.h"
// #include"fast_io_crypto/hash/intrin_include.h"
#include "fast_io_crypto/hash/impl.h"

#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#endif
#include "fast_io_dsal/impl/misc/pop_warnings.h"

#endif
23 changes: 5 additions & 18 deletions include/fast_io_dsal/array.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#pragma once
#undef min
#undef max

#if !defined(__cplusplus)
#error "You must be using a C++ compiler"
Expand All @@ -9,19 +7,9 @@
#if !defined(__cplusplus)
#error "You must be using a C++ compiler"
#endif
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(push)
#pragma warning(disable : 4464)
#pragma warning(disable : 4514)
#pragma warning(disable : 4623)
#pragma warning(disable : 4626)
#pragma warning(disable : 4668)
#pragma warning(disable : 4710)
#pragma warning(disable : 4820)
#pragma warning(disable : 5027)
#pragma warning(disable : 5045)
#include <cstring>
#endif

#include "impl/misc/push_macros.h"
#include "impl/misc/push_warnings.h"

#include "../fast_io_core.h"
#include "impl/array.h"
Expand All @@ -44,6 +32,5 @@ using ::fast_io::containers::to_array;

} // namespace fast_io

#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#endif
#include "impl/misc/pop_macros.h"
#include "impl/misc/pop_warnings.h"
30 changes: 0 additions & 30 deletions include/fast_io_dsal/cstring_view.h

This file was deleted.

23 changes: 5 additions & 18 deletions include/fast_io_dsal/deque.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
#pragma once
#undef min
#undef max

#if !defined(__cplusplus)
#error "You must be using a C++ compiler"
#endif
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(push)
#pragma warning(disable : 4464)
#pragma warning(disable : 4514)
#pragma warning(disable : 4623)
#pragma warning(disable : 4626)
#pragma warning(disable : 4668)
#pragma warning(disable : 4710)
#pragma warning(disable : 4820)
#pragma warning(disable : 5027)
#pragma warning(disable : 5045)
#include <cstring>
#endif

#include "impl/misc/push_macros.h"
#include "impl/misc/push_warnings.h"

#include <version>
#include <type_traits>
Expand Down Expand Up @@ -73,6 +61,5 @@ using deque = ::fast_io::containers::deque<T, Alloc>;

#endif

#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#endif
#include "impl/misc/pop_macros.h"
#include "impl/misc/pop_warnings.h"
6 changes: 6 additions & 0 deletions include/fast_io_dsal/impl/misc/pop_macros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Please keep it in reverse order with the macros in push_macros.h
#pragma pop_macro("erase")
#pragma pop_macro("move")
#pragma pop_macro("refresh")
#pragma pop_macro("max")
#pragma pop_macro("min")
3 changes: 3 additions & 0 deletions include/fast_io_dsal/impl/misc/pop_warnings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#endif
14 changes: 14 additions & 0 deletions include/fast_io_dsal/impl/misc/push_macros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma push_macro("min")
#undef min

#pragma push_macro("max")
#undef max

#pragma push_macro("refresh")
#undef refresh

#pragma push_macro("move")
#undef move

#pragma push_macro("erase")
#undef erase
15 changes: 15 additions & 0 deletions include/fast_io_dsal/impl/misc/push_warnings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4061)
#pragma warning(disable : 4365)
#pragma warning(disable : 4464)
#pragma warning(disable : 4514)
#pragma warning(disable : 4623)
#pragma warning(disable : 4626)
#pragma warning(disable : 4668)
#pragma warning(disable : 4710)
#pragma warning(disable : 4711)
#pragma warning(disable : 4820)
#pragma warning(disable : 5027)
#pragma warning(disable : 5045)
#endif
23 changes: 5 additions & 18 deletions include/fast_io_dsal/index_span.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#pragma once
#undef min
#undef max

#if !defined(__cplusplus)
#error "You must be using a C++ compiler"
Expand All @@ -9,19 +7,9 @@
#if !defined(__cplusplus)
#error "You must be using a C++ compiler"
#endif
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(push)
#pragma warning(disable : 4464)
#pragma warning(disable : 4514)
#pragma warning(disable : 4623)
#pragma warning(disable : 4626)
#pragma warning(disable : 4668)
#pragma warning(disable : 4710)
#pragma warning(disable : 4820)
#pragma warning(disable : 5027)
#pragma warning(disable : 5045)
#include <cstring>
#endif

#include "impl/misc/push_macros.h"
#include "impl/misc/push_warnings.h"

#include "span.h"
#include "impl/index_span.h"
Expand All @@ -39,6 +27,5 @@ using ::fast_io::containers::index_span;

} // namespace fast_io

#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#endif
#include "impl/misc/pop_macros.h"
#include "impl/misc/pop_warnings.h"
23 changes: 5 additions & 18 deletions include/fast_io_dsal/list.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
#pragma once
#undef min
#undef max

#if !defined(__cplusplus)
#error "You must be using a C++ compiler"
#endif
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(push)
#pragma warning(disable : 4464)
#pragma warning(disable : 4514)
#pragma warning(disable : 4623)
#pragma warning(disable : 4626)
#pragma warning(disable : 4668)
#pragma warning(disable : 4710)
#pragma warning(disable : 4820)
#pragma warning(disable : 5027)
#pragma warning(disable : 5045)
#include <cstring>
#endif

#include "impl/misc/push_macros.h"
#include "impl/misc/push_warnings.h"

#include <version>
#include <type_traits>
Expand Down Expand Up @@ -73,6 +61,5 @@ using list = ::fast_io::containers::list<T, Alloc>;

#endif

#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#endif
#include "impl/misc/pop_macros.h"
#include "impl/misc/pop_warnings.h"
Loading

0 comments on commit 32a43da

Please sign in to comment.