MeshLib C++ Docs
Loading...
Searching...
No Matches
MRUnsigned.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <type_traits>
5
6// Additional support for unsigned types.
7
8namespace MR::Unsigned
9{
10
11// Only callable on unsigned types. Returns the value unchanged.
12// The intended usage of this in templates is like this:
13// using std::abs;
14// using Unsigned::abs; // Or `using namespace Unsigned;`.
15// abs(x);
16// Doing it this way ensures that you can handle both signed and unsigned standard types, and additionally any classes that provide `abs()` via ADL.
17template <typename T, std::enable_if_t<std::is_unsigned_v<T>, std::nullptr_t> = nullptr>
18[[nodiscard]] constexpr T abs( T value )
19{
20 return value;
21}
22
23}
Definition MRUnsigned.h:9
constexpr T abs(T value)
Definition MRUnsigned.h:18