Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
057946f0
Commit
057946f0
authored
May 18, 2016
by
Harris Hancock
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reimplement Kind_ using VoidSfinae
parent
a4c634c0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
16 deletions
+11
-16
common.h
c++/src/capnp/common.h
+11
-16
No files found.
c++/src/capnp/common.h
View file @
057946f0
...
...
@@ -127,18 +127,7 @@ struct EnumInfo;
namespace
_
{
// private
template
<
typename
T
,
typename
=
typename
T
::
_capnpPrivate
::
IsStruct
>
uint8_t
kindSfinae
(
int
);
template
<
typename
T
,
typename
=
typename
T
::
_capnpPrivate
::
IsInterface
>
uint16_t
kindSfinae
(
int
);
template
<
typename
T
,
typename
=
typename
schemas
::
EnumInfo
<
T
>::
IsEnum
>
uint32_t
kindSfinae
(
int
);
template
<
typename
T
>
uint64_t
kindSfinae
(...);
template
<
typename
T
>
struct
MsvcWorkaround
{
// TODO(msvc): Remove this once MSVC supports expression SFINAE.
enum
{
value
=
sizeof
(
kindSfinae
<
T
>
(
0
))
};
};
template
<
typename
T
,
size_t
s
=
MsvcWorkaround
<
T
>::
value
>
struct
Kind_
;
template
<
typename
T
,
typename
=
void
>
struct
Kind_
;
template
<>
struct
Kind_
<
Void
>
{
static
constexpr
Kind
kind
=
Kind
::
PRIMITIVE
;
};
template
<>
struct
Kind_
<
bool
>
{
static
constexpr
Kind
kind
=
Kind
::
PRIMITIVE
;
};
...
...
@@ -155,9 +144,15 @@ template <> struct Kind_<double> { static constexpr Kind kind = Kind::PRIMITIVE;
template
<>
struct
Kind_
<
Text
>
{
static
constexpr
Kind
kind
=
Kind
::
BLOB
;
};
template
<>
struct
Kind_
<
Data
>
{
static
constexpr
Kind
kind
=
Kind
::
BLOB
;
};
template
<
typename
T
>
struct
Kind_
<
T
,
sizeof
(
uint8_t
)
>
{
static
constexpr
Kind
kind
=
Kind
::
STRUCT
;
};
template
<
typename
T
>
struct
Kind_
<
T
,
sizeof
(
uint16_t
)
>
{
static
constexpr
Kind
kind
=
Kind
::
INTERFACE
;
};
template
<
typename
T
>
struct
Kind_
<
T
,
sizeof
(
uint32_t
)
>
{
static
constexpr
Kind
kind
=
Kind
::
ENUM
;
};
template
<
typename
T
>
struct
Kind_
<
T
,
kj
::
VoidSfinae
<
typename
T
::
_capnpPrivate
::
IsStruct
>>
{
static
constexpr
Kind
kind
=
Kind
::
STRUCT
;
};
template
<
typename
T
>
struct
Kind_
<
T
,
kj
::
VoidSfinae
<
typename
T
::
_capnpPrivate
::
IsInterface
>>
{
static
constexpr
Kind
kind
=
Kind
::
INTERFACE
;
};
template
<
typename
T
>
struct
Kind_
<
T
,
kj
::
VoidSfinae
<
typename
schemas
::
EnumInfo
<
T
>::
IsEnum
>>
{
static
constexpr
Kind
kind
=
Kind
::
ENUM
;
};
}
// namespace _ (private)
...
...
@@ -206,7 +201,7 @@ template <typename T> struct ListElementType_<List<T>> { typedef T Type; };
template
<
typename
T
>
using
ListElementType
=
typename
ListElementType_
<
T
>::
Type
;
namespace
_
{
// private
template
<
typename
T
,
Kind
k
>
struct
Kind_
<
List
<
T
,
k
>
,
sizeof
(
uint64_t
)
>
{
template
<
typename
T
,
Kind
k
>
struct
Kind_
<
List
<
T
,
k
>>
{
static
constexpr
Kind
kind
=
Kind
::
LIST
;
};
}
// namespace _ (private)
...
...
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