From 70fed7085c0e9b7207f54d5165cff27fb9a887bc Mon Sep 17 00:00:00 2001 From: Jason Burmark Date: Tue, 11 Jun 2024 10:31:48 -0700 Subject: [PATCH] Allow std tuple_size and tuple_element before C++17 There's no reason to not supply them before 17. They can still be used in code for generic tuple-like classes. --- include/camp/array.hpp | 2 -- include/camp/tuple.hpp | 2 -- test/array.cpp | 3 ++- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/include/camp/array.hpp b/include/camp/array.hpp index 4e006d6..54fea98 100644 --- a/include/camp/array.hpp +++ b/include/camp/array.hpp @@ -274,7 +274,6 @@ namespace camp { #endif } // namespace camp -#if defined(__cplusplus) && __cplusplus >= 201703L // For structured bindings namespace std { template @@ -288,7 +287,6 @@ namespace std { using type = T; }; } -#endif #endif // !defined(CAMP_ARRAY_H) diff --git a/include/camp/tuple.hpp b/include/camp/tuple.hpp index 6607b43..fb18095 100644 --- a/include/camp/tuple.hpp +++ b/include/camp/tuple.hpp @@ -691,7 +691,6 @@ auto operator<<(std::ostream& os, camp::tuple const& tup) return os << ")"; } -#if defined(__cplusplus) && __cplusplus >= 201703L namespace std { /// This allows structured bindings to be used with camp::tuple /// e.g. auto t = make_tuple(1, 2.0); @@ -721,6 +720,5 @@ namespace std { using type = ::camp::tuple_element_t>; }; } // namespace std -#endif #endif /* camp_tuple_HPP__ */ diff --git a/test/array.cpp b/test/array.cpp index 1d22752..b3ec86c 100644 --- a/test/array.cpp +++ b/test/array.cpp @@ -359,7 +359,6 @@ CAMP_TEST_BEGIN(array, to_array) b[2] == 10; } CAMP_TEST_END(array, to_array) -#if defined(__cplusplus) && __cplusplus >= 201703L CAMP_TEST_BEGIN(array, tuple_size) { @@ -379,6 +378,8 @@ CAMP_TEST_BEGIN(array, tuple_element) element4; } CAMP_TEST_END(array, tuple_element) +#if defined(__cplusplus) && __cplusplus >= 201703L + CAMP_TEST_BEGIN(array, structured_binding) { camp::array a{-1, 1};