From 38c24347ff7f39d87c02f47a8f2dddb8daeb9464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Wed, 9 Jan 2019 17:26:28 +0100 Subject: [PATCH] Use C++14 std::conditional_t (instead of custom IF template) --- dynare++/kord/korder.hh | 37 +++++++++++++------------------------ dynare++/tl/cc/sthread.hh | 20 ++++---------------- 2 files changed, 17 insertions(+), 40 deletions(-) diff --git a/dynare++/kord/korder.hh b/dynare++/kord/korder.hh index efbba9041..ab9201554 100644 --- a/dynare++/kord/korder.hh +++ b/dynare++/kord/korder.hh @@ -41,6 +41,7 @@ #include #include +#include #define TYPENAME typename @@ -69,35 +70,23 @@ class UnfoldedZXContainer; class FoldedGXContainer; class UnfoldedGXContainer; -template -struct IF -{ - using RET = Then; -}; - -template -struct IF -{ - using RET = Else; -}; - template class ctraits { public: enum { fold, unfold }; - using Ttensor = TYPENAME IF::RET; - using Ttensym = TYPENAME IF::RET; - using Tg = TYPENAME IF::RET; - using Tgs = TYPENAME IF::RET; - using Tgss = TYPENAME IF::RET; - using TG = TYPENAME IF::RET; - using TZstack = TYPENAME IF::RET; - using TGstack = TYPENAME IF::RET; - using Tm = TYPENAME IF::RET; - using Tpol = TYPENAME IF::RET; - using TZXstack = TYPENAME IF::RET; - using TGXstack = TYPENAME IF::RET; + using Ttensor = std::conditional_t; + using Ttensym = std::conditional_t; + using Tg = std::conditional_t; + using Tgs = std::conditional_t; + using Tgss = std::conditional_t; + using TG = std::conditional_t; + using TZstack = std::conditional_t; + using TGstack = std::conditional_t; + using Tm = std::conditional_t; + using Tpol = std::conditional_t; + using TZXstack = std::conditional_t; + using TGXstack = std::conditional_t; }; /* The |PartitionY| class defines the partitioning of state variables diff --git a/dynare++/tl/cc/sthread.hh b/dynare++/tl/cc/sthread.hh index aab785d30..50bc7c53d 100644 --- a/dynare++/tl/cc/sthread.hh +++ b/dynare++/tl/cc/sthread.hh @@ -68,6 +68,7 @@ #include #include #include +#include namespace sthread { @@ -76,19 +77,6 @@ namespace sthread class Empty { }; - // classical IF template - /* Here is the classical IF template. */ - template - struct IF - { - using RET = Then; - }; - - template - struct IF - { - using RET = Else; - }; enum { posix, empty}; @@ -103,7 +91,7 @@ namespace sthread template struct thread_traits { - using _Tthread = typename IF::RET; + using _Tthread = std::conditional_t; using _Ctype = thread<0>; using _Dtype = detach_thread<0>; static void run(_Ctype *c); @@ -238,7 +226,7 @@ namespace sthread template struct mutex_traits { - using _Tmutex = typename IF::RET; + using _Tmutex = std::conditional_t; using mutex_int_map = map, ltmmkey>; static void init(_Tmutex &m); static void lock(_Tmutex &m); @@ -406,7 +394,7 @@ namespace sthread template struct cond_traits { - using _Tcond = typename IF::RET; + using _Tcond = std::conditional_t; using _Tmutex = typename mutex_traits::_Tmutex; static void init(_Tcond &cond); static void broadcast(_Tcond &cond);