std: add compact fixed width typedefs

This commit is contained in:
Danny Robson 2018-06-03 15:25:17 +10:00
parent 82b1c9fa40
commit 18e2b615d5
2 changed files with 56 additions and 0 deletions

View File

@ -366,6 +366,7 @@ list (
singleton.hpp singleton.hpp
stats.cpp stats.cpp
stats.hpp stats.hpp
std.hpp
stream.cpp stream.cpp
stream.hpp stream.hpp
string.cpp string.cpp

55
std.hpp Normal file
View File

@ -0,0 +1,55 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Copyright 2018 Danny Robson <danny@nerdcruft.net>
*/
#pragma once
#include <cstdint>
///////////////////////////////////////////////////////////////////////////////
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);