Skip to content

Commit 1618ca3

Browse files
author
Julia Smerdel
committed
fix pipeline by adding export
1 parent 00b2e74 commit 1618ca3

File tree

4 files changed

+42
-59
lines changed

4 files changed

+42
-59
lines changed

src/core/include/mp-units/cartesian_tensor.h

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
#pragma once
2424

25-
#include <mp-units/bits/module_macros.h>
2625
#include <mp-units/bits/requires_hosted.h>
26+
#include <mp-units/bits/module_macros.h>
2727
#include <mp-units/cartesian_vector.h>
2828
#include <mp-units/framework/customization_points.h>
2929
#include <mp-units/framework/representation_concepts.h>
@@ -56,6 +56,8 @@ class cartesian_tensor {
5656
static_assert(R >= 1 && R <= 3 && C >= 1 && C <= 3, "cartesian_tensor supports sizes up to 3x3");
5757

5858
public:
59+
// NOTE: This type is intentionally an aggregate (like std::array).
60+
// All special member functions are implicitly defined.
5961
T _data_[R * C];
6062
using value_type = T;
6163
static constexpr std::size_t rows_v = R;
@@ -82,7 +84,7 @@ class cartesian_tensor {
8284
};
8385

8486

85-
template<typename T, typename U, std::size_t R, std::size_t K, std::size_t C>
87+
MP_UNITS_EXPORT template<typename T, typename U, std::size_t R, std::size_t K, std::size_t C>
8688
[[nodiscard]] constexpr auto matmul(const cartesian_tensor<T, R, K>& A, const cartesian_tensor<U, K, C>& B)
8789
{
8890
using CT = std::common_type_t<T, U>;
@@ -96,7 +98,7 @@ template<typename T, typename U, std::size_t R, std::size_t K, std::size_t C>
9698
return Rm;
9799
}
98100

99-
template<typename T, typename U>
101+
MP_UNITS_EXPORT template<typename T, typename U>
100102
[[nodiscard]] constexpr auto matvec(const cartesian_tensor<T, 3, 3>& tensor, const cartesian_vector<U>& vector)
101103
{
102104
using CT = std::common_type_t<T, U>;
@@ -109,7 +111,7 @@ template<typename T, typename U>
109111
return y;
110112
}
111113

112-
template<typename T, typename U, std::size_t R, std::size_t C>
114+
MP_UNITS_EXPORT template<typename T, typename U, std::size_t R, std::size_t C>
113115
[[nodiscard]] constexpr auto double_contraction(const cartesian_tensor<T, R, C>& A, const cartesian_tensor<U, R, C>& B)
114116
{
115117
using CT = std::common_type_t<T, U>;
@@ -119,7 +121,7 @@ template<typename T, typename U, std::size_t R, std::size_t C>
119121
}
120122

121123

122-
template<typename T, typename U>
124+
MP_UNITS_EXPORT template<typename T, typename U>
123125
[[nodiscard]] constexpr auto outer_numeric(const cartesian_vector<T>& lhs, const cartesian_vector<U>& rhs)
124126
{
125127
using CT = std::common_type_t<T, U>;
@@ -129,7 +131,7 @@ template<typename T, typename U>
129131
return Rm;
130132
}
131133

132-
template<typename T, typename U, std::size_t R, std::size_t C>
134+
MP_UNITS_EXPORT template<typename T, typename U, std::size_t R, std::size_t C>
133135
requires requires(const T& t, const U& u) { t + u; }
134136
[[nodiscard]] constexpr auto operator+(const cartesian_tensor<T, R, C>& A, const cartesian_tensor<U, R, C>& B)
135137
{
@@ -139,7 +141,7 @@ template<typename T, typename U, std::size_t R, std::size_t C>
139141
return Rm;
140142
}
141143

142-
template<typename T, typename U, std::size_t R, std::size_t C>
144+
MP_UNITS_EXPORT template<typename T, typename U, std::size_t R, std::size_t C>
143145
requires requires(const T& t, const U& u) { t - u; }
144146
[[nodiscard]] constexpr auto operator-(const cartesian_tensor<T, R, C>& A, const cartesian_tensor<U, R, C>& B)
145147
{
@@ -149,7 +151,7 @@ template<typename T, typename U, std::size_t R, std::size_t C>
149151
return Rm;
150152
}
151153

152-
template<typename T, typename U, std::size_t R, std::size_t C>
154+
MP_UNITS_EXPORT template<typename T, typename U, std::size_t R, std::size_t C>
153155
requires(!treat_as_floating_point<T> && !treat_as_floating_point<U> && requires(const T& t, const U& u) { t % u; })
154156
[[nodiscard]] constexpr auto operator%(const cartesian_tensor<T, R, C>& A, const cartesian_tensor<U, R, C>& B)
155157
{
@@ -159,7 +161,7 @@ template<typename T, typename U, std::size_t R, std::size_t C>
159161
return Rm;
160162
}
161163

162-
template<typename T, typename S, std::size_t R, std::size_t C>
164+
MP_UNITS_EXPORT template<typename T, typename S, std::size_t R, std::size_t C>
163165
requires requires(const T& t, const S& s) { t * s; }
164166
[[nodiscard]] constexpr auto operator*(const cartesian_tensor<T, R, C>& tensor, const S& scalar)
165167
{
@@ -169,14 +171,14 @@ template<typename T, typename S, std::size_t R, std::size_t C>
169171
return Rm;
170172
}
171173

172-
template<typename S, typename U, std::size_t R, std::size_t C>
174+
MP_UNITS_EXPORT template<typename S, typename U, std::size_t R, std::size_t C>
173175
requires requires(const S& s, const U& u) { s * u; }
174176
[[nodiscard]] constexpr auto operator*(const S& scalar, const cartesian_tensor<U, R, C>& tensor)
175177
{
176178
return tensor * scalar;
177179
}
178180

179-
template<typename T, typename S, std::size_t R, std::size_t C>
181+
MP_UNITS_EXPORT template<typename T, typename S, std::size_t R, std::size_t C>
180182
requires requires(const T& t, const S& s) { t / s; }
181183
[[nodiscard]] constexpr auto operator/(const cartesian_tensor<T, R, C>& tensor, const S& scalar)
182184
{
@@ -192,8 +194,8 @@ template<typename T, typename S, std::size_t R, std::size_t C>
192194
template<typename T, std::size_t R, std::size_t C, typename Char>
193195
struct MP_UNITS_STD_FMT::formatter<mp_units::cartesian_tensor<T, R, C>, Char> :
194196
formatter<std::basic_string_view<Char>, Char> {
195-
template<typename Ctx>
196-
auto format(const mp_units::cartesian_tensor<T, R, C>& A, Ctx& ctx) const
197+
template<typename FormatContext>
198+
auto format(const mp_units::cartesian_tensor<T, R, C>& A, FormatContext& ctx) const
197199
{
198200
auto out = ctx.out();
199201
for (std::size_t r = 0; r < R; ++r) {
@@ -207,4 +209,4 @@ struct MP_UNITS_STD_FMT::formatter<mp_units::cartesian_tensor<T, R, C>, Char> :
207209
return out;
208210
}
209211
};
210-
#endif
212+
#endif

src/core/include/mp-units/cartesian_vector.h

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
#pragma once
2424

25-
#include <mp-units/bits/module_macros.h>
2625
#include <mp-units/bits/requires_hosted.h>
26+
#include <mp-units/bits/module_macros.h>
2727
#include <mp-units/framework/customization_points.h>
2828
#include <mp-units/framework/representation_concepts.h>
2929
#include <type_traits>
@@ -55,28 +55,11 @@ class cartesian_vector;
5555
MP_UNITS_EXPORT template<detail::Scalar T = double>
5656
class cartesian_vector {
5757
public:
58-
// NOTE: This type is intentionally an aggregate.
58+
// NOTE: This type is intentionally an aggregate (like std::array).
59+
// All special member functions are implicitly defined.
5960
T _coordinates_[3];
6061
using value_type = T;
6162

62-
template<std::convertible_to<T> U>
63-
constexpr cartesian_vector& operator=(const cartesian_vector<U>& other)
64-
{
65-
_coordinates_[0] = other[0];
66-
_coordinates_[1] = other[1];
67-
_coordinates_[2] = other[2];
68-
return *this;
69-
}
70-
71-
template<std::convertible_to<T> U>
72-
constexpr cartesian_vector& operator=(cartesian_vector<U>&& other)
73-
{
74-
_coordinates_[0] = std::move(other[0]);
75-
_coordinates_[1] = std::move(other[1]);
76-
_coordinates_[2] = std::move(other[2]);
77-
return *this;
78-
}
79-
8063
[[nodiscard]] constexpr T magnitude() const
8164
requires treat_as_floating_point<T>
8265
{
@@ -171,7 +154,7 @@ template<typename Arg, typename... Args>
171154
requires(sizeof...(Args) <= 2) && requires { typename std::common_type_t<Arg, Args...>; }
172155
cartesian_vector(Arg, Args...) -> cartesian_vector<std::common_type_t<Arg, Args...>>;
173156

174-
template<typename T, typename U>
157+
MP_UNITS_EXPORT template<typename T, typename U>
175158
requires requires(const T& t, const U& u) { t + u; }
176159
[[nodiscard]] constexpr auto operator+(const cartesian_vector<T>& lhs, const cartesian_vector<U>& rhs)
177160
{
@@ -180,7 +163,7 @@ template<typename T, typename U>
180163
lhs._coordinates_[2] + rhs._coordinates_[2]};
181164
}
182165

183-
template<typename T, typename U>
166+
MP_UNITS_EXPORT template<typename T, typename U>
184167
requires requires(const T& t, const U& u) { t - u; }
185168
[[nodiscard]] constexpr auto operator-(const cartesian_vector<T>& lhs, const cartesian_vector<U>& rhs)
186169
{
@@ -189,7 +172,7 @@ template<typename T, typename U>
189172
lhs._coordinates_[2] - rhs._coordinates_[2]};
190173
}
191174

192-
template<typename T, typename U>
175+
MP_UNITS_EXPORT template<typename T, typename U>
193176
requires(!treat_as_floating_point<T> && !treat_as_floating_point<U> && requires(const T& t, const U& u) { t % u; })
194177
[[nodiscard]] constexpr auto operator%(const cartesian_vector<T>& lhs, const cartesian_vector<U>& rhs)
195178
{
@@ -199,37 +182,37 @@ template<typename T, typename U>
199182
static_cast<CT>(lhs._coordinates_[2] % rhs._coordinates_[2])};
200183
}
201184

202-
template<typename T, typename S>
185+
MP_UNITS_EXPORT template<typename T, typename S>
203186
requires requires(const T& t, const S& s) { t * s; }
204187
[[nodiscard]] constexpr auto operator*(const cartesian_vector<T>& vector, const S& scalar)
205188
{
206189
return ::mp_units::cartesian_vector{vector._coordinates_[0] * scalar, vector._coordinates_[1] * scalar,
207190
vector._coordinates_[2] * scalar};
208191
}
209192

210-
template<typename S, typename U>
193+
MP_UNITS_EXPORT template<typename S, typename U>
211194
requires requires(const S& s, const U& u) { s * u; }
212195
[[nodiscard]] constexpr auto operator*(const S& scalar, const cartesian_vector<U>& vector)
213196
{
214197
return vector * scalar;
215198
}
216199

217-
template<typename T, typename S>
200+
MP_UNITS_EXPORT template<typename T, typename S>
218201
requires requires(const T& t, const S& s) { t / s; }
219202
[[nodiscard]] constexpr auto operator/(const cartesian_vector<T>& vector, const S& scalar)
220203
{
221204
return ::mp_units::cartesian_vector{vector._coordinates_[0] / scalar, vector._coordinates_[1] / scalar,
222205
vector._coordinates_[2] / scalar};
223206
}
224207

225-
template<typename T, std::equality_comparable_with<T> U>
208+
MP_UNITS_EXPORT template<typename T, std::equality_comparable_with<T> U>
226209
[[nodiscard]] constexpr bool operator==(const cartesian_vector<T>& lhs, const cartesian_vector<U>& rhs)
227210
{
228211
return lhs._coordinates_[0] == rhs._coordinates_[0] && lhs._coordinates_[1] == rhs._coordinates_[1] &&
229212
lhs._coordinates_[2] == rhs._coordinates_[2];
230213
}
231214

232-
template<typename T, typename U>
215+
MP_UNITS_EXPORT template<typename T, typename U>
233216
requires requires(const T& t, const U& u, decltype(t * u) v) {
234217
t * u;
235218
v + v;
@@ -240,7 +223,7 @@ template<typename T, typename U>
240223
lhs._coordinates_[2] * rhs._coordinates_[2];
241224
}
242225

243-
template<typename T, typename U>
226+
MP_UNITS_EXPORT template<typename T, typename U>
244227
requires requires(const T& t, const U& u, decltype(t * u) v) {
245228
t * u;
246229
v - v;
@@ -283,9 +266,9 @@ template<typename T, typename Char>
283266
struct MP_UNITS_STD_FMT::formatter<mp_units::cartesian_vector<T>, Char> :
284267
formatter<std::basic_string_view<Char>, Char> {
285268
template<typename FormatContext>
286-
auto format(const mp_units::cartesian_vector<T>& vector, FormatContext& ctx) const
269+
auto format(const mp_units::cartesian_vector<T>& vec, FormatContext& ctx) const
287270
{
288-
return format_to(ctx.out(), "[{}, {}, {}]", vector[0], vector[1], vector[2]);
271+
return format_to(ctx.out(), "[{}, {}, {}]", vec[0], vec[1], vec[2]);
289272
}
290273
};
291-
#endif
274+
#endif

test/runtime/cartesian_tensor_test.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ import mp_units;
2929
#include <mp-units/cartesian_tensor.h>
3030
#include <mp-units/cartesian_vector.h>
3131
#include <mp-units/compat_macros.h>
32-
#if MP_UNITS_HOSTED
3332
#include <mp-units/ext/format.h>
3433
#include <sstream>
3534
#endif
36-
#endif
3735

3836
using namespace mp_units;
3937
using Catch::Matchers::WithinAbs;
@@ -153,7 +151,6 @@ TEST_CASE("cartesian_tensor — core", "[tensor]")
153151
REQUIRE(T(2, 2) == 18);
154152
}
155153

156-
#if MP_UNITS_HOSTED
157154
SECTION("text output (ostream + fmt)")
158155
{
159156
cartesian_tensor<int, 2, 2> A{1, 2, 3, 4};
@@ -162,7 +159,6 @@ TEST_CASE("cartesian_tensor — core", "[tensor]")
162159
CHECK(os.str() == "[[1, 2]\n [3, 4]]");
163160
CHECK(MP_UNITS_STD_FMT::format("{}", A) == os.str());
164161
}
165-
#endif
166162

167163
SECTION("constexpr basics")
168164
{
@@ -172,4 +168,4 @@ TEST_CASE("cartesian_tensor — core", "[tensor]")
172168
static_assert(C(0, 0) == 5 && C(0, 1) == 7 && C(0, 2) == 9);
173169
(void)C;
174170
}
175-
}
171+
}

