Skip to content

Commit

Permalink
disable ambiguous range constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelKoch committed Jun 30, 2023
1 parent 5036395 commit fb403c3
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion include/ginkgo/core/base/range.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,27 @@ GKO_ATTRIBUTES constexpr GKO_INLINE
equal_dimensions<CurrentDimension + 1>(first, second);
}

/**
* Helper that stores the first type of a parameter pack, if its length is
* greater 0.
*/
template <class...>
struct head;

/**
* @copydoc head
*/
template <class First, class... Rest>
struct head<First, Rest...> {
using type = First;
};

/**
* @copydoc head
*/
template <class... T>
using head_t = typename head<T...>::type;


} // namespace detail

Expand Down Expand Up @@ -327,7 +348,11 @@ class range {
*
* @param params parameters forwarded to Accessor constructor.
*/
template <typename... AccessorParams>
template <typename... AccessorParams,
typename = std::enable_if_t<
sizeof...(AccessorParams) != 1 ||
!std::is_same_v<
range, std::decay<detail::head_t<AccessorParams...>>>>>
GKO_ATTRIBUTES constexpr explicit range(AccessorParams&&... params)
: accessor_{std::forward<AccessorParams>(params)...}
{}
Expand Down

0 comments on commit fb403c3

Please sign in to comment.