Skip to content

Commit 4b933b4

Browse files
authored
Merge pull request #730 from Radnyx/fix/msvc-empty-bases
build: MSVC workaround for empty base classes
2 parents c363cf1 + 2af1821 commit 4b933b4

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/core/include/mp-units/bits/hacks.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,16 @@ MP_UNITS_DIAGNOSTIC_POP
146146

147147
#endif
148148

149+
#if MP_UNITS_COMP_MSVC
150+
151+
#define MP_UNITS_EMPTY_BASES_WORKAROUND __declspec(empty_bases)
152+
153+
#else
154+
155+
#define MP_UNITS_EMPTY_BASES_WORKAROUND
156+
157+
#endif
158+
149159
#if !defined MP_UNITS_API_NO_CRTP && __cpp_explicit_this_parameter
150160

151161
#define MP_UNITS_API_NO_CRTP 1

src/core/include/mp-units/framework/unit.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ struct propagate_point_origin<U, true> {
226226
};
227227

228228
template<UnitMagnitude auto M, Unit U>
229-
struct scaled_unit_impl : detail::unit_interface, detail::propagate_point_origin<U> {
229+
struct MP_UNITS_EMPTY_BASES_WORKAROUND scaled_unit_impl : detail::unit_interface, detail::propagate_point_origin<U> {
230230
using _base_type_ = scaled_unit_impl; // exposition only
231231
static constexpr UnitMagnitude auto _mag_ = M;
232232
static constexpr U _reference_unit_{};
@@ -461,7 +461,9 @@ struct common_unit final : decltype(detail::get_common_scaled_unit(U1{}, U2{}, R
461461
namespace detail {
462462

463463
template<typename... Expr>
464-
struct derived_unit_impl : detail::unit_interface, detail::expr_fractions<one, Expr...> {
464+
struct MP_UNITS_EMPTY_BASES_WORKAROUND derived_unit_impl :
465+
detail::unit_interface,
466+
detail::expr_fractions<one, Expr...> {
465467
using _base_type_ = derived_unit_impl; // exposition only
466468
};
467469

0 commit comments

Comments
 (0)