Skip to content
Snippets Groups Projects
Commit efff3765 authored by Santiago Ospina De Los Ríos's avatar Santiago Ospina De Los Ríos Committed by Simon Praetorius
Browse files

Add explicit function to StaticIntegralRange that returns the std::index_sequience

parent 619440d4
No related branches found
No related tags found
1 merge request!1339Add explicit function to StaticIntegralRange that returns the std::index_sequience
......@@ -248,6 +248,9 @@ namespace Dune
/** \brief cast into corresponding std::integer_sequence **/
constexpr operator integer_sequence() const noexcept { return {}; }
/** \brief return corresponding std::integer_sequence **/
static constexpr integer_sequence to_integer_sequence() noexcept { return {}; }
/** \brief obtain a random-access iterator to the first element **/
static constexpr iterator begin() noexcept { return iterator(from); }
/** \brief obtain a random-access iterator past the last element **/
......
......@@ -4,6 +4,7 @@
#include <array>
#include <map>
#include <utility>
#include <vector>
#include <numeric>
#include <type_traits>
......@@ -61,6 +62,10 @@ template<class T>
struct is_mutable_reference : public std::conjunction<std::is_reference<T>, std::negation<is_const_reference<T>>>
{};
template<typename F, typename T, T... I>
void checkIndexExpansion(std::integer_sequence<T, I...> seq, F&& f){
f(seq);
}
auto testTransformedRangeView()
{
......@@ -305,13 +310,19 @@ int main()
suite.check(range(6).contains(5));
suite.check(not range(6).contains(6));
using StaticRange4 = decltype(range(std::integral_constant<int,4>()));
auto range4 = range(std::integral_constant<int,4>());
using StaticRange4 = decltype(range4);
static_assert(StaticRange4::contains(std::integral_constant<int,3>()));
static_assert(not StaticRange4::contains(4));
static_assert(std::is_same<StaticRange4::integer_sequence, std::make_integer_sequence<int, 4>>::value,
"decltype(range(std::integral_constant<int, 4>))::integer_sequence must be the same as std::make_integer_sequence<int, 4>");
checkIndexExpansion(range4.to_integer_sequence(), [](auto seq){
static_assert(std::is_same<decltype(seq), std::make_integer_sequence<int, 4>>::value,
"decltype(range(std::integral_constant<int, 4>))::integer_sequence must be the same as std::make_integer_sequence<int, 4>");
});
// Hybrid::forEach for integer ranges
Dune::Hybrid::forEach(range(std::integral_constant<int, 1>()), [] (auto &&i) {
static_assert(std::is_same<std::decay_t<decltype(i)>, std::integral_constant<int, 0>>::value,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment