Skip to content

Commit

Permalink
Merge pull request #259 from ruby-rice/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
cfis authored Feb 19, 2025
2 parents 8b02a3c + 7fa36c4 commit 853fea1
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 27 deletions.
17 changes: 0 additions & 17 deletions rice/detail/TupleIterator.hpp

This file was deleted.

8 changes: 3 additions & 5 deletions rice/detail/Type.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,16 @@ namespace Rice::detail
}

template<typename Tuple_T, size_t...Is>
void verifyTypesImpl()
void verifyTypesImpl(std::index_sequence<Is...> indexes)
{
(verifyType<typename std::tuple_element<Is, Tuple_T>::type>(), ...);
}

template<typename Tuple_T>
void verifyTypes()
{
if constexpr (std::tuple_size<Tuple_T>::value > 0)
{
verifyTypesImpl<Tuple_T, std::tuple_size<Tuple_T>::value - 1>();
}
std::make_index_sequence<std::tuple_size_v<Tuple_T>> indexes;
verifyTypesImpl<Tuple_T>(indexes);
}

inline std::string demangle(char const* mangled_name)
Expand Down
3 changes: 0 additions & 3 deletions rice/rice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
#include "traits/method_traits.hpp"
#include "traits/attribute_traits.hpp"

// Helpers
#include "detail/TupleIterator.hpp"

// Code for C++ to call Ruby
#include "Exception.hpp"
#include "JumpException.hpp"
Expand Down
1 change: 0 additions & 1 deletion rice/stl/tuple.ipp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <tuple>
#include "../detail/TupleIterator.hpp"

namespace Rice::detail
{
Expand Down
1 change: 0 additions & 1 deletion rice/stl/variant.ipp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <variant>
#include "../detail/TupleIterator.hpp"

namespace Rice::detail
{
Expand Down
9 changes: 9 additions & 0 deletions rice/traits/rice_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ namespace Rice
template<class T>
constexpr bool is_pointer_pointer_v = is_pointer_pointer<T>::value;

// See https://www.cppstories.com/2022/tuple-iteration-apply/
template <typename Tuple_T, typename Function_T>
void for_each_tuple(Tuple_T&& tuple, Function_T&& callable)
{
std::apply([&callable](auto&& ...args)
{
(callable(std::forward<decltype(args)>(args)), ...);
}, std::forward<Tuple_T>(tuple));
}
} // detail
} // Rice

Expand Down

0 comments on commit 853fea1

Please sign in to comment.