Port to C++11 using keyword

Performed using modernize-use-using from clang-tidy.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-using.html
time-shift
Sébastien Villemot 2019-01-09 17:21:14 +01:00
parent 60fd92ddce
commit 922014c2fa
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
30 changed files with 174 additions and 172 deletions

View File

@ -70,8 +70,8 @@
class ZAuxContainer : public StackContainer<FGSTensor>, public FoldedStackContainer
{
public:
typedef StackContainer<FGSTensor>::_Ctype _Ctype;
typedef StackContainer<FGSTensor>::itype itype;
using _Ctype = StackContainer<FGSTensor>::_Ctype;
using itype = StackContainer<FGSTensor>::itype;
ZAuxContainer(const _Ctype *gss, int ngss, int ng, int ny, int nu);
itype getType(int i, const Symmetry &s) const override;
};

View File

@ -97,7 +97,7 @@ template <int t>
class DecisionRuleImpl : public ctraits<t>::Tpol, public DecisionRule
{
protected:
typedef typename ctraits<t>::Tpol _Tparent;
using _Tparent = typename ctraits<t>::Tpol;
const Vector ysteady;
const PartitionY ypart;
const int nu;
@ -482,7 +482,7 @@ public:
template <int t>
class DRFixPoint : public ctraits<t>::Tpol
{
typedef typename ctraits<t>::Tpol _Tparent;
using _Tparent = typename ctraits<t>::Tpol;
static int max_iter;
static int max_newton_iter;
static int newton_pause;
@ -492,7 +492,7 @@ class DRFixPoint : public ctraits<t>::Tpol
_Tparent *bigf;
_Tparent *bigfder;
public:
typedef typename DecisionRule::emethod emethod;
using emethod = typename DecisionRule::emethod;
DRFixPoint(const _Tg &g, const PartitionY &yp,
const Vector &ys, double sigma);

View File

@ -96,7 +96,7 @@ public:
char prefix[MAXLEN];
char mes[MAXLEN];
SystemResourcesFlash flash;
typedef JournalRecord & (*_Tfunc)(JournalRecord &);
using _Tfunc = JournalRecord &(*)(JournalRecord &);
JournalRecord(Journal &jr, char rc = 'M')
: recChar(rc), ord(jr.getOrd()), journal(jr)

View File

@ -72,13 +72,13 @@ class UnfoldedGXContainer;
template<bool condition, class Then, class Else>
struct IF
{
typedef Then RET;
using RET = Then;
};
template<class Then, class Else>
struct IF<false, Then, Else>
{
typedef Else RET;
using RET = Else;
};
template <int type>
@ -86,18 +86,18 @@ class ctraits
{
public:
enum { fold, unfold };
typedef TYPENAME IF<type == fold, FGSTensor, UGSTensor>::RET Ttensor;
typedef TYPENAME IF<type == fold, FFSTensor, UFSTensor>::RET Ttensym;
typedef TYPENAME IF<type == fold, FGSContainer, UGSContainer>::RET Tg;
typedef TYPENAME IF<type == fold, FGSContainer, UGSContainer>::RET Tgs;
typedef TYPENAME IF<type == fold, FGSContainer, UGSContainer>::RET Tgss;
typedef TYPENAME IF<type == fold, FGSContainer, UGSContainer>::RET TG;
typedef TYPENAME IF<type == fold, FoldedZContainer, UnfoldedZContainer>::RET TZstack;
typedef TYPENAME IF<type == fold, FoldedGContainer, UnfoldedGContainer>::RET TGstack;
typedef TYPENAME IF<type == fold, FNormalMoments, UNormalMoments>::RET Tm;
typedef TYPENAME IF<type == fold, FTensorPolynomial, UTensorPolynomial>::RET Tpol;
typedef TYPENAME IF<type == fold, FoldedZXContainer, UnfoldedZXContainer>::RET TZXstack;
typedef TYPENAME IF<type == fold, FoldedGXContainer, UnfoldedGXContainer>::RET TGXstack;
using Ttensor = TYPENAME IF<type == fold, FGSTensor, UGSTensor>::RET;
using Ttensym = TYPENAME IF<type == fold, FFSTensor, UFSTensor>::RET;
using Tg = TYPENAME IF<type == fold, FGSContainer, UGSContainer>::RET;
using Tgs = TYPENAME IF<type == fold, FGSContainer, UGSContainer>::RET;
using Tgss = TYPENAME IF<type == fold, FGSContainer, UGSContainer>::RET;
using TG = TYPENAME IF<type == fold, FGSContainer, UGSContainer>::RET;
using TZstack = TYPENAME IF<type == fold, FoldedZContainer, UnfoldedZContainer>::RET;
using TGstack = TYPENAME IF<type == fold, FoldedGContainer, UnfoldedGContainer>::RET;
using Tm = TYPENAME IF<type == fold, FNormalMoments, UNormalMoments>::RET;
using Tpol = TYPENAME IF<type == fold, FTensorPolynomial, UTensorPolynomial>::RET;
using TZXstack = TYPENAME IF<type == fold, FoldedZXContainer, UnfoldedZXContainer>::RET;
using TGXstack = TYPENAME IF<type == fold, FoldedGXContainer, UnfoldedGXContainer>::RET;
};
/* The |PartitionY| class defines the partitioning of state variables

View File

@ -247,9 +247,9 @@ template <class _Ttype>
class GXContainer : public GContainer<_Ttype>
{
public:
typedef StackContainerInterface<_Ttype> _Stype;
typedef typename StackContainer<_Ttype>::_Ctype _Ctype;
typedef typename StackContainer<_Ttype>::itype itype;
using _Stype = StackContainerInterface<_Ttype>;
using _Ctype = typename StackContainer<_Ttype>::_Ctype;
using itype = typename StackContainer<_Ttype>::itype;
GXContainer(const _Ctype *gs, int ngs, int nu)
: GContainer<_Ttype>(gs, ngs, nu)
{
@ -291,9 +291,9 @@ template <class _Ttype>
class ZXContainer : public ZContainer<_Ttype>
{
public:
typedef StackContainerInterface<_Ttype> _Stype;
typedef typename StackContainer<_Ttype>::_Ctype _Ctype;
typedef typename StackContainer<_Ttype>::itype itype;
using _Stype = StackContainerInterface<_Ttype>;
using _Ctype = typename StackContainer<_Ttype>::_Ctype;
using itype = typename StackContainer<_Ttype>::itype;
ZXContainer(const _Ctype *gss, int ngss, const _Ctype *g, int ng, int ny, int nu)
: ZContainer<_Ttype>(gss, ngss, g, ng, ny, nu)
{
@ -335,7 +335,7 @@ ZXContainer<_Ttype>::getType(int i, const Symmetry &s) const
class UnfoldedGXContainer : public GXContainer<UGSTensor>, public UnfoldedStackContainer
{
public:
typedef TensorContainer<UGSTensor> _Ctype;
using _Ctype = TensorContainer<UGSTensor>;
UnfoldedGXContainer(const _Ctype *gs, int ngs, int nu)
: GXContainer<UGSTensor>(gs, ngs, nu)
{
@ -345,7 +345,7 @@ public:
class FoldedGXContainer : public GXContainer<FGSTensor>, public FoldedStackContainer
{
public:
typedef TensorContainer<FGSTensor> _Ctype;
using _Ctype = TensorContainer<FGSTensor>;
FoldedGXContainer(const _Ctype *gs, int ngs, int nu)
: GXContainer<FGSTensor>(gs, ngs, nu)
{
@ -355,7 +355,7 @@ public:
class UnfoldedZXContainer : public ZXContainer<UGSTensor>, public UnfoldedStackContainer
{
public:
typedef TensorContainer<UGSTensor> _Ctype;
using _Ctype = TensorContainer<UGSTensor>;
UnfoldedZXContainer(const _Ctype *gss, int ngss, const _Ctype *g, int ng, int ny, int nu)
: ZXContainer<UGSTensor>(gss, ngss, g, ng, ny, nu)
{
@ -365,7 +365,7 @@ public:
class FoldedZXContainer : public ZXContainer<FGSTensor>, public FoldedStackContainer
{
public:
typedef TensorContainer<FGSTensor> _Ctype;
using _Ctype = TensorContainer<FGSTensor>;
FoldedZXContainer(const _Ctype *gss, int ngss, const _Ctype *g, int ng, int ny, int nu)
: ZXContainer<FGSTensor>(gss, ngss, g, ng, ny, nu)
{

View File

@ -16,7 +16,7 @@
class MersenneTwister : public RandomGenerator
{
protected:
typedef unsigned int uint32;
using uint32 = unsigned int;
enum {STATE_SIZE = 624};
enum {RECUR_OFFSET = 397};
uint32 statevec[STATE_SIZE];

View File

@ -26,7 +26,7 @@ namespace ogp
{
friend class AtomAsgnEvaluator;
protected:
typedef std::map<const char *, int, ltstr> Tvarintmap;
using Tvarintmap = std::map<const char *, int, ltstr>;
/** All atoms which should be sufficient for formulas at the
* right hand sides. The atoms should be filled with names
* (preregistered). This is a responsibility of the caller. */
@ -88,7 +88,7 @@ namespace ogp
public std::vector<double>
{
protected:
typedef std::map<int, double> Tusrvalmap;
using Tusrvalmap = std::map<int, double>;
Tusrvalmap user_values;
const AtomAssignings &aa;
public:

View File

@ -31,10 +31,10 @@ namespace ogp
class AtomSubstitutions
{
public:
typedef pair<const char *, int> Tshiftname;
typedef map<const char *, Tshiftname, ltstr> Tshiftmap;
typedef set<Tshiftname> Tshiftnameset;
typedef map<const char *, Tshiftnameset, ltstr> Toldnamemap;
using Tshiftname = pair<const char *, int>;
using Tshiftmap = map<const char *, Tshiftname, ltstr>;
using Tshiftnameset = set<Tshiftname>;
using Toldnamemap = map<const char *, Tshiftnameset, ltstr>;
protected:
/** This maps a new name to a shifted old name. This is, one
* entry looks as "a_m3 ==> a(-3)", saying that a variable

View File

@ -74,8 +74,8 @@ namespace ogp
{
public:
/** Type for a map mapping tree indices to double values. */
typedef map<int, double> Tconstantmap;
typedef map<int, int> Tintintmap;
using Tconstantmap = map<int, double>;
using Tintintmap = map<int, int>;
protected:
/** Map mapping a tree index of a constant to its double value. */
Tconstantmap cmap;
@ -124,7 +124,7 @@ namespace ogp
}
private:
/** Inverse map to Tconstantmap. */
typedef map<double, int> Tconstantinvmap;
using Tconstantinvmap = map<double, int>;
/** This is an inverse map to cmap. This is only used for fast
* queries for the existing double constants in check
* method and add_constant. */
@ -140,12 +140,12 @@ namespace ogp
{
public:
/** Definition of a type mapping lags to the indices of the variables. */
typedef map<int, int> Tlagmap;
using Tlagmap = map<int, int>;
protected:
/** Definition of a type mapping names of the atoms to Tlagmap. */
typedef map<const char *, Tlagmap, ltstr> Tvarmap;
using Tvarmap = map<const char *, Tlagmap, ltstr>;
/** Definition of a type mapping indices of variables to the variable names. */
typedef map<int, const char *> Tindexmap;
using Tindexmap = map<int, const char *>;
/** This is just a storage for variable names, since all other
* instances of a variable name just point to the memory
* allocated by this object. */

View File

@ -109,7 +109,7 @@ namespace ogp
{
protected:
/** Type for a map mapping a variable name to an integer. */
typedef map<const char *, int, ltstr> Tvarintmap;
using Tvarintmap = map<const char *, int, ltstr>;
/** Reference to atoms. */
const FineAtoms &atoms;
/** The vector of all endo and exo variables in outer
@ -175,7 +175,7 @@ namespace ogp
{
friend class AllvarOuterOrdering;
protected:
typedef map<const char *, int, ltstr> Tvarintmap;
using Tvarintmap = map<const char *, int, ltstr>;
private:
/** The vector of parameters names. The order gives the order
* the data is communicated with outside world. */

View File

@ -89,7 +89,7 @@ namespace ogp
/** For retrieving derivatives via a multiindex, we have a map
* mapping a multiindex to a derivative in the tder
* ordering. This means that indices[ind2der[index]] == index. */
typedef map<FoldMultiIndex, int, ltfmi> Tfmiintmap;
using Tfmiintmap = map<FoldMultiIndex, int, ltfmi>;
Tfmiintmap ind2der;
/** The number of variables. */
int nvar;

View File

@ -13,8 +13,8 @@ namespace ogp
class StaticAtoms : public Atoms, public Constants
{
protected:
typedef map<const char *, int, ltstr> Tvarmap;
typedef map<int, const char *> Tinvmap;
using Tvarmap = map<const char *, int, ltstr>;
using Tinvmap = map<int, const char *>;
/** Storage for names. */
NameStorage varnames;
/** Outer order of variables. */

View File

@ -22,9 +22,9 @@ namespace ogp
class StaticFineAtoms : public StaticAtoms
{
public:
typedef map<int, int> Tintintmap;
using Tintintmap = map<int, int>;
protected:
typedef map<const char *, int, ltstr> Tvarintmap;
using Tvarintmap = map<const char *, int, ltstr>;
private:
/** The vector of parameter names, gives the parameter
* ordering. */

View File

@ -181,22 +181,22 @@ namespace ogp
/** This defines a type for a map mapping the unary and binary
* operations to their indices. */
typedef unordered_map<Operation, int, ophash> _Topmap;
typedef _Topmap::value_type _Topval;
using _Topmap = unordered_map<Operation, int, ophash>;
using _Topval = _Topmap::value_type;
/** This is the map mapping the unary and binary operations to
* the indices of the terms.*/
_Topmap opmap;
/** This is a type for a set of integers. */
typedef unordered_set<int> _Tintset;
using _Tintset = unordered_set<int>;
/** This is a vector of integer sets corresponding to the
* nulary terms contained in the term. */
vector<_Tintset> nul_incidence;
/** This is a type of the map from variables (nulary terms) to
* the terms. */
typedef unordered_map<int, int> _Tderivmap;
using _Tderivmap = unordered_map<int, int>;
/** This is a vector of derivative mappings. For each term, it
* maps variables to the derivatives of the term with respect
* to the variables. */

View File

@ -24,7 +24,7 @@ namespace ogdyn
/** A definition of a type mapping a string to an integer. Used as
* a substitution map, saying what names are substituted for what
* expressions represented by tree indices. */
typedef map<const char *, int, ogp::ltstr> Tsubstmap;
using Tsubstmap = map<const char *, int, ogp::ltstr>;
class DynareStaticAtoms : public ogp::StaticAtoms
{
@ -54,7 +54,7 @@ namespace ogdyn
public:
enum atype {endovar, exovar, param};
protected:
typedef map<const char *, atype, ogp::ltstr> Tatypemap;
using Tatypemap = map<const char *, atype, ogp::ltstr>;
/** The map assigining a type to each name. */
Tatypemap atom_type;
public:

View File

@ -26,7 +26,7 @@ namespace ogdyn
class ForwSubstBuilder
{
typedef map<int, const char *> Ttermauxmap;
using Ttermauxmap = map<int, const char *>;
protected:
/** Reference to the model, to which we will add equations and
* change some equations. */

View File

@ -150,12 +150,12 @@ namespace ogdyn
friend class MultInitSS;
public:
/** Type for a set of variable names. */
typedef unordered_set<const char *> Tvarset;
using Tvarset = unordered_set<const char *>;
/** Type for a set of equations. An equation is identified by
* an index to an equation in the equation vector given by
* DynareModel::eqs. The tree index of the i-th formula is
* retrieved as DynareModel::egs.formula(i). */
typedef vector<int> Teqset;
using Teqset = vector<int>;
protected:
/** This is a set of variables wrt which the planner
* optimizes. These could be all endogenous variables, but it

View File

@ -150,7 +150,7 @@ public:
template <class _Tdiag, class _Tblock, class _Titer>
struct _diag_iter
{
typedef _diag_iter<_Tdiag, _Tblock, _Titer> _Self;
using _Self = _diag_iter<_Tdiag, _Tblock, _Titer>;
_Tdiag diag;
_Titer it;
public:
@ -197,8 +197,8 @@ public:
class Diagonal
{
public:
typedef _diag_iter<const Diagonal &, const DiagonalBlock &, list<DiagonalBlock>::const_iterator> const_diag_iter;
typedef _diag_iter<Diagonal &, DiagonalBlock &, list<DiagonalBlock>::iterator> diag_iter;
using const_diag_iter = _diag_iter<const Diagonal &, const DiagonalBlock &, list<DiagonalBlock>::const_iterator>;
using diag_iter = _diag_iter<Diagonal &, DiagonalBlock &, list<DiagonalBlock>::iterator>;
private:
int num_all{0};
list<DiagonalBlock> blocks;
@ -281,7 +281,7 @@ private:
template <class _TRef, class _TPtr>
struct _matrix_iter
{
typedef _matrix_iter<_TRef, _TPtr> _Self;
using _Self = _matrix_iter<_TRef, _TPtr>;
int d_size;
bool real;
_TPtr ptr;
@ -323,8 +323,8 @@ public:
template <class _TRef, class _TPtr>
class _column_iter : public _matrix_iter<_TRef, _TPtr>
{
typedef _matrix_iter<_TRef, _TPtr> _Tparent;
typedef _column_iter<_TRef, _TPtr> _Self;
using _Tparent = _matrix_iter<_TRef, _TPtr>;
using _Self = _column_iter<_TRef, _TPtr>;
int row;
public:
_column_iter(_TPtr base, int ds, bool r, int rw)
@ -358,8 +358,8 @@ public:
template <class _TRef, class _TPtr>
class _row_iter : public _matrix_iter<_TRef, _TPtr>
{
typedef _matrix_iter<_TRef, _TPtr> _Tparent;
typedef _row_iter<_TRef, _TPtr> _Self;
using _Tparent = _matrix_iter<_TRef, _TPtr>;
using _Self = _row_iter<_TRef, _TPtr>;
int col;
public:
_row_iter(_TPtr base, int ds, bool r, int cl)
@ -396,12 +396,12 @@ class SchurDecompZero;
class QuasiTriangular : public SqSylvMatrix
{
public:
typedef _column_iter<const double &, const double *> const_col_iter;
typedef _column_iter<double &, double *> col_iter;
typedef _row_iter<const double &, const double *> const_row_iter;
typedef _row_iter<double &, double *> row_iter;
typedef Diagonal::const_diag_iter const_diag_iter;
typedef Diagonal::diag_iter diag_iter;
using const_col_iter = _column_iter<const double &, const double *>;
using col_iter = _column_iter<double &, double *>;
using const_row_iter = _row_iter<const double &, const double *>;
using row_iter = _row_iter<double &, double *>;
using const_diag_iter = Diagonal::const_diag_iter;
using diag_iter = Diagonal::diag_iter;
protected:
Diagonal diagonal;
public:

View File

@ -13,7 +13,7 @@
class SchurDecompEig : public SchurDecomp
{
public:
typedef QuasiTriangular::diag_iter diag_iter;
using diag_iter = QuasiTriangular::diag_iter;
SchurDecompEig(const SqSylvMatrix &m) : SchurDecomp(m)
{
}

View File

@ -14,7 +14,7 @@ class SimilarityDecomp
SqSylvMatrix *q;
BlockDiagonal *b;
SqSylvMatrix *invq;
typedef BlockDiagonal::diag_iter diag_iter;
using diag_iter = BlockDiagonal::diag_iter;
public:
SimilarityDecomp(const double *d, int d_size, double log10norm = 3.0);
virtual

View File

@ -18,7 +18,7 @@ template <class _Type>
struct ParamItem
{
protected:
typedef ParamItem<_Type> _Self;
using _Self = ParamItem<_Type>;
status s;
_Type value;
public:
@ -74,7 +74,7 @@ public:
class SylvParams
{
public:
typedef enum {iter, recurse} solve_method;
using solve_method = enum {iter, recurse};
protected:
class DoubleParamItem : public ParamItem<double>

View File

@ -76,8 +76,8 @@ private:
/* recursivelly calculates kronecker product of complex vectors (used in getEigSep) */
static void multEigVector(KronVector &eig, const Vector &feig, const Vector &keig);
/* auxiliary typedefs */
typedef QuasiTriangular::const_diag_iter const_diag_iter;
typedef QuasiTriangular::const_row_iter const_row_iter;
using const_diag_iter = QuasiTriangular::const_diag_iter;
using const_row_iter = QuasiTriangular::const_row_iter;
/* called from solvi */
void solviRealAndEliminate(double r, const_diag_iter di,
KronVector &d, double &eig_min) const;

View File

@ -99,8 +99,8 @@ private:
int n;
list<OrdSequence> classes;
public:
typedef list<OrdSequence>::const_iterator const_seqit;
typedef list<OrdSequence>::iterator seqit;
using const_seqit = list<OrdSequence>::const_iterator;
using seqit = list<OrdSequence>::iterator;
/* The first constructor constructs $\{\{0\},\{1\},\ldots,\{n-1\}\}$.
@ -185,7 +185,7 @@ class EquivalenceSet
int n;
list<Equivalence> equis;
public:
typedef list<Equivalence>::const_iterator const_iterator;
using const_iterator = list<Equivalence>::const_iterator;
EquivalenceSet(int num);
void print(const char *prefix) const;
const_iterator

View File

@ -75,9 +75,9 @@ template <class _Ttype>
class FineContainer : public SizeRefinement, public StackContainer<_Ttype>
{
protected:
typedef StackContainer<_Ttype> _Stype;
typedef typename StackContainerInterface<_Ttype>::_Ctype _Ctype;
typedef typename StackContainerInterface<_Ttype>::itype itype;
using _Stype = StackContainer<_Ttype>;
using _Ctype = typename StackContainerInterface<_Ttype>::_Ctype;
using itype = typename StackContainerInterface<_Ttype>::itype;
_Ctype **const ref_conts;
const _Stype &stack_cont;
public:

View File

@ -50,11 +50,11 @@ struct ltseq
class SparseTensor
{
public:
typedef pair<int, double> Item;
typedef multimap<IntSequence, Item, ltseq> Map;
typedef Map::const_iterator const_iterator;
using Item = pair<int, double>;
using Map = multimap<IntSequence, Item, ltseq>;
using const_iterator = Map::const_iterator;
protected:
typedef Map::iterator iterator;
using iterator = Map::iterator;
Map m;
const int dim;
@ -128,7 +128,7 @@ public:
class FSSparseTensor : public SparseTensor
{
public:
typedef SparseTensor::const_iterator const_iterator;
using const_iterator = SparseTensor::const_iterator;
private:
const int nv;
const Symmetry sym;
@ -158,7 +158,7 @@ public:
class GSSparseTensor : public SparseTensor
{
public:
typedef SparseTensor::const_iterator const_iterator;
using const_iterator = SparseTensor::const_iterator;
private:
const TensorDimens tdims;
public:

View File

@ -92,8 +92,8 @@ template <class _Ttype>
class StackContainerInterface
{
public:
typedef TensorContainer<_Ttype> _Ctype;
typedef enum { matrix, unit, zero} itype;
using _Ctype = TensorContainer<_Ttype>;
using itype = enum { matrix, unit, zero};
protected:
const EquivalenceBundle &ebundle;
public:
@ -134,9 +134,9 @@ template <class _Ttype>
class StackContainer : virtual public StackContainerInterface<_Ttype>
{
public:
typedef StackContainerInterface<_Ttype> _Stype;
typedef typename StackContainerInterface<_Ttype>::_Ctype _Ctype;
typedef typename StackContainerInterface<_Ttype>::itype itype;
using _Stype = StackContainerInterface<_Ttype>;
using _Ctype = typename StackContainerInterface<_Ttype>::_Ctype;
using itype = typename StackContainerInterface<_Ttype>::itype;
protected:
int num_conts;
IntSequence stack_sizes;
@ -341,10 +341,10 @@ template <class _Ttype>
class ZContainer : public StackContainer<_Ttype>
{
public:
typedef StackContainer<_Ttype> _Tparent;
typedef StackContainerInterface<_Ttype> _Stype;
typedef typename _Tparent::_Ctype _Ctype;
typedef typename _Tparent::itype itype;
using _Tparent = StackContainer<_Ttype>;
using _Stype = StackContainerInterface<_Ttype>;
using _Ctype = typename _Tparent::_Ctype;
using itype = typename _Tparent::itype;
ZContainer(const _Ctype *gss, int ngss, const _Ctype *g, int ng,
int ny, int nu)
: _Tparent(4, 2)
@ -390,7 +390,7 @@ class FoldedZContainer : public ZContainer<FGSTensor>,
public FoldedStackContainer
{
public:
typedef TensorContainer<FGSTensor> _Ctype;
using _Ctype = TensorContainer<FGSTensor>;
FoldedZContainer(const _Ctype *gss, int ngss, const _Ctype *g, int ng,
int ny, int nu)
: ZContainer<FGSTensor>(gss, ngss, g, ng, ny, nu)
@ -402,7 +402,7 @@ class UnfoldedZContainer : public ZContainer<UGSTensor>,
public UnfoldedStackContainer
{
public:
typedef TensorContainer<UGSTensor> _Ctype;
using _Ctype = TensorContainer<UGSTensor>;
UnfoldedZContainer(const _Ctype *gss, int ngss, const _Ctype *g, int ng,
int ny, int nu)
: ZContainer<UGSTensor>(gss, ngss, g, ng, ny, nu)
@ -424,10 +424,10 @@ template <class _Ttype>
class GContainer : public StackContainer<_Ttype>
{
public:
typedef StackContainer<_Ttype> _Tparent;
typedef StackContainerInterface<_Ttype> _Stype;
typedef typename StackContainer<_Ttype>::_Ctype _Ctype;
typedef typename StackContainer<_Ttype>::itype itype;
using _Tparent = StackContainer<_Ttype>;
using _Stype = StackContainerInterface<_Ttype>;
using _Ctype = typename StackContainer<_Ttype>::_Ctype;
using itype = typename StackContainer<_Ttype>::itype;
GContainer(const _Ctype *gs, int ngs, int nu)
: StackContainer<_Ttype>(4, 1)
{
@ -473,7 +473,7 @@ class FoldedGContainer : public GContainer<FGSTensor>,
public FoldedStackContainer
{
public:
typedef TensorContainer<FGSTensor> _Ctype;
using _Ctype = TensorContainer<FGSTensor>;
FoldedGContainer(const _Ctype *gs, int ngs, int nu)
: GContainer<FGSTensor>(gs, ngs, nu)
{
@ -484,7 +484,7 @@ class UnfoldedGContainer : public GContainer<UGSTensor>,
public UnfoldedStackContainer
{
public:
typedef TensorContainer<UGSTensor> _Ctype;
using _Ctype = TensorContainer<UGSTensor>;
UnfoldedGContainer(const _Ctype *gs, int ngs, int nu)
: GContainer<UGSTensor>(gs, ngs, nu)
{
@ -501,9 +501,9 @@ template <class _Ttype>
class StackProduct
{
public:
typedef StackContainerInterface<_Ttype> _Stype;
typedef typename _Stype::_Ctype _Ctype;
typedef typename _Stype::itype itype;
using _Stype = StackContainerInterface<_Ttype>;
using _Ctype = typename _Stype::_Ctype;
using itype = typename _Stype::itype;
protected:
const _Stype &stack_cont;
InducedSymmetries syms;
@ -611,8 +611,8 @@ template <class _Ttype>
class KronProdStack : public KronProdAllOptim
{
public:
typedef StackProduct<_Ttype> _Ptype;
typedef StackContainerInterface<_Ttype> _Stype;
using _Ptype = StackProduct<_Ttype>;
using _Stype = StackContainerInterface<_Ttype>;
/* Here we construct |KronProdAllOptim| from |StackContainer| and given
selections of stack items from stack containers in the product. We

View File

@ -81,29 +81,45 @@ namespace sthread
template<bool condition, class Then, class Else>
struct IF
{
typedef Then RET;
using RET = Then;
};
template<class Then, class Else>
struct IF<false, Then, Else>
{
typedef Else RET;
using RET = Else;
};
enum { posix, empty};
template <int>
class thread_traits;
template <int thread_impl>
class thread;
template <int>
class detach_thread;
/* Clear. We have only |run|, |detach_run|, |exit| and |join|, since
this is only a simple interface. */
template <int thread_impl>
struct thread_traits
{
using _Tthread = typename IF<thread_impl == posix, pthread_t, Empty>::RET;
using _Ctype = thread<0>;
using _Dtype = detach_thread<0>;
static void run(_Ctype *c);
static void detach_run(_Dtype *c);
static void exit();
static void join(_Ctype *c);
};
/* The class of |thread| is clear. The user implements |operator()()|,
the method |run| runs the user's code as joinable thread, |exit| kills the
execution. */
template <int thread_impl>
class thread
{
typedef thread_traits<thread_impl> _Ttraits;
typedef typename _Ttraits::_Tthread _Tthread;
using _Ttraits = thread_traits<0>;
using _Tthread = typename _Ttraits::_Tthread;
_Tthread th;
public:
virtual ~thread()
@ -144,10 +160,10 @@ namespace sthread
template <int thread_impl>
class thread_group
{
typedef thread_traits<thread_impl> _Ttraits;
typedef thread<thread_impl> _Ctype;
using _Ttraits = thread_traits<thread_impl>;
using _Ctype = thread<thread_impl>;
list<_Ctype *> tlist;
typedef typename list<_Ctype *>::iterator iterator;
using iterator = typename list<_Ctype *>::iterator;
public:
static int max_parallel_threads;
void
@ -214,30 +230,16 @@ namespace sthread
}
};
/* Clear. We have only |run|, |detach_run|, |exit| and |join|, since
this is only a simple interface. */
template <int thread_impl>
struct thread_traits
{
typedef typename IF<thread_impl == posix, pthread_t, Empty>::RET _Tthread;
typedef thread<thread_impl> _Ctype;
typedef detach_thread<thread_impl> _Dtype;
static void run(_Ctype *c);
static void detach_run(_Dtype *c);
static void exit();
static void join(_Ctype *c);
};
/* Clear. We have only |init|, |lock|, and |unlock|. */
struct ltmmkey;
typedef pair<const void *, const char *> mmkey;
using mmkey = pair<const void *, const char *>;
template <int thread_impl>
struct mutex_traits
{
typedef typename IF<thread_impl == posix, pthread_mutex_t, Empty>::RET _Tmutex;
typedef map<mmkey, pair<_Tmutex, int>, ltmmkey> mutex_int_map;
using _Tmutex = typename IF<thread_impl == posix, pthread_mutex_t, Empty>::RET;
using mutex_int_map = map<mmkey, pair<_Tmutex, int>, ltmmkey>;
static void init(_Tmutex &m);
static void lock(_Tmutex &m);
static void unlock(_Tmutex &m);
@ -274,12 +276,12 @@ namespace sthread
class mutex_map :
public mutex_traits<thread_impl>::mutex_int_map
{
typedef typename mutex_traits<thread_impl>::_Tmutex _Tmutex;
typedef mutex_traits<thread_impl> _Mtraits;
typedef pair<_Tmutex, int> mmval;
typedef map<mmkey, mmval, ltmmkey> _Tparent;
typedef typename _Tparent::iterator iterator;
typedef typename _Tparent::value_type _mvtype;
using _Tmutex = typename mutex_traits<thread_impl>::_Tmutex;
using _Mtraits = mutex_traits<thread_impl>;
using mmval = pair<_Tmutex, int>;
using _Tparent = map<mmkey, mmval, ltmmkey>;
using iterator = typename _Tparent::iterator;
using _mvtype = typename _Tparent::value_type;
_Tmutex m;
public:
mutex_map()
@ -340,10 +342,10 @@ namespace sthread
template <int thread_impl>
class synchro
{
typedef typename mutex_traits<thread_impl>::_Tmutex _Tmutex;
typedef mutex_traits<thread_impl> _Mtraits;
using _Tmutex = typename mutex_traits<thread_impl>::_Tmutex;
using _Mtraits = mutex_traits<0>;
public:
typedef mutex_map<thread_impl> mutex_map_t;
using mutex_map_t = mutex_map<0>;
private:
const void *caller;
const char *iden;
@ -404,8 +406,8 @@ namespace sthread
template <int thread_impl>
struct cond_traits
{
typedef typename IF<thread_impl == posix, pthread_cond_t, Empty>::RET _Tcond;
typedef typename mutex_traits<thread_impl>::_Tmutex _Tmutex;
using _Tcond = typename IF<thread_impl == posix, pthread_cond_t, Empty>::RET;
using _Tmutex = typename mutex_traits<thread_impl>::_Tmutex;
static void init(_Tcond &cond);
static void broadcast(_Tcond &cond);
static void wait(_Tcond &cond, _Tmutex &mutex);
@ -424,8 +426,8 @@ namespace sthread
template <int thread_impl>
class condition_counter
{
typedef typename mutex_traits<thread_impl>::_Tmutex _Tmutex;
typedef typename cond_traits<thread_impl>::_Tcond _Tcond;
using _Tmutex = typename mutex_traits<thread_impl>::_Tmutex;
using _Tcond = typename cond_traits<thread_impl>::_Tcond;
int counter{0};
_Tmutex mut;
_Tcond cond;
@ -524,11 +526,11 @@ namespace sthread
template<int thread_impl>
class detach_thread_group
{
typedef thread_traits<thread_impl> _Ttraits;
typedef cond_traits<thread_impl> _Ctraits;
typedef detach_thread<thread_impl> _Ctype;
using _Ttraits = thread_traits<thread_impl>;
using _Ctraits = cond_traits<thread_impl>;
using _Ctype = detach_thread<thread_impl>;
list<_Ctype *> tlist;
typedef typename list<_Ctype *>::iterator iterator;
using iterator = typename list<_Ctype *>::iterator;
condition_counter<thread_impl> counter;
public:
static int max_parallel_threads;
@ -583,9 +585,9 @@ namespace sthread
/* Here we only define the specializations for POSIX threads. Then we
define the macros. Note that the |PosixSynchro| class construct itself
from the static map defined in {\tt sthreads.cpp}. */
typedef detach_thread<posix> PosixThread;
typedef detach_thread_group<posix> PosixThreadGroup;
typedef synchro<posix> posix_synchro;
using PosixThread = detach_thread<posix>;
using PosixThreadGroup = detach_thread_group<posix>;
using posix_synchro = synchro<posix>;
class PosixSynchro : public posix_synchro
{
public:
@ -602,9 +604,9 @@ namespace sthread
mutex. |NoSynchro| class is also empty, but an empty constructor is
declared. The empty destructor is declared only to avoid ``unused
variable warning''. */
typedef thread<empty> NoThread;
typedef thread_group<empty> NoThreadGroup;
typedef synchro<empty> no_synchro;
using NoThread = thread<empty>;
using NoThreadGroup = thread_group<empty>;
using no_synchro = synchro<empty>;
class NoSynchro
{
public:

View File

@ -94,13 +94,13 @@ template<class _Ttype>
class TensorContainer
{
protected:
typedef const _Ttype *_const_ptr;
typedef _Ttype *_ptr;
typedef map<Symmetry, _ptr, ltsym> _Map;
typedef typename _Map::value_type _mvtype;
using _const_ptr = const _Ttype *;
using _ptr = _Ttype *;
using _Map = map<Symmetry, _ptr, ltsym>;
using _mvtype = typename _Map::value_type;
public:
typedef typename _Map::iterator iterator;
typedef typename _Map::const_iterator const_iterator;
using iterator = typename _Map::iterator;
using const_iterator = typename _Map::const_iterator;
private:
int n;
_Map m;

View File

@ -97,8 +97,8 @@ class TensorPolynomial : public TensorContainer<_Ttype>
int nr;
int nv;
int maxdim;
typedef TensorContainer<_Ttype> _Tparent;
typedef typename _Tparent::_ptr _ptr;
using _Tparent = TensorContainer<_Ttype>;
using _ptr = typename _Tparent::_ptr;
public:
TensorPolynomial(int rows, int vars)
: TensorContainer<_Ttype>(1),

View File

@ -76,7 +76,7 @@
template<class _Tptr>
class _index
{
typedef _index<_Tptr> _Self;
using _Self = _index<_Tptr>;
_Tptr tensor;
int offset;
IntSequence coor;
@ -162,7 +162,7 @@ class Tensor : public TwoDMatrix
{
public:
enum indor {along_row, along_col};
typedef _index<const Tensor *> index;
using index = _index<const Tensor *>;
protected:
const index in_beg;
const index in_end;