From 7de5315dc47685c293b60c4c4e5c58ab7485de56 Mon Sep 17 00:00:00 2001
From: Chuck Atkins <chuck.atkins@kitware.com>
Date: Wed, 5 Apr 2017 11:44:31 -0400
Subject: [PATCH] Add line breaks for template declarations

---
 .clang-format                              |  1 +
 bindings/python/include/EnginePy.h         |  3 +-
 bindings/python/include/adiosPyFunctions.h |  9 ++-
 include/ADIOS.h                            | 21 ++++--
 include/core/Engine.h                      | 24 ++++---
 include/core/Method.h                      |  3 +-
 include/core/Variable.h                    |  3 +-
 include/format/BP1.h                       | 36 +++++++----
 include/functions/adiosTemplates.h         | 75 ++++++++++++++++------
 9 files changed, 124 insertions(+), 51 deletions(-)

diff --git a/.clang-format b/.clang-format
index 455bf99fe..93948cf8b 100644
--- a/.clang-format
+++ b/.clang-format
@@ -5,3 +5,4 @@ ConstructorInitializerIndentWidth:  0
 IndentWidth: 4
 ContinuationIndentWidth: 4
 AccessModifierOffset: -4
+AlwaysBreakTemplateDeclarations:  true
diff --git a/bindings/python/include/EnginePy.h b/bindings/python/include/EnginePy.h
index 437247f5b..29d65cb00 100644
--- a/bindings/python/include/EnginePy.h
+++ b/bindings/python/include/EnginePy.h
@@ -60,7 +60,8 @@ private:
     ADIOSPy &m_ADIOSPy;
     bool m_IsVariableTypeDefined = false;
 
-    template <class T> void DefineVariableInADIOS(VariablePy &variable)
+    template <class T>
+    void DefineVariableInADIOS(VariablePy &variable)
     {
         auto &var = m_ADIOSPy.DefineVariable<T>(
             variable.m_Name, variable.m_LocalDimensions,
diff --git a/bindings/python/include/adiosPyFunctions.h b/bindings/python/include/adiosPyFunctions.h
index 8ef0ff9f6..b47e02d7b 100644
--- a/bindings/python/include/adiosPyFunctions.h
+++ b/bindings/python/include/adiosPyFunctions.h
@@ -64,7 +64,8 @@ std::map<std::string, std::string>
 KwargsToMap(const pybind11::kwargs &dictionary);
 #endif
 
-template <class T> const T *PyArrayToPointer(const pyArray &array)
+template <class T>
+const T *PyArrayToPointer(const pyArray &array)
 {
 #ifdef HAVE_BOOSTPYTHON
     return reinterpret_cast<const T *>(array.get_data());
@@ -75,7 +76,8 @@ template <class T> const T *PyArrayToPointer(const pyArray &array)
 #endif
 }
 
-template <class T> bool IsType(const pyArray &array)
+template <class T>
+bool IsType(const pyArray &array)
 {
 #ifdef HAVE_BOOSTPYTHON
     if (array.get_dtype() == dtype::get_builtin<T>())
@@ -90,7 +92,8 @@ template <class T> bool IsType(const pyArray &array)
     return false;
 }
 
-template <class T, class U> T PyCast(U object)
+template <class T, class U>
+T PyCast(U object)
 {
 #ifdef HAVE_BOOSTPYTHON
     return boost::python::extract<T>(object);
diff --git a/include/ADIOS.h b/include/ADIOS.h
index be624488c..7765737c3 100644
--- a/include/ADIOS.h
+++ b/include/ADIOS.h
@@ -107,7 +107,8 @@ public:
                                     name + " in call to DefineVariable\n");
     }
 
-    template <class T> inline Variable<T> &GetVariable(const std::string &name)
+    template <class T>
+    inline Variable<T> &GetVariable(const std::string &name)
     {
         throw std::invalid_argument("ERROR: type not supported for variable " +
                                     name + " in call to GetVariable\n");
@@ -360,7 +361,8 @@ protected: // no const to allow default empty and copy constructors
                      const std::string &methodName,
                      const std::string &hint) const;
 
-    template <class T> unsigned int GetVariableIndex(const std::string &name)
+    template <class T>
+    unsigned int GetVariableIndex(const std::string &name)
     {
         auto itVariable = m_Variables.find(name);
         CheckVariableName(itVariable, name,
@@ -596,7 +598,8 @@ ADIOS::DefineVariable(const std::string &name, const Dims dimensions,
 }
 
 // Get template specialization
-template <> inline Variable<char> &ADIOS::GetVariable(const std::string &name)
+template <>
+inline Variable<char> &ADIOS::GetVariable(const std::string &name)
 {
     return m_Char.at(GetVariableIndex<char>(name));
 }
@@ -607,7 +610,8 @@ inline Variable<unsigned char> &ADIOS::GetVariable(const std::string &name)
     return m_UChar.at(GetVariableIndex<unsigned char>(name));
 }
 
-template <> inline Variable<short> &ADIOS::GetVariable(const std::string &name)
+template <>
+inline Variable<short> &ADIOS::GetVariable(const std::string &name)
 {
     return m_Short.at(GetVariableIndex<short>(name));
 }
@@ -618,7 +622,8 @@ inline Variable<unsigned short> &ADIOS::GetVariable(const std::string &name)
     return m_UShort.at(GetVariableIndex<unsigned short>(name));
 }
 
-template <> inline Variable<int> &ADIOS::GetVariable(const std::string &name)
+template <>
+inline Variable<int> &ADIOS::GetVariable(const std::string &name)
 {
     return m_Int.at(GetVariableIndex<int>(name));
 }
@@ -654,12 +659,14 @@ ADIOS::GetVariable(const std::string &name)
     return m_ULLInt.at(GetVariableIndex<unsigned long long int>(name));
 }
 
