Skip to content

Commit

Permalink
Allow std tuple_size and tuple_element before C++17
Browse files Browse the repository at this point in the history
There's no reason to not supply them before 17.
They can still be used in code for generic tuple-like classes.
  • Loading branch information
MrBurmark committed Jun 11, 2024
1 parent 1a2050b commit 70fed70
Showing 3 changed files with 2 additions and 5 deletions.
2 changes: 0 additions & 2 deletions include/camp/array.hpp
Original file line number Diff line number Diff line change
@@ -274,7 +274,6 @@ namespace camp {
#endif
} // namespace camp

#if defined(__cplusplus) && __cplusplus >= 201703L
// For structured bindings
namespace std {
template <class T, std::size_t N>
@@ -288,7 +287,6 @@ namespace std {
using type = T;
};
}
#endif

#endif // !defined(CAMP_ARRAY_H)

2 changes: 0 additions & 2 deletions include/camp/tuple.hpp
Original file line number Diff line number Diff line change
@@ -691,7 +691,6 @@ auto operator<<(std::ostream& os, camp::tuple<Args...> 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<i, camp::tagged_tuple<TagList, Elements...>>;
};
} // namespace std
#endif

#endif /* camp_tuple_HPP__ */
3 changes: 2 additions & 1 deletion test/array.cpp
Original file line number Diff line number Diff line change
@@ -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<int, 2> a{-1, 1};

0 comments on commit 70fed70

Please sign in to comment.