Skip to content

Commit 314500a

Browse files
committed
portability fixes
1 parent ef403aa commit 314500a

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

include/MGIS/Function/UniformEvaluator.hxx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,19 @@ namespace mgis::function {
9393
template <SpaceConcept SpaceType, std::size_t N>
9494
UniformEvaluator(const SpaceType&, const real (&)[N])
9595
->UniformEvaluator<SpaceType, N>
96-
requires(N > 1);
96+
/* requires(N > 1) */; // most compilers (nvhpc, clang, intel) don't
97+
// support require clause on class template
98+
// deduction guide in 2025
9799

98100
template <SpaceConcept SpaceType, std::size_t N>
99101
UniformEvaluator(const SpaceType&, std::array<real, N>)
100102
->UniformEvaluator<SpaceType, N>
101-
requires(N > 1);
103+
/* requires(N > 1) */;
102104

103105
template <SpaceConcept SpaceType, std::size_t N>
104106
UniformEvaluator(const SpaceType&, std::span<real, N>)
105107
->UniformEvaluator<SpaceType, N>
106-
requires(N > 1);
108+
/* requires(N > 1) */;
107109

108110
template <SpaceConcept Space, std::size_t N>
109111
constexpr bool check(AbstractErrorHandler&,

tests/UniformEvaluatorsTest.cxx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@
2020
#include "TFEL/Tests/TestManager.hxx"
2121
#include "MGIS/Function/BasicLinearSpace.hxx"
2222
#include "MGIS/Function/UniformEvaluator.hxx"
23+
#include "MGIS/Function/Tensors.hxx"
2324

2425
struct UniformEvaluatorsTest final : public tfel::tests::TestCase {
2526
UniformEvaluatorsTest()
2627
: tfel::tests::TestCase("MGIS/Function", "UniformEvaluatorsTests") {
2728
} // end of UniformEvaluatorsTest
2829
tfel::tests::TestResult execute() override {
2930
this->test1();
31+
this->test2();
3032
return this->result;
3133
}
3234

@@ -47,6 +49,23 @@ struct UniformEvaluatorsTest final : public tfel::tests::TestCase {
4749
TFEL_TESTS_STATIC_ASSERT(local_abs(e2(1)[1] + 2) < eps);
4850
TFEL_TESTS_STATIC_ASSERT(local_abs(e2(1)[2] - 6) < eps);
4951
}
52+
void test2() {
53+
using namespace mgis;
54+
using namespace mgis::function;
55+
auto local_abs = [](const mgis::real r) constexpr {
56+
return r > 0 ? r : -r;
57+
};
58+
constexpr auto eps = real{1e-14};
59+
constexpr auto space = BasicLinearSpace{3};
60+
constexpr real values[6] = {1, 1, 1, 0, 0, 0};
61+
constexpr auto id = UniformEvaluator(space, values) | as_stensor<3>;
62+
TFEL_TESTS_STATIC_ASSERT(local_abs(id(1)[0] - 1) < eps);
63+
TFEL_TESTS_STATIC_ASSERT(local_abs(id(1)[1] - 1) < eps);
64+
TFEL_TESTS_STATIC_ASSERT(local_abs(id(1)[2] - 1) < eps);
65+
TFEL_TESTS_STATIC_ASSERT(local_abs(id(1)[3]) < eps);
66+
TFEL_TESTS_STATIC_ASSERT(local_abs(id(1)[4]) < eps);
67+
TFEL_TESTS_STATIC_ASSERT(local_abs(id(1)[5]) < eps);
68+
}
5069
};
5170

5271
TFEL_TESTS_GENERATE_PROXY(UniformEvaluatorsTest, "UniformEvaluatorsTest");

0 commit comments

Comments
 (0)