-template <> inline Variable<float> &ADIOS::GetVariable(const std::string &name)
+template <>
+inline Variable<float> &ADIOS::GetVariable(const std::string &name)
 {
     return m_Float.at(GetVariableIndex<float>(name));
 }
 
-template <> inline Variable<double> &ADIOS::GetVariable(const std::string &name)
+template <>
+inline Variable<double> &ADIOS::GetVariable(const std::string &name)
 {
     return m_Double.at(GetVariableIndex<double>(name));
 }
diff --git a/include/core/Engine.h b/include/core/Engine.h
index a206682e8..7b3f3fede 100644
--- a/include/core/Engine.h
+++ b/include/core/Engine.h
@@ -130,7 +130,8 @@ public:
      * @param variable name of variable to the written
      * @param values pointer passed from the application
      */
-    template <class T> void Write(Variable<T> &variable, const T *values)
+    template <class T>
+    void Write(Variable<T> &variable, const T *values)
     {
         Write(variable, values);
     }
@@ -151,7 +152,8 @@ public:
      * @param variable
      * @param values
      */
-    template <class T> void Write(Variable<T> &variable, const T values)
+    template <class T>
+    void Write(Variable<T> &variable, const T values)
     {
         const T val = values;
         Write(variable, &val);
@@ -245,7 +247,8 @@ public:
      * @param values pointer passed from the application, nullptr not allowed,
      * must use Read(variable) instead intentionally
      */
-    template <class T> void Read(Variable<T> &variable, const T *values)
+    template <class T>
+    void Read(Variable<T> &variable, const T *values)
     {
         Read(variable, values);
     }
@@ -266,7 +269,8 @@ public:
      * @param variable
      * @param values
      */
-    template <class T> void Read(Variable<T> &variable, const T &values)
+    template <class T>
+    void Read(Variable<T> &variable, const T &values)
     {
         Read(variable, &values);
     }
@@ -286,7 +290,8 @@ public:
      * Unallocated version, ADIOS will allocate space for incoming data
      * @param variable
      */
-    template <class T> void Read(Variable<T> &variable)
+    template <class T>
+    void Read(Variable<T> &variable)
     {
         Read(variable, nullptr);
     }
@@ -295,7 +300,8 @@ public:
      * Unallocated version, ADIOS will allocate space for incoming data
      * @param variableName
      */
-    template <class T> void Read(const std::string variableName)
+    template <class T>
+    void Read(const std::string variableName)
     {
         Read(variableName, nullptr);
     }
@@ -310,7 +316,8 @@ public:
      * @param variable name of variable to the written
      * @param values pointer passed from the application
      */
-    template <class T> void ScheduleRead(Variable<T> &variable, const T *values)
+    template <class T>
+    void ScheduleRead(Variable<T> &variable, const T *values)
     {
         ScheduleRead(variable, values);
     }
@@ -331,7 +338,8 @@ public:
      * @param variable
      * @param values
      */
-    template <class T> void ScheduleRead(Variable<T> &variable, const T &values)
+    template <class T>
+    void ScheduleRead(Variable<T> &variable, const T &values)
     {
         ScheduleRead(variable, &values);
     }
diff --git a/include/core/Method.h b/include/core/Method.h
index 0576703b6..c1e60c151 100644
--- a/include/core/Method.h
+++ b/include/core/Method.h
@@ -97,7 +97,8 @@ public:
      * @param args list of parameters with format "parameter1=value1", ...,
      * "parameterN=valueN"
      */
-    template <class... Args> void SetParameters(Args... args)
+    template <class... Args>
+    void SetParameters(Args... args)
     {
         std::vector<std::string> parameters = {args...};
         m_Parameters = BuildParametersMap(parameters, m_DebugMode);
diff --git a/include/core/Variable.h b/include/core/Variable.h
index 93acbfc9f..cc932a484 100644
--- a/include/core/Variable.h
+++ b/include/core/Variable.h
@@ -36,7 +36,8 @@ struct TransformData
  * @param Base (parent) class for template derived (child) class CVariable.
  * Required to put CVariable objects in STL containers.
  */
-template <class T> class Variable : public VariableBase
+template <class T>
+class Variable : public VariableBase
 {
 
 public:
diff --git a/include/format/BP1.h b/include/format/BP1.h
index 518325ecd..96b7253aa 100644
--- a/include/format/BP1.h
+++ b/include/format/BP1.h
@@ -236,7 +236,8 @@ protected:
         statistic_finite = 6
     };
 
-    template <class T> struct Stats
+    template <class T>
+    struct Stats
     {
         T Min;
         T Max;
@@ -257,7 +258,8 @@ protected:
      * @param variable input variable
      * @return data type
      */
-    template <class T> inline std::int8_t GetDataType() const noexcept
+    template <class T>
+    inline std::int8_t GetDataType() const noexcept
     {
         return type_unknown;
     }
@@ -269,32 +271,39 @@ protected:
 
 // Moving template BP1Writer::GetDataType template specializations outside of
 // the class
-template <> inline std::int8_t BP1::GetDataType<char>() const noexcept
+template <>
+inline std::int8_t BP1::GetDataType<char>() const noexcept
 {
     return type_byte;
 }
-template <> inline std::int8_t BP1::GetDataType<short>() const noexcept
+template <>
+inline std::int8_t BP1::GetDataType<short>() const noexcept
 {
     return type_short;
 }
-template <> inline std::int8_t BP1::GetDataType<int>() const noexcept
+template <>
+inline std::int8_t BP1::GetDataType<int>() const noexcept
 {
     return type_integer;
 }
-template <> inline std::int8_t BP1::GetDataType<long int>() const noexcept
+template <>
+inline std::int8_t BP1::GetDataType<long int>() const noexcept
 {
     return type_long;
 }
 
-template <> inline std::int8_t BP1::GetDataType<unsigned char>() const noexcept
+template <>
+inline std::int8_t BP1::GetDataType<unsigned char>() const noexcept
 {
     return type_unsigned_byte;
 }
-template <> inline std::int8_t BP1::GetDataType<unsigned short>() const noexcept
+template <>
+inline std::int8_t BP1::GetDataType<unsigned short>() const noexcept
 {
     return type_unsigned_short;
 }
-template <> inline std::int8_t BP1::GetDataType<unsigned int>() const noexcept
+template <>
+inline std::int8_t BP1::GetDataType<unsigned int>() const noexcept
 {
     return type_unsigned_integer;
 }
@@ -304,15 +313,18 @@ inline std::int8_t BP1::GetDataType<unsigned long int>() const noexcept
     return type_unsigned_long;
 }
 
-template <> inline std::int8_t BP1::GetDataType<float>() const noexcept
+template <>
+inline std::int8_t BP1::GetDataType<float>() const noexcept
 {
     return type_real;
 }
-template <> inline std::int8_t BP1::GetDataType<double>() const noexcept
+template <>
+inline std::int8_t BP1::GetDataType<double>() const noexcept
 {
     return type_double;
 }
-template <> inline std::int8_t BP1::GetDataType<long double>() const noexcept
+template <>
+inline std::int8_t BP1::GetDataType<long double>() const noexcept
 {
     return type_long_double;
 }
diff --git a/include/functions/adiosTemplates.h b/include/functions/adiosTemplates.h
index 7266a6b21..a1a7a2441 100644
--- a/include/functions/adiosTemplates.h
+++ b/include/functions/adiosTemplates.h
@@ -27,54 +27,93 @@ namespace adios
  * Get the primitive type in a string from a template
  * @return if T is a char, returns string = "char"
  */
-template <class T> inline std::string GetType() noexcept { return "compound"; }
-template <> inline std::string GetType<void>() noexcept { return "unknown"; }
-template <> inline std::string GetType<char>() noexcept { return "char"; }
-template <> inline std::string GetType<unsigned char>() noexcept
+template <class T>
+inline std::string GetType() noexcept
+{
+    return "compound";
+}
+template <>
+inline std::string GetType<void>() noexcept
+{
+    return "unknown";
+}
+template <>
+inline std::string GetType<char>() noexcept
+{
+    return "char";
+}
+template <>
+inline std::string GetType<unsigned char>() noexcept
 {
     return "unsigned char";
 }
-template <> inline std::string GetType<short>() noexcept { return "short"; }
-template <> inline std::string GetType<unsigned short>() noexcept
+template <>
+inline std::string GetType<short>() noexcept
+{
+    return "short";
+}
+template <>
+inline std::string GetType<unsigned short>() noexcept
 {
     return "unsigned short";
 }
-template <> inline std::string GetType<int>() noexcept { return "int"; }
-template <> inline std::string GetType<unsigned int>() noexcept
+template <>
+inline std::string GetType<int>() noexcept
+{
+    return "int";
+}
+template <>
+inline std::string GetType<unsigned int>() noexcept
 {
     return "unsigned int";
 }
-template <> inline std::string GetType<long int>() noexcept
+template <>
+inline std::string GetType<long int>() noexcept
 {
     return "long int";
 }
-template <> inline std::string GetType<unsigned long int>() noexcept
+template <>
+inline std::string GetType<unsigned long int>() noexcept
 {
     return "unsigned long int";
 }
-template <> inline std::string GetType<long long int>() noexcept
+template <>
+inline std::string GetType<long long int>() noexcept
 {
     return "long long int";
 }
-template <> inline std::string GetType<unsigned long long int>() noexcept
+template <>
+inline std::string GetType<unsigned long long int>() noexcept
 {
     return "unsigned long long int";
 }
-template <> inline std::string GetType<float>() noexcept { return "float"; }
-template <> inline std::string GetType<double>() noexcept { return "double"; }
-template <> inline std::string GetType<long double>() noexcept
+template <>
+inline std::string GetType<float>() noexcept
+{
+    return "float";
+}
+template <>
+inline std::string GetType<double>() noexcept
+{
+    return "double";
+}
+template <>
+inline std::string GetType<long double>() noexcept
 {
     return "long double";
 }
-template <> inline std::string GetType<std::complex<float>>() noexcept
+template <>
+inline std::string GetType<std::complex<float>>() noexcept
 {
     return "float complex";
 }
-template <> inline std::string GetType<std::complex<double>>() noexcept
+template <>
+inline std::string GetType<std::complex<double>>() noexcept
 {
     return "double complex";
 }
-template <> inline std::string GetType<std::complex<long double>>() noexcept
+template <>
+inline std::string GetType<std::complex<long double>>() noexcept
 {
     return "long double complex";
 }
-- 
GitLab