Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F1497686
squashed_int.hpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Size
2 KB
Referenced Files
None
Subscribers
None
squashed_int.hpp
View Options
/******************************************************************************
*
* File: squashed_int.hpp
*
* Contents: Facilities for squashing integer types into standard equivalents.
*
* Copyright 2017
*
* Author: David Juhasz (david.juhasz@tuwien.ac.at)
*
* This implementation is based on the squashed_int implementation of CAF.
* TODO: Check license.
*
******************************************************************************/
#ifndef ROSA_SUPPORT_SQUASHED_INT_HPP
#define ROSA_SUPPORT_SQUASHED_INT_HPP
#include
"rosa/support/type_list.hpp"
#include
"rosa/support/type_pair.hpp"
namespace
rosa
{
// Compile-time list of integer types.
// NOTE: This list is used to select a proper type as type_nr_t,
// always make sure that type_nr_t remains correct whenever changing the list.
using
IntegerTypesBySize
=
TypeList
<
// bytes
unit_t
,
// 0
TypePair
<
int8_t
,
uint8_t
>
,
// 1
TypePair
<
int16_t
,
uint16_t
>
,
// 2
unit_t
,
// 3
TypePair
<
int32_t
,
uint32_t
>
,
// 4
unit_t
,
// 5
unit_t
,
// 6
unit_t
,
// 7
TypePair
<
int64_t
,
uint64_t
>
// 8
>
;
// Squashes integer types into [u]int_[8|16|32|64]_t equivalents.
template
<
class
T
>
struct
SquashedInt
{
using
TPair
=
typename
TypeListAt
<
IntegerTypesBySize
,
sizeof
(
T
)
>::
Type
;
using
Type
=
typename
std
::
conditional
<
std
::
is_signed
<
T
>::
value
,
typename
TPair
::
First
,
typename
TPair
::
Second
>::
type
;
};
// Convenience alias for obtaining a squashed int type.
template
<
class
T
>
using
squashed_int_t
=
typename
SquashedInt
<
T
>::
Type
;
// Replaces all integral types with their corresponding squashed integer.
template
<
typename
List
>
struct
SquashedTypeList
;
template
<>
struct
SquashedTypeList
<
EmptyTypeList
>
{
using
Type
=
EmptyTypeList
;
};
template
<
typename
T
,
typename
...
Ts
>
struct
SquashedTypeList
<
TypeList
<
T
,
Ts
...
>>
{
using
SquashedT
=
typename
std
::
conditional
<
std
::
is_integral
<
T
>::
value
,
squashed_int_t
<
T
>
,
T
>::
type
;
using
Type
=
typename
TypeListPush
<
SquashedT
,
typename
SquashedTypeList
<
TypeList
<
Ts
...
>>::
Type
>::
Type
;
};
}
// End namespace rosa
#endif
// ROSA_SUPPORT_SQUASHED_INT_HPP
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Sun, Mar 1, 9:38 PM (1 d, 22 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
279331
Default Alt Text
squashed_int.hpp (2 KB)
Attached To
Mode
R20 SoC_Rosa_repo
Attached
Detach File
Event Timeline
Log In to Comment