Skip to content

Commit

Permalink
Add literals for size_t and ptrdiff_t
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-johansson committed Sep 26, 2024
1 parent 4b929df commit 0d9cbf6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions source/base/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ target_sources(tactile-base
"inc/tactile/base/meta/color.hpp"
"inc/tactile/base/numeric/extent_2d.hpp"
"inc/tactile/base/numeric/index_2d.hpp"
"inc/tactile/base/numeric/literals.hpp"
"inc/tactile/base/numeric/offset_2d.hpp"
"inc/tactile/base/numeric/saturate_cast.hpp"
"inc/tactile/base/numeric/vec.hpp"
Expand Down
21 changes: 21 additions & 0 deletions source/base/lib/inc/tactile/base/numeric/literals.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (C) 2024 Albin Johansson (GNU General Public License v3.0)

#pragma once

#include <cstddef> // size_t, ptrdiff_t

namespace tactile {

[[nodiscard]]
consteval auto operator""_uz(const unsigned long long int value) noexcept -> std::size_t
{
return static_cast<std::size_t>(value);
}

[[nodiscard]]
consteval auto operator""_z(const unsigned long long int value) noexcept -> std::ptrdiff_t
{
return static_cast<std::ptrdiff_t>(value);
}

} // namespace tactile

0 comments on commit 0d9cbf6

Please sign in to comment.