Skip to content

Commit

Permalink
Attempting to address gnu 7.3 compiler errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
odlomax committed Sep 13, 2024
1 parent cbf7818 commit b6ff4af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/atlas/array/ArrayViewVariant.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct Ints {};
template <typename...>
struct VariantHelper;

// Recursively construct ArrayView std::variant from types Ts and Ranks Is.
// Recursively construct ArrayView std::variant from types Ts and ranks Is.
template <typename... ArrayViews, typename T, typename... Ts, int... Is>
struct VariantHelper<Types<ArrayViews...>, Types<T, Ts...>, Ints<Is...>> {
using type = typename VariantHelper<
Expand Down
18 changes: 10 additions & 8 deletions src/tests/array/test_array_view_variant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ CASE("test variant assignment") {
}

template <typename View>
constexpr auto Rank = std::decay_t<View>::rank();
constexpr auto Rank() {
return std::remove_reference_t<View>::rank();
}

CASE("test std::visit") {
auto array1 = ArrayT<int>(10);
Expand All @@ -93,7 +95,7 @@ CASE("test std::visit") {
make_view<int, 2>(array2).assign({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});

const auto testRank1 = [](auto&& view) {
using View = std::decay_t<decltype(view)>;
using View = std::remove_reference_t<decltype(view)>;
EXPECT_EQ(View::rank(), 1);
using Value = typename View::value_type;
EXPECT((std::is_same_v<Value, int>));
Expand All @@ -104,7 +106,7 @@ CASE("test std::visit") {
};

const auto testRank2 = [](auto&& view) {
using View = std::decay_t<decltype(view)>;
using View = std::remove_reference_t<decltype(view)>;
EXPECT_EQ(View::rank(), 2);
using Value = typename View::value_type;
EXPECT((std::is_same_v<Value, int>));
Expand All @@ -125,11 +127,11 @@ CASE("test std::visit") {
auto rank2Tested = false;

const auto visitor = [&](auto&& view) {
if constexpr (Rank<decltype(view)> == 1) {
if constexpr (Rank<decltype(view)>() == 1) {
testRank1(view);
rank1Tested = true;
}
if constexpr (Rank<decltype(view)> == 2) {
if constexpr (Rank<decltype(view)>() == 2) {
testRank2(view);
rank2Tested = true;
}
Expand All @@ -147,15 +149,15 @@ CASE("test std::visit") {
auto rank1Tested = false;
auto rank2Tested = false;
const auto visitor = eckit::Overloaded{
[&](auto&& view) -> std::enable_if_t<Rank<decltype(view)> == 1> {
[&](auto&& view) -> std::enable_if_t<Rank<decltype(view)>() == 1> {
testRank1(view);
rank1Tested = true;
},
[&](auto&& view) -> std::enable_if_t<Rank<decltype(view)> == 2> {
[&](auto&& view) -> std::enable_if_t<Rank<decltype(view)>() == 2> {
testRank2(view);
rank2Tested = true;
},
[](auto&& view) -> std::enable_if_t<Rank<decltype(view)> >= 3> {
[](auto&& view) -> std::enable_if_t<(Rank<decltype(view)>() > 2)> {
// do nothing.
}};

Expand Down

0 comments on commit b6ff4af

Please sign in to comment.