Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Algorithms Library Toolkit Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Hello
GitLab will be updated tonight at 22:00. Expect short outage.
Show more breadcrumbs
Algorithms Library Toolkit
Algorithms Library Toolkit Core
Commits
cf8f91eb
Commit
cf8f91eb
authored
5 years ago
by
Jan Travnicek
Committed by
Jan Trávníček
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
use constexpr_switch elsewhere
parent
e1800140
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
alib2abstraction/src/common/AbstractionHelpers.hpp
+17
-21
17 additions, 21 deletions
alib2abstraction/src/common/AbstractionHelpers.hpp
with
17 additions
and
21 deletions
alib2abstraction/src/common/AbstractionHelpers.hpp
+
17
−
21
View file @
cf8f91eb
...
@@ -50,33 +50,29 @@ struct CheckInput {
...
@@ -50,33 +50,29 @@ struct CheckInput {
};
};
template
<
class
...
Params
>
template
<
class
...
Params
>
struct
ParamType
;
struct
ParamType
{
static
ext
::
type_index
paramType
(
unsigned
index
)
{
ext
::
type_index
res
(
typeid
(
void
)
);
template
<
>
auto
lambda
=
[
&
]
(
auto
I
)
{
struct
ParamType
<
>
{
res
=
ext
::
type_index
(
typeid
(
std
::
tuple_element_t
<
decltype
(
I
)
::
value
,
std
::
tuple
<
Params
...
>
>
)
);
static
ext
::
type_index
paramType
(
unsigned
)
{
};
throw
std
::
logic_error
(
"Out of types to check"
);
}
static
ext
::
set
<
abstraction
::
ParamQualifiers
::
ParamQualifier
>
paramTypeQualifiers
(
unsigned
)
{
ext
::
constexpr_switch
<
sizeof
...
(
Params
)
>
(
index
,
lambda
);
throw
std
::
logic_error
(
"Out of types to check"
);
}
};
template
<
class
Param
,
class
...
Params
>
return
res
;
struct
ParamType
<
Param
,
Params
...
>
{
static
ext
::
type_index
paramType
(
unsigned
index
)
{
if
(
index
==
0
)
return
ext
::
type_index
(
typeid
(
Param
)
);
else
return
ParamType
<
Params
...
>::
paramType
(
index
-
1
);
}
}
static
ext
::
set
<
abstraction
::
ParamQualifiers
::
ParamQualifier
>
paramTypeQualifiers
(
unsigned
index
)
{
static
ext
::
set
<
abstraction
::
ParamQualifiers
::
ParamQualifier
>
paramTypeQualifiers
(
unsigned
index
)
{
if
(
index
==
0
)
ext
::
set
<
abstraction
::
ParamQualifiers
::
ParamQualifier
>
res
;
return
abstraction
::
ParamQualifiers
::
paramQualifiers
<
Param
>
(
);
else
auto
lambda
=
[
&
]
(
auto
I
)
{
return
ParamType
<
Params
...
>::
paramTypeQualifiers
(
index
-
1
);
res
=
abstraction
::
ParamQualifiers
::
paramQualifiers
<
std
::
tuple_element_t
<
decltype
(
I
)
::
value
,
std
::
tuple
<
Params
...
>
>
>
(
);
};
ext
::
constexpr_switch
<
sizeof
...
(
Params
)
>
(
index
,
lambda
);
return
res
;
}
}
};
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment