-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make matrix types use signed integers
- Loading branch information
1 parent
b98dd2a
commit 5ebfd42
Showing
8 changed files
with
91 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (C) 2024 Albin Johansson (GNU General Public License v3.0) | ||
|
||
#pragma once | ||
|
||
#include <concepts> // signed_integral, unsigned_integral | ||
#include <type_traits> // make_unsigned_t, make_signed_t | ||
|
||
#include "tactile/base/prelude.hpp" | ||
|
||
namespace tactile { | ||
|
||
template <std::signed_integral T> | ||
[[nodiscard]] constexpr auto sign_cast(const T value) noexcept | ||
-> std::make_unsigned_t<T> | ||
{ | ||
return static_cast<std::make_unsigned_t<T>>(value); | ||
} | ||
|
||
template <std::unsigned_integral T> | ||
[[nodiscard]] constexpr auto sign_cast(const T value) noexcept | ||
-> std::make_signed_t<T> | ||
{ | ||
return static_cast<std::make_signed_t<T>>(value); | ||
} | ||
|
||
} // namespace tactile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters