Skip to content

Conversation

@danielytics
Copy link

Fixes #40

I wanted to get this code working:

using Quantity = dec::decimal<8>;
[[nodiscard]] constexpr Quantity operator"" _qty(unsigned long long value) noexcept {
    return Quantity{int(value)};
}
[[nodiscard]] constexpr Quantity operator"" _qty(long double value) noexcept {
    return Quantity{value};
}

void test() {
    Quantity q = 12.1_qty;
}

and this change makes this work. It just marks the constructors as constexpr (when using C++11), it doesn't change any other function. This seems to be enough for my use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggest using constexpr

1 participant