libcruft-util/cruft/util/std.hpp

59 lines
1.7 KiB
C++
Raw Permalink Normal View History

2018-06-03 15:25:17 +10:00
/*
2018-08-04 15:14:06 +10:00
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
2018-06-03 15:25:17 +10:00
*
2020-01-16 11:58:03 +11:00
* Copyright 2018-2020, Danny Robson <danny@nerdcruft.net>
2018-06-03 15:25:17 +10:00
*/
#pragma once
#include <cstdint>
2024-11-11 13:00:50 +11:00
#include <cstddef>
2018-06-03 15:25:17 +10:00
2020-01-16 11:58:03 +11:00
/// A collection of convenience typedefs that define short aliases (three
/// letters) to std sized types in the global namespace.
///
/// We guarantee that there will be minimal, and safe, includes in this header.
2018-06-03 15:25:17 +10:00
///////////////////////////////////////////////////////////////////////////////
using u08 = std::uint8_t;
using u16 = std::uint16_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;
//-----------------------------------------------------------------------------
static_assert (sizeof (u08) == 1);
static_assert (sizeof (u16) == 2);
static_assert (sizeof (u32) == 4);
static_assert (sizeof (u64) == 8);
///////////////////////////////////////////////////////////////////////////////
using i08 = std::int8_t;
using i16 = std::int16_t;
using i32 = std::int32_t;
using i64 = std::int64_t;
//-----------------------------------------------------------------------------
static_assert (sizeof (i08) == 1);
static_assert (sizeof (i16) == 2);
static_assert (sizeof (i32) == 4);
static_assert (sizeof (i64) == 8);
///////////////////////////////////////////////////////////////////////////////
using f32 = float;
using f64 = double;
//-----------------------------------------------------------------------------
static_assert (sizeof (f32) == 4);
static_assert (sizeof (f64) == 8);
2024-11-11 13:00:50 +11:00
///////////////////////////////////////////////////////////////////////////////
using isize = std::ptrdiff_t;
using usize = std::size_t;