Commit 2c10f815 authored by Paul's avatar Paul
Browse files

Add workaround for gcc 5

parent 81134ed5
......@@ -4,8 +4,8 @@ project(rtglib)
find_package(ROCM REQUIRED)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.5")
message(FATAL_ERROR "RTGLib requires at least gcc 5.5")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.4")
message(FATAL_ERROR "RTGLib requires at least gcc 5.4")
endif()
endif()
......
......@@ -96,6 +96,25 @@ struct raw_data
}
};
namespace detail {
template<class V, class... Ts>
void visit_all_impl(const shape& s, V&& v, Ts&&... xs)
{
s.visit_type([&](auto as) {
v(make_view(xs.get_shape(), as.from(xs.data()))...);
});
}
}
/**
* @brief Visits every object together
* @details This will visit every object, but assumes each object is the same type. This can reduce the deeply nested visit calls. This will return a function that will take the visitor callback. So it will be called with `visit_all(xs...)([](auto... ys) {})` where `xs...` and `ys...` are the same number of parameters.
*
* @param x A raw data object
* @param xs Many raw data objects
* @return A function to be called with the visitor
*/
template <class T, class... Ts>
auto visit_all(T&& x, Ts&&... xs)
{
......@@ -104,9 +123,8 @@ auto visit_all(T&& x, Ts&&... xs)
if(!std::all_of(types.begin(), types.end(), [&](shape::type_t t) { return t == s.type(); }))
RTG_THROW("Types must be the same");
return [&](auto v) {
s.visit_type([&](auto as) {
v(make_view(s, as.from(x.data())), make_view(xs.get_shape(), as.from(xs.data()))...);
});
// Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70100
detail::visit_all_impl(s, v, x, xs...);
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment