Antkeeper  0.0.1
make-uint.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Christopher J. Howard
3  *
4  * This file is part of Antkeeper source code.
5  *
6  * Antkeeper source code is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Antkeeper source code is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef ANTKEEPER_MATH_HASH_MAKE_UINT_HPP
21 #define ANTKEEPER_MATH_HASH_MAKE_UINT_HPP
22 
23 #include <cstdint>
24 #include <type_traits>
25 
26 namespace math {
27 namespace hash {
28 
32 template <class T>
33 struct make_uint
34 {
35  static_assert(std::is_integral<T>::value);
36 
38  typedef typename std::make_unsigned<T>::type type;
39 };
40 
42 template<>
43 struct make_uint<float>
44 {
45  static_assert(sizeof(float) == sizeof(std::uint32_t));
46 
48  typedef std::uint32_t type;
49 };
50 
52 template<>
53 struct make_uint<double>
54 {
55  static_assert(sizeof(double) == sizeof(std::uint64_t));
56 
58  typedef std::uint64_t type;
59 };
60 
62 template <class T>
64 
65 } // namespace hash
66 } // namespace math
67 
68 #endif // ANTKEEPER_MATH_HASH_MAKE_UINT_HPP
Hash functions.
Definition: fnv1a.hpp:29
typename make_uint< T >::type make_uint_t
Helper type for make_uint.
Definition: make-uint.hpp:63
Mathematical functions and data types.
Definition: angles.hpp:26
std::uint64_t type
Unsigned integer type of equivalent size to double.
Definition: make-uint.hpp:55
std::uint32_t type
Unsigned integer type of equivalent size to float.
Definition: make-uint.hpp:45
Provides an unsigned integer type of equivalent size to type T.
Definition: make-uint.hpp:34
std::make_unsigned< T >::type type
Unsigned integer type of equivalent size to type T.
Definition: make-uint.hpp:35