From 6e83b6a20382cf07d7e87761b05d2b75aadb6e91 Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Mon, 2 May 2016 19:31:21 -0700 Subject: [PATCH] Hadrons: namespace reorganisation, now everything is in Grid::Hadrons, the 'using Grid::operator<<' statement is used to prevent a very nasty compilation error with GCC. --- programs/Hadrons/AWilson.cc | 1 + programs/Hadrons/Application.cc | 1 + programs/Hadrons/CMeson.cc | 3 ++- programs/Hadrons/Factory.hpp | 4 ++-- programs/Hadrons/FermionAction.cc | 1 + programs/Hadrons/Global.cc | 1 + programs/Hadrons/Global.hpp | 13 +++++++++---- programs/Hadrons/Graph.hpp | 4 ++-- programs/Hadrons/Hadrons.cc | 2 ++ programs/Hadrons/MQuark.cc | 1 + programs/Hadrons/MSource.cc | 2 ++ programs/Hadrons/Module.cc | 1 + programs/Hadrons/SRBPrecCG.cc | 1 + 13 files changed, 26 insertions(+), 9 deletions(-) diff --git a/programs/Hadrons/AWilson.cc b/programs/Hadrons/AWilson.cc index 2f8483f3..f9de0926 100644 --- a/programs/Hadrons/AWilson.cc +++ b/programs/Hadrons/AWilson.cc @@ -29,6 +29,7 @@ directory. #include using namespace Grid; +using namespace QCD; using namespace Hadrons; /****************************************************************************** diff --git a/programs/Hadrons/Application.cc b/programs/Hadrons/Application.cc index 5cdb6ed2..1a24f8b6 100644 --- a/programs/Hadrons/Application.cc +++ b/programs/Hadrons/Application.cc @@ -29,6 +29,7 @@ directory. #include using namespace Grid; +using namespace QCD; using namespace Hadrons; /****************************************************************************** diff --git a/programs/Hadrons/CMeson.cc b/programs/Hadrons/CMeson.cc index c171fb95..a6e958f9 100644 --- a/programs/Hadrons/CMeson.cc +++ b/programs/Hadrons/CMeson.cc @@ -28,6 +28,7 @@ directory. #include using namespace Grid; +using namespace QCD; using namespace Hadrons; /****************************************************************************** @@ -85,7 +86,7 @@ void CMeson::execute(Environment &env) result.corr[iSink].resize(Ns*Ns); for (unsigned int iSrc = 0; iSrc < Ns*Ns; ++iSrc) { - c = trace(g[iSink]*q1*g[iSrc]*g5*adj(q2)*g5); + c = trace(g[iSink]*q1*g[iSrc]*g5*adj(q2)*g5); sliceSum(c, buf, Tp); result.corr[iSink][iSrc].resize(buf.size()); for (unsigned int t = 0; t < buf.size(); ++t) diff --git a/programs/Hadrons/Factory.hpp b/programs/Hadrons/Factory.hpp index 2b219dcc..e609949a 100644 --- a/programs/Hadrons/Factory.hpp +++ b/programs/Hadrons/Factory.hpp @@ -47,7 +47,7 @@ public: virtual ~Factory(void) = default; // registration void registerBuilder(const std::string type, const Func &f); - // get module list + // get builder list std::vector getBuilderList(void) const; // factory std::unique_ptr create(const std::string type, @@ -91,7 +91,7 @@ std::unique_ptr Factory::create(const std::string type, { func = builder_.at(type); } - catch (std::out_of_range) + catch (std::out_of_range &) { HADRON_ERROR("object of type '" + type + "' unknown"); } diff --git a/programs/Hadrons/FermionAction.cc b/programs/Hadrons/FermionAction.cc index 0857008b..fdd9530c 100644 --- a/programs/Hadrons/FermionAction.cc +++ b/programs/Hadrons/FermionAction.cc @@ -28,6 +28,7 @@ directory. #include using namespace Grid; +using namespace QCD; using namespace Hadrons; /****************************************************************************** diff --git a/programs/Hadrons/Global.cc b/programs/Hadrons/Global.cc index 18c3028e..6b855cda 100644 --- a/programs/Hadrons/Global.cc +++ b/programs/Hadrons/Global.cc @@ -28,6 +28,7 @@ directory. #include using namespace Grid; +using namespace QCD; using namespace Hadrons; HadronsLogger Hadrons::HadronsLogError(1,"Error"); diff --git a/programs/Hadrons/Global.hpp b/programs/Hadrons/Global.hpp index 39758b7e..f5a5c144 100644 --- a/programs/Hadrons/Global.hpp +++ b/programs/Hadrons/Global.hpp @@ -28,15 +28,20 @@ directory. #ifndef Hadrons_Global_hpp_ #define Hadrons_Global_hpp_ -#include #include #include +#include #define BEGIN_HADRONS_NAMESPACE \ +namespace Grid {\ +using namespace QCD;\ namespace Hadrons {\ -using namespace Grid;\ -using namespace QCD; -#define END_HADRONS_NAMESPACE } +using Grid::operator<<; +#define END_HADRONS_NAMESPACE }} + +/* the 'using Grid::operator<<;' statement prevents a very nasty compilation + * error with GCC (clang compiles fine without it). + */ BEGIN_HADRONS_NAMESPACE diff --git a/programs/Hadrons/Graph.hpp b/programs/Hadrons/Graph.hpp index 8b8afcc6..c7591350 100644 --- a/programs/Hadrons/Graph.hpp +++ b/programs/Hadrons/Graph.hpp @@ -105,8 +105,8 @@ private: void depthFirstSearch(void); void depthFirstSearch(const T &root); private: - std::map isMarked_; - std::set edgeSet_; + std::map isMarked_; + std::set edgeSet_; }; // build depedency matrix from topological sorts diff --git a/programs/Hadrons/Hadrons.cc b/programs/Hadrons/Hadrons.cc index 73ac03f9..da5e02b1 100644 --- a/programs/Hadrons/Hadrons.cc +++ b/programs/Hadrons/Hadrons.cc @@ -27,6 +27,8 @@ directory. #include +using namespace Grid; +using namespace QCD; using namespace Hadrons; int main(int argc, char *argv[]) diff --git a/programs/Hadrons/MQuark.cc b/programs/Hadrons/MQuark.cc index 575914e4..04f9042d 100644 --- a/programs/Hadrons/MQuark.cc +++ b/programs/Hadrons/MQuark.cc @@ -28,6 +28,7 @@ directory. #include using namespace Grid; +using namespace QCD; using namespace Hadrons; /****************************************************************************** diff --git a/programs/Hadrons/MSource.cc b/programs/Hadrons/MSource.cc index f09c0b1d..3897db7c 100644 --- a/programs/Hadrons/MSource.cc +++ b/programs/Hadrons/MSource.cc @@ -28,7 +28,9 @@ directory. #include #define ERROR_SUF " (source '" << getName() << "')" + using namespace Grid; +using namespace QCD; using namespace Hadrons; /****************************************************************************** diff --git a/programs/Hadrons/Module.cc b/programs/Hadrons/Module.cc index 1437046e..a590b81a 100644 --- a/programs/Hadrons/Module.cc +++ b/programs/Hadrons/Module.cc @@ -28,6 +28,7 @@ directory. #include using namespace Grid; +using namespace QCD; using namespace Hadrons; /****************************************************************************** diff --git a/programs/Hadrons/SRBPrecCG.cc b/programs/Hadrons/SRBPrecCG.cc index 22206ed3..ff4a50d5 100644 --- a/programs/Hadrons/SRBPrecCG.cc +++ b/programs/Hadrons/SRBPrecCG.cc @@ -28,6 +28,7 @@ directory. #include using namespace Grid; +using namespace QCD; using namespace Hadrons; /******************************************************************************