Skip to content

Commit

Permalink
Missing overload to ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrk24 committed Jun 11, 2023
1 parent 0ff798a commit 47e0cb4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. See [Keep a

## Unreleased

## [1.3.4] - 2023-06-11

### Fixed

- Changed the overloads of `int24_t::int24_t` so that it compiles on macOS.

## [1.3.3] - 2023-06-11

### Fixed
Expand Down Expand Up @@ -116,3 +122,4 @@ First versioned release.
[1.3.1]: https://github.com/bbrk24/Trilangle/tree/1.3.1
[1.3.2]: https://github.com/bbrk24/Trilangle/tree/1.3.2
[1.3.3]: https://github.com/bbrk24/Trilangle/tree/1.3.3
[1.3.4]: https://github.com/bbrk24/Trilangle/tree/1.3.4
2 changes: 1 addition & 1 deletion src/disassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using std::pair;
using std::vector;

disassembler::~disassembler() {
disassembler::~disassembler() noexcept {
if (m_fragments == nullptr) {
return;
}
Expand Down
10 changes: 8 additions & 2 deletions src/int24.hh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ struct int24_t {
int24_t() = default;
constexpr int24_t(char x) noexcept : value(x) {}
constexpr int24_t(unsigned char x) noexcept : value(x) {}
constexpr explicit int24_t(int32_t x) noexcept : value(x) {}
constexpr explicit int24_t(int64_t x) noexcept : value(static_cast<int32_t>(x)) {}
constexpr explicit int24_t(size_t x) noexcept : value(static_cast<int32_t>(x)) {}
constexpr explicit int24_t(long double x) noexcept : value(static_cast<int32_t>(x)) {}

// So on most modern systems, int32_t is int, and int64_t is long long. On Windows, time_t is also long long, but on
// macOS it's just long. Still 64 bits, but it's a nominally different type, so there's "no" valid overloads. If I
// just add an overload that takes time_t, Windows complains that I've declared the one taking long long twice, so I
// have to do this.
MAYBE_UNUSED constexpr explicit int24_t(int x) noexcept : value(static_cast<int32_t>(x)) {}
MAYBE_UNUSED constexpr explicit int24_t(long x) noexcept : value(static_cast<int32_t>(x)) {}
MAYBE_UNUSED constexpr explicit int24_t(long long x) noexcept : value(static_cast<int32_t>(x)) {}

// Returns { false, this + other } when overflow does not occur, and { true, undefined } when overflow does occur.
std::pair<bool, int24_t> add_with_overflow(int24_t other) const noexcept;
// Returns { false, this - other } when overflow does not occur, and { true, undefined } when overflow does occur.
Expand Down

0 comments on commit 47e0cb4

Please sign in to comment.