1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-12 08:30:05 +00:00
CLK/Numeric/Sizes.hpp

35 lines
715 B
C++
Raw Normal View History

//
// Sizes.hpp
// Clock Signal
//
// Created by Thomas Harte on 26/01/2021.
// Copyright © 2021 Thomas Harte. All rights reserved.
//
#pragma once
2021-03-12 19:27:29 +00:00
#include <limits>
2021-06-23 01:31:46 +00:00
#include <type_traits>
2021-03-12 19:27:29 +00:00
/*!
2021-03-18 16:47:48 +00:00
Maps to the smallest integral type that can contain max_value, from the following options:
* uint8_t;
* uint16_t;
* uint32_t; or
* uint64_t.
*/
template <uint64_t max_value> struct MinIntTypeValue {
using type =
std::conditional_t<
max_value <= std::numeric_limits<uint8_t>::max(), uint8_t,
std::conditional_t<
max_value <= std::numeric_limits<uint16_t>::max(), uint16_t,
std::conditional_t<
max_value <= std::numeric_limits<uint32_t>::max(), uint32_t,
uint64_t
>
>
>;
};