Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
ff2ed53e
Commit
ff2ed53e
authored
Sep 29, 2016
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move squashed_int into separate header
parent
a83feea0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
21 deletions
+66
-21
libcaf_core/caf/detail/squashed_int.hpp
libcaf_core/caf/detail/squashed_int.hpp
+64
-0
libcaf_core/caf/type_nr.hpp
libcaf_core/caf/type_nr.hpp
+2
-21
No files found.
libcaf_core/caf/detail/squashed_int.hpp
0 → 100644
View file @
ff2ed53e
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2016 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_DETAIL_SQUASHED_INT_HPP
#define CAF_DETAIL_SQUASHED_INT_HPP
#include <cstdint>
#include <type_traits>
#include "caf/detail/type_list.hpp"
namespace
caf
{
namespace
detail
{
/// Compile-time list of integer types types.
using
int_types_by_size
=
detail
::
type_list
<
// bytes
void
,
// 0
detail
::
type_pair
<
int8_t
,
uint8_t
>
,
// 1
detail
::
type_pair
<
int16_t
,
uint16_t
>
,
// 2
void
,
// 3
detail
::
type_pair
<
int32_t
,
uint32_t
>
,
// 4
void
,
// 5
void
,
// 6
void
,
// 7
detail
::
type_pair
<
int64_t
,
uint64_t
>
// 8
>
;
/// Squashes integer types into [u]int_[8|16|32|64]_t equivalents
template
<
class
T
>
struct
squashed_int
{
using
tpair
=
typename
detail
::
tl_at
<
int_types_by_size
,
sizeof
(
T
)
>::
type
;
using
type
=
typename
std
::
conditional
<
std
::
is_signed
<
T
>::
value
,
typename
tpair
::
first
,
typename
tpair
::
second
>::
type
;
};
template
<
class
T
>
using
squashed_int_t
=
typename
squashed_int
<
T
>::
type
;
}
// namespace detail
}
// namespace caf
#endif // CAF_DETAIL_SQUASHED_INT_HPP
libcaf_core/caf/type_nr.hpp
View file @
ff2ed53e
...
...
@@ -30,6 +30,7 @@
#include "caf/atom.hpp"
#include "caf/detail/type_list.hpp"
#include "caf/detail/squashed_int.hpp"
namespace
caf
{
...
...
@@ -76,20 +77,6 @@ using sorted_builtin_types =
float
// float
>
;
/// Compile-time list of integer types types.
using
int_types_by_size
=
detail
::
type_list
<
// bytes
void
,
// 0
detail
::
type_pair
<
int8_t
,
uint8_t
>
,
// 1
detail
::
type_pair
<
int16_t
,
uint16_t
>
,
// 2
void
,
// 3
detail
::
type_pair
<
int32_t
,
uint32_t
>
,
// 4
void
,
// 5
void
,
// 6
void
,
// 7
detail
::
type_pair
<
int64_t
,
uint64_t
>
// 8
>
;
/// Computes the type number for `T`.
template
<
class
T
,
bool
IsIntegral
=
std
::
is_integral
<
T
>
::
value
>
struct
type_nr
{
...
...
@@ -99,13 +86,7 @@ struct type_nr {
template
<
class
T
>
struct
type_nr
<
T
,
true
>
{
using
tpair
=
typename
detail
::
tl_at
<
int_types_by_size
,
sizeof
(
T
)
>::
type
;
using
type
=
typename
std
::
conditional
<
std
::
is_signed
<
T
>::
value
,
typename
tpair
::
first
,
typename
tpair
::
second
>::
type
;
using
type
=
detail
::
squashed_int_t
<
T
>
;
static
constexpr
uint16_t
value
=
static_cast
<
uint16_t
>
(
detail
::
tl_index_of
<
sorted_builtin_types
,
type
>::
value
+
1
);
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment