Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Özgür Ozan Sen
ogs
Commits
c913f38d
Commit
c913f38d
authored
8 years ago
by
Christoph Lehmann
Browse files
Options
Downloads
Patches
Plain Diff
[BL] added metaprogramming integer sequence
parent
762bacca
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
BaseLib/TMPUtil.h
+46
-0
46 additions, 0 deletions
BaseLib/TMPUtil.h
with
46 additions
and
0 deletions
BaseLib/TMPUtil.h
0 → 100644
+
46
−
0
View file @
c913f38d
/**
* \copyright
* Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#ifndef BASELIB_TMPUTIL_H
#define BASELIB_TMPUTIL_H
namespace
BaseLib
{
//! Has sequence of integers as template parameters
template
<
int
...>
struct
IntegerSequence
{
};
//! Generates an IntegerSequence.
//!
//! \see http://stackoverflow.com/a/7858971
template
<
int
N
,
int
...
S
>
struct
GenerateIntegerSequence
{
// effectively pushes N-1 from the left to the list int... S of integers.
typedef
typename
GenerateIntegerSequence
<
N
-
1
,
N
-
1
,
S
...
>::
type
type
;
};
template
<
int
...
S
>
struct
GenerateIntegerSequence
<
0
,
S
...
>
{
typedef
IntegerSequence
<
S
...
>
type
;
};
/* The template metaprogram proceeds in the following way:
*
* GenerateIntegerSequence<sizeof...(Args)>::type
*
* Assume sizeof...(Args) == 3. Let GIS := GenerateIntegerSequence
* GIS<3, []>
* -> GIS<2, [2]>
* -> GIS<1, [1, 2]>
* -> GIS<0, [0, 1, 2], which has member typedef IntegerSequence<0, 1, 2>
*/
}
// namespace BaseLib
#endif // BASELIB_TMPUTIL_H
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