MCPcopy Create free account
hub / github.com/andreasfertig/programming-with-cpp20 / BCD

Class BCD

06.14-bcdConstexpr/main.cpp:6–22  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4#include <compare>
5
6class BCD {
7public:
8 constexpr BCD(int v, int significance)
9 : mSignificance{significance}
10 , mValue{Adjust(v)}
11 {}
12
13 constexpr operator int() const { return mValue; }
14
15 constexpr auto operator<=>(const BCD&) const = default; // #A Add constexpr
16
17private:
18 int mSignificance; // #B The additional member just works
19 int mValue;
20
21 static constexpr int Adjust(int v);
22};
23
24constexpr int BCD::Adjust(int v)
25{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected