diff --git a/.github/workflows/single-file-build-and-test.yml b/.github/workflows/single-file-build-and-test.yml index 1028c477..8a9dd3eb 100644 --- a/.github/workflows/single-file-build-and-test.yml +++ b/.github/workflows/single-file-build-and-test.yml @@ -38,7 +38,7 @@ jobs: - name: Build single-file package shell: cmd - run: python tools/bin/make-single-file --units meters seconds --version-id NA > au.hh + run: python tools/bin/make-single-file --units meters seconds --constants speed_of_light --version-id NA > au.hh - name: Build and run test shell: cmd diff --git a/au/code/au/constant.hh b/au/code/au/constant.hh index a84dc375..6e7ac13a 100644 --- a/au/code/au/constant.hh +++ b/au/code/au/constant.hh @@ -56,7 +56,8 @@ struct Constant : detail::MakesQuantityFromNumber, // Convert this constant to a Quantity of the given unit and rep. template constexpr auto as(OtherUnit u) const { - static_assert(can_store_value_in(u), "Cannot represent constant in this unit/rep"); + static_assert(can_store_value_in(OtherUnit{}), + "Cannot represent constant in this unit/rep"); return coerce_as(u); } @@ -69,7 +70,8 @@ struct Constant : detail::MakesQuantityFromNumber, // Get the value of this constant in the given unit and rep. template constexpr auto in(OtherUnit u) const { - static_assert(can_store_value_in(u), "Cannot represent constant in this unit/rep"); + static_assert(can_store_value_in(OtherUnit{}), + "Cannot represent constant in this unit/rep"); return coerce_in(u); } diff --git a/single-file-test.cc b/single-file-test.cc index 62e8bd99..439b7552 100644 --- a/single-file-test.cc +++ b/single-file-test.cc @@ -26,6 +26,8 @@ // dependencies outside of the C++14 standard library, and the single-file package of Au itself. using namespace au; +using ::au::symbols::m; +using ::au::symbols::s; // This ad hoc utility is a stand-in for GTEST, which we can't use here. template @@ -42,6 +44,7 @@ int main(int argc, char **argv) { const std::vector results{ { expect_equal((meters / second)(5) * seconds(6), meters(30)), + expect_equal(SPEED_OF_LIGHT.as(m / s), 299'792'458 * m / s), }, }; return std::all_of(std::begin(results), std::end(results), [](auto x) { return x; }) ? 0 : 1;