test/runtime/cartesian_vector_test.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ import mp_units;
3131
#include <sstream>
3232
#endif
3333

34+
#ifndef MP_UNITS_MODULES
35+
#include <sstream>
36+
#endif
37+
3438
using namespace mp_units;
3539
using Catch::Matchers::WithinAbs;
3640

@@ -75,20 +79,20 @@ TEST_CASE("cartesian_vector", "[vector]")
7579
}
7680
}
7781

78-
SECTION("convertibility from another vector")
82+
SECTION("aggregate assignment")
7983
{
80-
cartesian_vector v1{1, 2, 3};
81-
82-
SECTION("construction from other rep")
84+
SECTION("aggregate copy assignment")
8385
{
86+
cartesian_vector v1{1, 2, 3};
8487
cartesian_vector<double> v2{};
8588
v2 = v1;
8689
REQUIRE(v2[0] == 1.0);
8790
REQUIRE(v2[1] == 2.0);
8891
REQUIRE(v2[2] == 3.0);
8992
}
90-
SECTION("assignment from other rep")
93+
SECTION("aggregate assignment from different rep")
9194
{
95+
cartesian_vector v1{1, 2, 3};
9296
cartesian_vector<double> v2{3.0, 2.0, 1.0};
9397
v2 = v1;
9498
REQUIRE(v2[0] == 1.0);
@@ -224,7 +228,6 @@ TEST_CASE("cartesian_vector", "[vector]")
224228
REQUIRE_THAT(u[2], WithinAbs(0.0, 1e-12));
225229
}
226230

227-
#if MP_UNITS_HOSTED
228231
SECTION("text output (ostream + fmt)")
229232
{
230233
cartesian_vector v{1, 2, 3};
@@ -233,7 +236,6 @@ TEST_CASE("cartesian_vector", "[vector]")
233236
CHECK(os.str() == "[1, 2, 3]");
234237
CHECK(MP_UNITS_STD_FMT::format("{}", v) == os.str());
235238
}
236-
#endif
237239

238240
SECTION("constexpr basics")
239241
{
@@ -243,4 +245,4 @@ TEST_CASE("cartesian_vector", "[vector]")
243245
static_assert(c._coordinates_[0] == 5 && c._coordinates_[1] == 7 && c._coordinates_[2] == 9);
244246
(void)c;
245247
}
246-
}
248+
}

0 commit comments

Comments
 (0)