Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dynare
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Wenddy SHu
dynare
Commits
38c24347
Verified
Commit
38c24347
authored
6 years ago
by
Sébastien Villemot
Browse files
Options
Downloads
Patches
Plain Diff
Use C++14 std::conditional_t (instead of custom IF template)
parent
922014c2
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
dynare++/kord/korder.hh
+13
-24
13 additions, 24 deletions
dynare++/kord/korder.hh
dynare++/tl/cc/sthread.hh
+4
-16
4 additions, 16 deletions
dynare++/tl/cc/sthread.hh
with
17 additions
and
40 deletions
dynare++/kord/korder.hh
+
13
−
24
View file @
38c24347
...
@@ -41,6 +41,7 @@
...
@@ -41,6 +41,7 @@
#include
<dynlapack.h>
#include
<dynlapack.h>
#include
<cmath>
#include
<cmath>
#include
<type_traits>
#define TYPENAME typename
#define TYPENAME typename
...
@@ -69,35 +70,23 @@ class UnfoldedZXContainer;
...
@@ -69,35 +70,23 @@ class UnfoldedZXContainer;
class
FoldedGXContainer
;
class
FoldedGXContainer
;
class
UnfoldedGXContainer
;
class
UnfoldedGXContainer
;
template
<
bool
condition
,
class
Then
,
class
Else
>
struct
IF
{
using
RET
=
Then
;
};
template
<
class
Then
,
class
Else
>
struct
IF
<
false
,
Then
,
Else
>
{
using
RET
=
Else
;
};
template
<
int
type
>
template
<
int
type
>
class
ctraits
class
ctraits
{
{
public:
public:
enum
{
fold
,
unfold
};
enum
{
fold
,
unfold
};
using
Ttensor
=
TYPENAME
IF
<
type
==
fold
,
FGSTensor
,
UGSTensor
>
::
RET
;
using
Ttensor
=
std
::
conditional_t
<
type
==
fold
,
FGSTensor
,
UGSTensor
>
;
using
Ttensym
=
TYPENAME
IF
<
type
==
fold
,
FFSTensor
,
UFSTensor
>
::
RET
;
using
Ttensym
=
std
::
conditional_t
<
type
==
fold
,
FFSTensor
,
UFSTensor
>
;
using
Tg
=
TYPENAME
IF
<
type
==
fold
,
FGSContainer
,
UGSContainer
>
::
RET
;
using
Tg
=
std
::
conditional_t
<
type
==
fold
,
FGSContainer
,
UGSContainer
>
;
using
Tgs
=
TYPENAME
IF
<
type
==
fold
,
FGSContainer
,
UGSContainer
>
::
RET
;
using
Tgs
=
std
::
conditional_t
<
type
==
fold
,
FGSContainer
,
UGSContainer
>
;
using
Tgss
=
TYPENAME
IF
<
type
==
fold
,
FGSContainer
,
UGSContainer
>
::
RET
;
using
Tgss
=
std
::
conditional_t
<
type
==
fold
,
FGSContainer
,
UGSContainer
>
;
using
TG
=
TYPENAME
IF
<
type
==
fold
,
FGSContainer
,
UGSContainer
>
::
RET
;
using
TG
=
std
::
conditional_t
<
type
==
fold
,
FGSContainer
,
UGSContainer
>
;
using
TZstack
=
TYPENAME
IF
<
type
==
fold
,
FoldedZContainer
,
UnfoldedZContainer
>
::
RET
;
using
TZstack
=
std
::
conditional_t
<
type
==
fold
,
FoldedZContainer
,
UnfoldedZContainer
>
;
using
TGstack
=
TYPENAME
IF
<
type
==
fold
,
FoldedGContainer
,
UnfoldedGContainer
>
::
RET
;
using
TGstack
=
std
::
conditional_t
<
type
==
fold
,
FoldedGContainer
,
UnfoldedGContainer
>
;
using
Tm
=
TYPENAME
IF
<
type
==
fold
,
FNormalMoments
,
UNormalMoments
>
::
RET
;
using
Tm
=
std
::
conditional_t
<
type
==
fold
,
FNormalMoments
,
UNormalMoments
>
;
using
Tpol
=
TYPENAME
IF
<
type
==
fold
,
FTensorPolynomial
,
UTensorPolynomial
>
::
RET
;
using
Tpol
=
std
::
conditional_t
<
type
==
fold
,
FTensorPolynomial
,
UTensorPolynomial
>
;
using
TZXstack
=
TYPENAME
IF
<
type
==
fold
,
FoldedZXContainer
,
UnfoldedZXContainer
>
::
RET
;
using
TZXstack
=
std
::
conditional_t
<
type
==
fold
,
FoldedZXContainer
,
UnfoldedZXContainer
>
;
using
TGXstack
=
TYPENAME
IF
<
type
==
fold
,
FoldedGXContainer
,
UnfoldedGXContainer
>
::
RET
;
using
TGXstack
=
std
::
conditional_t
<
type
==
fold
,
FoldedGXContainer
,
UnfoldedGXContainer
>
;
};
};
/* The |PartitionY| class defines the partitioning of state variables
/* The |PartitionY| class defines the partitioning of state variables
...
...
This diff is collapsed.
Click to expand it.
dynare++/tl/cc/sthread.hh
+
4
−
16
View file @
38c24347
...
@@ -68,6 +68,7 @@
...
@@ -68,6 +68,7 @@
#include
<cstdio>
#include
<cstdio>
#include
<list>
#include
<list>
#include
<map>
#include
<map>
#include
<type_traits>
namespace
sthread
namespace
sthread
{
{
...
@@ -76,19 +77,6 @@ namespace sthread
...
@@ -76,19 +77,6 @@ namespace sthread
class
Empty
class
Empty
{
{
};
};
// classical IF template
/* Here is the classical IF template. */
template
<
bool
condition
,
class
Then
,
class
Else
>
struct
IF
{
using
RET
=
Then
;
};
template
<
class
Then
,
class
Else
>
struct
IF
<
false
,
Then
,
Else
>
{
using
RET
=
Else
;
};
enum
{
posix
,
empty
};
enum
{
posix
,
empty
};
...
@@ -103,7 +91,7 @@ namespace sthread
...
@@ -103,7 +91,7 @@ namespace sthread
template
<
int
thread_impl
>
template
<
int
thread_impl
>
struct
thread_traits
struct
thread_traits
{
{
using
_Tthread
=
typename
IF
<
thread_impl
==
posix
,
pthread_t
,
Empty
>
::
RET
;
using
_Tthread
=
std
::
conditional_t
<
thread_impl
==
posix
,
pthread_t
,
Empty
>
;
using
_Ctype
=
thread
<
0
>
;
using
_Ctype
=
thread
<
0
>
;
using
_Dtype
=
detach_thread
<
0
>
;
using
_Dtype
=
detach_thread
<
0
>
;
static
void
run
(
_Ctype
*
c
);
static
void
run
(
_Ctype
*
c
);
...
@@ -238,7 +226,7 @@ namespace sthread
...
@@ -238,7 +226,7 @@ namespace sthread
template
<
int
thread_impl
>
template
<
int
thread_impl
>
struct
mutex_traits
struct
mutex_traits
{
{
using
_Tmutex
=
typename
IF
<
thread_impl
==
posix
,
pthread_mutex_t
,
Empty
>
::
RET
;
using
_Tmutex
=
std
::
conditional_t
<
thread_impl
==
posix
,
pthread_mutex_t
,
Empty
>
;
using
mutex_int_map
=
map
<
mmkey
,
pair
<
_Tmutex
,
int
>
,
ltmmkey
>
;
using
mutex_int_map
=
map
<
mmkey
,
pair
<
_Tmutex
,
int
>
,
ltmmkey
>
;
static
void
init
(
_Tmutex
&
m
);
static
void
init
(
_Tmutex
&
m
);
static
void
lock
(
_Tmutex
&
m
);
static
void
lock
(
_Tmutex
&
m
);
...
@@ -406,7 +394,7 @@ namespace sthread
...
@@ -406,7 +394,7 @@ namespace sthread
template
<
int
thread_impl
>
template
<
int
thread_impl
>
struct
cond_traits
struct
cond_traits
{
{
using
_Tcond
=
typename
IF
<
thread_impl
==
posix
,
pthread_cond_t
,
Empty
>
::
RET
;
using
_Tcond
=
std
::
conditional_t
<
thread_impl
==
posix
,
pthread_cond_t
,
Empty
>
;
using
_Tmutex
=
typename
mutex_traits
<
thread_impl
>::
_Tmutex
;
using
_Tmutex
=
typename
mutex_traits
<
thread_impl
>::
_Tmutex
;
static
void
init
(
_Tcond
&
cond
);
static
void
init
(
_Tcond
&
cond
);
static
void
broadcast
(
_Tcond
&
cond
);
static
void
broadcast
(
_Tcond
&
cond
);
...
...
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