Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add constexpr constructors #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions include/decimal.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@

#ifdef DEC_NO_CPP11
#define DEC_OVERRIDE
#define DEC_CONSTEXPR
#else
#define DEC_OVERRIDE override
#define DEC_CONSTEXPR constexpr
#endif

#if (DEC_ALLOW_SPACESHIP_OPER == 1) && (__cplusplus > 201703L)
Expand Down Expand Up @@ -690,36 +692,36 @@ class decimal {
init(src);
}
#else
decimal() noexcept : m_value(0) {}
decimal(const decimal &src) = default;
DEC_CONSTEXPR decimal() noexcept : m_value(0) {}
DEC_CONSTEXPR decimal(const decimal &src) = default;
#endif
explicit decimal(uint value) {
explicit DEC_CONSTEXPR decimal(uint value) {
init(value);
}
explicit decimal(int value) {
explicit DEC_CONSTEXPR decimal(int value) {
init(value);
}
#ifdef DEC_HANDLE_LONG
explicit decimal(long int value) {
explicit DEC_CONSTEXPR decimal(long int value) {
init(value);
}
#endif
explicit decimal(int64 value) {
explicit DEC_CONSTEXPR decimal(int64 value) {
init(value);
}
explicit decimal(xdouble value) {
explicit DEC_CONSTEXPR decimal(xdouble value) {
init(value);
}
explicit decimal(double value) {
explicit DEC_CONSTEXPR decimal(double value) {
init(value);
}
explicit decimal(float value) {
explicit DEC_CONSTEXPR decimal(float value) {
init(value);
}
explicit decimal(int64 value, int64 precFactor) {
explicit DEC_CONSTEXPR decimal(int64 value, int64 precFactor) {
initWithPrec(value, precFactor);
}
explicit decimal(const std::string &value) {
explicit DEC_CONSTEXPR decimal(const std::string &value) {
fromString(value, *this);
}

Expand Down