diff --git a/.clang-format b/.clang-format index 2deb5e108feb830af49c08e964242a38d87a0151..0dada7918f1705ce1b4c801399d5a6dd2a8911a0 100644 --- a/.clang-format +++ b/.clang-format @@ -2,7 +2,7 @@ BasedOnStyle: LLVM AccessModifierOffset: -4 AllowShortFunctionsOnASingleLine: Inline AllowShortIfStatementsOnASingleLine: false -AlwaysBreakTemplateDeclarations: Yes +AlwaysBreakTemplateDeclarations: No BreakBeforeBinaryOperators: NonAssignment BreakBeforeBraces: WebKit BreakConstructorInitializers : BeforeComma diff --git a/Base/Math/IntegratorMCMiser.h b/Base/Math/IntegratorMCMiser.h index cbe27644291163685cc7a44adea0af99a0d6f0db..274cb2bafb871bcc947b3fbfaf6fdbac8fa9b2d5 100644 --- a/Base/Math/IntegratorMCMiser.h +++ b/Base/Math/IntegratorMCMiser.h @@ -22,8 +22,7 @@ #include <memory> //! Alias template for member function with signature double f(double) -template <class T> -using miser_integrand = double (T::*)(const double*, size_t, const void*) const; +template <class T> using miser_integrand = double (T::*)(const double*, size_t, const void*) const; //! Template class to use Monte Carlo MISER integration of class member functions. //! @@ -34,8 +33,7 @@ using miser_integrand = double (T::*)(const double*, size_t, const void*) const; //! 'auto integrator = make_integrator_miser(this, mem_function, dimension)' //! - Call: 'integrator.integrate(lmin, lmax, data, n_points)' -template <class T> -class IntegratorMCMiser { +template <class T> class IntegratorMCMiser { public: //! structure holding the object and possible extra parameters struct CallBackHolder { @@ -69,14 +67,12 @@ private: }; //! Alias template for handle to a miser integrator -template <class T> -using P_integrator_miser = std::unique_ptr<IntegratorMCMiser<T>>; +template <class T> using P_integrator_miser = std::unique_ptr<IntegratorMCMiser<T>>; //! Template function to create an integrator object -template <class T> -P_integrator_miser<T> make_integrator_miser(const T* object, miser_integrand<T> mem_function, - size_t dim) +template <class T> P_integrator_miser<T> +make_integrator_miser(const T* object, miser_integrand<T> mem_function, size_t dim) { P_integrator_miser<T> P_integrator(new IntegratorMCMiser<T>(object, mem_function, dim)); return P_integrator; @@ -102,16 +98,14 @@ IntegratorMCMiser<T>::IntegratorMCMiser(const T* p_object, miser_integrand<T> p_ m_random_gen = gsl_rng_alloc(random_type); } -template <class T> -IntegratorMCMiser<T>::~IntegratorMCMiser() +template <class T> IntegratorMCMiser<T>::~IntegratorMCMiser() { gsl_monte_miser_free(m_gsl_workspace); gsl_rng_free(m_random_gen); } -template <class T> -double IntegratorMCMiser<T>::integrate(double* min_array, double* max_array, const void* params, - size_t n_points) const +template <class T> double IntegratorMCMiser<T>::integrate(double* min_array, double* max_array, + const void* params, size_t n_points) const { CallBackHolder cb = {m_object, m_member_function, params}; diff --git a/Base/Types/CloneableVector.h b/Base/Types/CloneableVector.h index 1167740d7c1b5bc779819253d03b7a78c0f7c747..a4373b75669b5c852516bd871ce1ee4665bfb75f 100644 --- a/Base/Types/CloneableVector.h +++ b/Base/Types/CloneableVector.h @@ -28,8 +28,7 @@ //! If the copy constructor or the copy assignment operator is used, //! then there must be a function T::clone(). -template <class T> -class CloneableVector : public OwningVector<T> { +template <class T> class CloneableVector : public OwningVector<T> { public: CloneableVector() = default; //! Constructor that takes over ownership of elements in given vector diff --git a/Base/Types/OwningVector.h b/Base/Types/OwningVector.h index ca8e04b40c2614adde7fa2389e2e2d38c6b470fc..b941e2c496553a2b4c42ca0889d72c721eafde81 100644 --- a/Base/Types/OwningVector.h +++ b/Base/Types/OwningVector.h @@ -27,8 +27,7 @@ //! //! Cannot be copied. For a copyable vector of cloneable objects, use CloneableVector. -template <class T> -class OwningVector { +template <class T> class OwningVector { public: OwningVector() = default; //! Constructor that takes over ownership of elements in given vector diff --git a/Base/Util/IFactory.h b/Base/Util/IFactory.h index 8000cc0811ec4fd6b7e70d3561847a240fdbe411..bf1fa732a630c6580fbfe70e88cd3a2263f4d7f1 100644 --- a/Base/Util/IFactory.h +++ b/Base/Util/IFactory.h @@ -24,8 +24,7 @@ //! Base class for all factories. -template <class Key, class AbstractProduct> -class IFactory { +template <class Key, class AbstractProduct> class IFactory { public: //! function which will be used to create object of AbstractProduct base type using CreateItemCallback = std::function<AbstractProduct*()>; diff --git a/Fit/Adapter/MinimizerAdapter.h b/Fit/Adapter/MinimizerAdapter.h index e0e10da2dd844eae7ef1fb42ac3684d3eb26d973..5f66651744897eb718893c83ed45834d046f4fe5 100644 --- a/Fit/Adapter/MinimizerAdapter.h +++ b/Fit/Adapter/MinimizerAdapter.h @@ -89,15 +89,12 @@ protected: virtual const root_minimizer_t* rootMinimizer() const = 0; root_minimizer_t* rootMinimizer(); - template <class T> - OptionContainer::option_t addOption(const std::string& optionName, T value, - const std::string& description = ""); + template <class T> OptionContainer::option_t addOption(const std::string& optionName, T value, + const std::string& description = ""); - template <class T> - void setOptionValue(const std::string& optionName, T value); + template <class T> void setOptionValue(const std::string& optionName, T value); - template <class T> - T optionValue(const std::string& optionName) const; + template <class T> T optionValue(const std::string& optionName) const; private: MinimizerOptions m_options; @@ -106,21 +103,18 @@ private: bool m_status; }; -template <class T> -OptionContainer::option_t MinimizerAdapter::addOption(const std::string& optionName, T value, - const std::string& description) +template <class T> OptionContainer::option_t +MinimizerAdapter::addOption(const std::string& optionName, T value, const std::string& description) { return m_options.addOption(optionName, value, description); } -template <class T> -void MinimizerAdapter::setOptionValue(const std::string& optionName, T value) +template <class T> void MinimizerAdapter::setOptionValue(const std::string& optionName, T value) { m_options.setOptionValue(optionName, value); } -template <class T> -T MinimizerAdapter::optionValue(const std::string& optionName) const +template <class T> T MinimizerAdapter::optionValue(const std::string& optionName) const { return m_options.optionValue<T>(optionName); } diff --git a/Fit/Adapter/Report.cpp b/Fit/Adapter/Report.cpp index b6864dfca88f162234a832d3dca5c9243842cff7..f6aea61d6c7db2fc9f2af8605613de306dbb2847 100644 --- a/Fit/Adapter/Report.cpp +++ b/Fit/Adapter/Report.cpp @@ -22,8 +22,7 @@ namespace { const int column_width = 18; -template <typename T> -std::string reportValue(const std::string& name, T value) +template <typename T> std::string reportValue(const std::string& name, T value) { std::ostringstream result; result << std::setw(column_width) << std::left << name << ": " << value << std::endl; diff --git a/Fit/Option/MultiOption.h b/Fit/Option/MultiOption.h index 34c91cd30136135cc517da8430159b2ba262aef1..76919d0599ce6cfb6a1f38ddde6342b82b184b84 100644 --- a/Fit/Option/MultiOption.h +++ b/Fit/Option/MultiOption.h @@ -41,12 +41,10 @@ public: variant_t& defaultValue(); //! Returns the option's value - template <typename T> - T get() const; + template <typename T> T get() const; //! Returns the option's default value (i.e. used during construction) - template <typename T> - T getDefault() const; + template <typename T> T getDefault() const; //! Returns a string representation of the option's value std::string value_str(); @@ -69,14 +67,12 @@ MultiOption::MultiOption(const std::string& name, const T& t, const std::string& m_default_value = t; } -template <typename T> -T MultiOption::get() const +template <typename T> T MultiOption::get() const { return std::get<T>(m_value); } -template <typename T> -T MultiOption::getDefault() const +template <typename T> T MultiOption::getDefault() const { return std::get<T>(m_default_value); } diff --git a/Fit/Option/OptionContainer.h b/Fit/Option/OptionContainer.h index 6ed264fe10d53ace05cfff2778bed60805329708..e9c687c65c63a46d932bbcc190346e9eb9a87f2d 100644 --- a/Fit/Option/OptionContainer.h +++ b/Fit/Option/OptionContainer.h @@ -43,12 +43,10 @@ public: option_t option(const std::string& optionName); option_t option(const std::string& optionName) const; - template <class T> - T optionValue(const std::string& optionName) const; + template <class T> T optionValue(const std::string& optionName) const; //! Sets the value of option. Option should hold same value type already. - template <class T> - void setOptionValue(const std::string& optionName, T value); + template <class T> void setOptionValue(const std::string& optionName, T value); iterator begin() { return m_options.begin(); } const_iterator begin() const { return m_options.begin(); } @@ -65,9 +63,8 @@ protected: container_t m_options; }; -template <class T> -OptionContainer::option_t OptionContainer::addOption(const std::string& optionName, T value, - const std::string& description) +template <class T> OptionContainer::option_t +OptionContainer::addOption(const std::string& optionName, T value, const std::string& description) { if (exists(optionName)) throw std::runtime_error("OptionContainer::addOption -> Error. Option '" + optionName @@ -78,14 +75,12 @@ OptionContainer::option_t OptionContainer::addOption(const std::string& optionNa return result; } -template <class T> -T OptionContainer::optionValue(const std::string& optionName) const +template <class T> T OptionContainer::optionValue(const std::string& optionName) const { return option(optionName)->get<T>(); } -template <class T> -void OptionContainer::setOptionValue(const std::string& optionName, T value) +template <class T> void OptionContainer::setOptionValue(const std::string& optionName, T value) { option(optionName)->value() = value; if (option(optionName)->value().index() != option(optionName)->defaultValue().index()) diff --git a/Fit/Tools/StringUtil.h b/Fit/Tools/StringUtil.h index 6587e7b26640139c4a3967e2f2ccd8e3569e1c47..ea12acaa4ad88cb25e8ac9f24bcc8a502a1c4623 100644 --- a/Fit/Tools/StringUtil.h +++ b/Fit/Tools/StringUtil.h @@ -31,11 +31,9 @@ namespace mumufit::stringUtil { std::vector<std::string> split(const std::string& text, const std::string& delimiter); //! Returns scientific string representing given value of any numeric type. -template <typename T> -std::string scientific(T value, int n = 10); +template <typename T> std::string scientific(T value, int n = 10); -template <typename T> -std::string scientific(const T value, int n) +template <typename T> std::string scientific(const T value, int n) { std::ostringstream out; out << std::scientific << std::setprecision(n) << value; diff --git a/GUI/Model/Beam/BeamDistributionItem.h b/GUI/Model/Beam/BeamDistributionItem.h index fb11a199700353ffab22d5f0fc0956f2f34c1405..ebb458d6dd961e468b96759d4d0f50d658dc1314 100644 --- a/GUI/Model/Beam/BeamDistributionItem.h +++ b/GUI/Model/Beam/BeamDistributionItem.h @@ -36,8 +36,7 @@ public: virtual double scaleFactor() const; - template <typename T> - T* setDistributionItemType(); + template <typename T> T* setDistributionItemType(); DistributionItem* distributionItem() const { return m_distribution.currentItem(); } SelectionProperty<DistributionItemCatalog>& distributionSelection() { return m_distribution; } @@ -47,8 +46,7 @@ protected: SelectionProperty<DistributionItemCatalog> m_distribution; }; -template <typename T> -T* BeamDistributionItem::setDistributionItemType() +template <typename T> T* BeamDistributionItem::setDistributionItemType() { m_distribution.setCurrentItem<T>(); return dynamic_cast<T*>(m_distribution.currentItem()); diff --git a/GUI/Model/Descriptor/DistributionItems.h b/GUI/Model/Descriptor/DistributionItems.h index 256ceed27274a4c2d830f181310b749dc677fc1d..e259dceb9b1d926090c14c2e7cb3a2b61c15f409 100644 --- a/GUI/Model/Descriptor/DistributionItems.h +++ b/GUI/Model/Descriptor/DistributionItems.h @@ -26,11 +26,7 @@ public: virtual ~DistributionItem() = default; DistributionItem(); - template <typename T> - bool is() const - { - return dynamic_cast<const T*>(this) != nullptr; - } + template <typename T> bool is() const { return dynamic_cast<const T*>(this) != nullptr; } virtual std::unique_ptr<IDistribution1D> createDistribution(double scale = 1.0) const = 0; diff --git a/GUI/Model/Descriptor/SelectionProperty.h b/GUI/Model/Descriptor/SelectionProperty.h index da1024a128728c794c2b372b96451683f579ad29..7e3839e6cd6d8d744164628b0ac9b1f59431deea 100644 --- a/GUI/Model/Descriptor/SelectionProperty.h +++ b/GUI/Model/Descriptor/SelectionProperty.h @@ -50,8 +50,7 @@ public: //! //! The initialization of a SelectionProperty is done using a catalog. //! -template <typename Catalog> -class SelectionProperty : public ISelectionProperty { +template <typename Catalog> class SelectionProperty : public ISelectionProperty { public: using CatalogedType = typename Catalog::CatalogedType; @@ -60,9 +59,9 @@ public: //! The current selection will be initialized with the first type in the catalog types. The //! optional arguments are the arguments which may be necessary for the creation method in the //! catalog. - template <typename... ArgsForCreation> - void init(const QString& label, const QString& tooltip, typename Catalog::Type currentType, - ArgsForCreation... argsForCreation) + template <typename... ArgsForCreation> void init(const QString& label, const QString& tooltip, + typename Catalog::Type currentType, + ArgsForCreation... argsForCreation) { initFieldsAndSetter(label, tooltip, argsForCreation...); int index = Catalog::types().indexOf(currentType); @@ -221,8 +220,7 @@ private: //! SelectionProperty but with the set of them, for example 'InstrumentModel', 'CompoundItem', //! 'ParticleLayoutItems', 'MaskItems' -template <typename Catalog> -class SelectionVector { +template <typename Catalog> class SelectionVector { public: using CatalogedType = typename Catalog::CatalogedType; diff --git a/GUI/Model/Detector/DetectorItem.h b/GUI/Model/Detector/DetectorItem.h index 71c282cb635f7e265bdf95bcc909312b3d73fda3..a0672863cbdd648fb296a54df01e306bd5bca057 100644 --- a/GUI/Model/Detector/DetectorItem.h +++ b/GUI/Model/Detector/DetectorItem.h @@ -37,8 +37,7 @@ public: SelectionProperty<ResolutionFunctionItemCatalog>& resolutionFunctionSelection(); - template <typename T> - T* setResolutionFunctionType(); + template <typename T> T* setResolutionFunctionType(); void writeTo(QXmlStreamWriter* w) const; void readFrom(QXmlStreamReader* r); @@ -62,8 +61,7 @@ private: AxisProperty m_alphaAxis; }; -template <typename T> -T* DetectorItem::setResolutionFunctionType() +template <typename T> T* DetectorItem::setResolutionFunctionType() { m_resolutionFunction.setCurrentItem<T>(); return dynamic_cast<T*>(m_resolutionFunction.currentItem()); diff --git a/GUI/Model/Device/InstrumentItems.h b/GUI/Model/Device/InstrumentItems.h index e3bb28c522997990a667c3e513f2cee1439552bf..b47aca0ee20fa09c6180733220c4b3ce4142fa75 100644 --- a/GUI/Model/Device/InstrumentItems.h +++ b/GUI/Model/Device/InstrumentItems.h @@ -66,17 +66,12 @@ public: QString instrumentName() const { return m_name; } void setInstrumentName(const QString& instrumentName) { m_name = instrumentName; } - template <typename T> - bool is() const - { - return dynamic_cast<const T*>(this) != nullptr; - } + template <typename T> bool is() const { return dynamic_cast<const T*>(this) != nullptr; } QString description() const { return m_description; } void setDescription(const QString& description) { m_description = description; } - template <typename T> - T* setBackgroundItemType(); + template <typename T> T* setBackgroundItemType(); SelectionProperty<BackgroundItemCatalog>& backgroundSelection() { return m_background; } BackgroundItem* backgroundItem() const { return m_background.currentItem(); } @@ -211,8 +206,7 @@ private: // templated functions implementation // ************************************************************************************************ -template <typename T> -T* InstrumentItem::setBackgroundItemType() +template <typename T> T* InstrumentItem::setBackgroundItemType() { m_background.setCurrentItem<T>(); return dynamic_cast<T*>(m_background.currentItem()); diff --git a/GUI/Model/Device/InstrumentModel.h b/GUI/Model/Device/InstrumentModel.h index bf4029c8894610f54e398be187fa95979521481b..f3f8524c51f53b5f3751c4de32827a378663b49e 100644 --- a/GUI/Model/Device/InstrumentModel.h +++ b/GUI/Model/Device/InstrumentModel.h @@ -29,8 +29,7 @@ class InstrumentModel { public: ~InstrumentModel(); - template <typename T> - T* addInstrumentItem() + template <typename T> T* addInstrumentItem() { auto* t = new T(); emplace_back(t); diff --git a/GUI/Model/Device/MultiInstrumentNotifier.h b/GUI/Model/Device/MultiInstrumentNotifier.h index 03281db47575d93cf0c07f2430901f77ffdb475b..bea47301be93406a9e4bb3885dcf5eb308bdb03e 100644 --- a/GUI/Model/Device/MultiInstrumentNotifier.h +++ b/GUI/Model/Device/MultiInstrumentNotifier.h @@ -46,8 +46,7 @@ public: InstrumentModel* instrumentModel(); //! Add an instrument and emit the respective signal. - template <typename T> - T* addInstrumentItem(); + template <typename T> T* addInstrumentItem(); //! Add an instrument and emit the respective signal. void removeInstrument(InstrumentItem* instrument); @@ -85,8 +84,7 @@ private: //!< borrowed, not owned. }; -template <typename T> -T* MultiInstrumentNotifier::addInstrumentItem() +template <typename T> T* MultiInstrumentNotifier::addInstrumentItem() { auto* t = m_instruments->addInstrumentItem<T>(); emit instrumentAddedOrRemoved(); diff --git a/GUI/Model/FromCore/ItemizeSample.cpp b/GUI/Model/FromCore/ItemizeSample.cpp index 5a7cd000b80653833fde99e44a8194ab418fe016..8941bb96e120ea2f2cfa81b36b6bff506d25abd5 100644 --- a/GUI/Model/FromCore/ItemizeSample.cpp +++ b/GUI/Model/FromCore/ItemizeSample.cpp @@ -72,8 +72,7 @@ void set_PDF1D(InterferenceRadialParacrystalItem* parent, const IProfile1D* ipdf // note: SetterPDF(1|2)Type are needed because template template parameter must be classes -template <class T> -struct SetterPDF1Type { +template <class T> struct SetterPDF1Type { T* operator()(Interference2DParacrystalItem* parent) { auto* p = new T(); @@ -82,8 +81,7 @@ struct SetterPDF1Type { } }; -template <class T> -struct SetterPDF2Type { +template <class T> struct SetterPDF2Type { T* operator()(Interference2DParacrystalItem* parent) { auto* p = new T(); @@ -201,8 +199,7 @@ void set_PositionVariance(InterferenceItem* parent, const IInterference& iff) parent->setPositionVariance(pos_var); } -template <typename T> -T* addFormFactorItem(std::variant<ParticleItem*, MesocrystalItem*> parent) +template <typename T> T* addFormFactorItem(std::variant<ParticleItem*, MesocrystalItem*> parent) { if (std::holds_alternative<ParticleItem*>(parent)) return std::get<ParticleItem*>(parent)->setFormFactorItemType<T>(); diff --git a/GUI/Model/Job/ParameterTreeBuilder.cpp b/GUI/Model/Job/ParameterTreeBuilder.cpp index 6d06e4abc36978c4254d143cdd01c5ae9bc6b695..dc5601ecda0a733500ac1df6050778c7516814d9 100644 --- a/GUI/Model/Job/ParameterTreeBuilder.cpp +++ b/GUI/Model/Job/ParameterTreeBuilder.cpp @@ -37,9 +37,9 @@ using std::variant; namespace { -template <typename Catalog> -ParameterLabelItem* addLabel(ParameterLabelItem* parent, const QString& category, - const typename Catalog::CatalogedType* p) +template <typename Catalog> ParameterLabelItem* addLabel(ParameterLabelItem* parent, + const QString& category, + const typename Catalog::CatalogedType* p) { const auto title = category + " (" + Catalog::uiInfo(Catalog::type(p)).menuEntry + ")"; return new ParameterLabelItem(title, parent); diff --git a/GUI/Model/Mask/ProjectionItems.h b/GUI/Model/Mask/ProjectionItems.h index f75f79235a1c0e2cff37ce56d9d5e69402160900..8db0c56ced886c645055564569d7c627855ef6cc 100644 --- a/GUI/Model/Mask/ProjectionItems.h +++ b/GUI/Model/Mask/ProjectionItems.h @@ -27,8 +27,7 @@ public: QVector<MaskItem*> projectionsOfType(Qt::Orientation projectionType); private: - template <typename LineType> - QVector<MaskItem*> projections() + template <typename LineType> QVector<MaskItem*> projections() { QVector<MaskItem*> result; for (const auto& proj : m_maskItems) diff --git a/GUI/Model/Sample/MesocrystalItem.h b/GUI/Model/Sample/MesocrystalItem.h index 4e53faff43fabf70823eb14853dee128776c3aa7..6c61ff59f6ce7c9eb4418dd5a3315420742b2979 100644 --- a/GUI/Model/Sample/MesocrystalItem.h +++ b/GUI/Model/Sample/MesocrystalItem.h @@ -42,8 +42,7 @@ public: std::unique_ptr<IParticle> getBasis() const; std::unique_ptr<IFormFactor> getOuterShape() const; - template <typename T> - T* setOuterShapeType(); + template <typename T> T* setOuterShapeType(); SelectionProperty<FormFactorItemCatalog>& outerShapeSelection() { return m_outerShape; } void setOuterShape(FormFactorItem* p) { m_outerShape.setCurrentItem(p); } @@ -76,8 +75,7 @@ private: const MaterialModel* m_materialModel; }; -template <typename T> -T* MesocrystalItem::setOuterShapeType() +template <typename T> T* MesocrystalItem::setOuterShapeType() { auto* p = new T(); setOuterShape(p); diff --git a/GUI/Model/Sample/ParticleItem.h b/GUI/Model/Sample/ParticleItem.h index 3d6d9885821cefaa4f1d3e7558044c6e68bd0688..68d6fa76fd29d12a72368e6c91ee5e6c0212107a 100644 --- a/GUI/Model/Sample/ParticleItem.h +++ b/GUI/Model/Sample/ParticleItem.h @@ -33,8 +33,7 @@ public: std::unique_ptr<Particle> createParticle() const; - template <typename T> - T* setFormFactorItemType(); + template <typename T> T* setFormFactorItemType(); void setFormFactor(FormFactorItem* p); FormFactorItem* formFactorItem() const; QVector<ItemWithParticles*> containedItemsWithParticles() const override; @@ -45,8 +44,7 @@ private: SelectionProperty<FormFactorItemCatalog> m_formFactor; }; -template <typename T> -T* ParticleItem::setFormFactorItemType() +template <typename T> T* ParticleItem::setFormFactorItemType() { T* p = new T(); setFormFactor(p); diff --git a/GUI/Support/XML/Backup.h b/GUI/Support/XML/Backup.h index 5d36b4d76cbe531ce194ea0ced712b7d9f77a644..2845ec7660a6ea9ae6b5663264daf2d00abaa9d7 100644 --- a/GUI/Support/XML/Backup.h +++ b/GUI/Support/XML/Backup.h @@ -28,8 +28,7 @@ const QString Backup("Backup"); namespace GUI::Util { -template <typename T> -QByteArray createBackup(const T* t) +template <typename T> QByteArray createBackup(const T* t) { QByteArray backup; QXmlStreamWriter w(&backup); @@ -39,8 +38,7 @@ QByteArray createBackup(const T* t) return backup; } -template <typename T> -void restoreBackup(T* t, const QByteArray& backup) +template <typename T> void restoreBackup(T* t, const QByteArray& backup) { QXmlStreamReader r(backup); r.readNextStartElement(); @@ -48,8 +46,7 @@ void restoreBackup(T* t, const QByteArray& backup) t->readFrom(&r); } -template <typename T> -void copyContents(const T* source, T* dest) +template <typename T> void copyContents(const T* source, T* dest) { GUI::Util::restoreBackup(dest, GUI::Util::createBackup(source)); } diff --git a/GUI/View/Instrument/InstrumentListModel.cpp b/GUI/View/Instrument/InstrumentListModel.cpp index 9ab64cb8a6f9fccd28eace64552f355e80d33984..45c3058cc386553397941ac9f52a06d705aad1f5 100644 --- a/GUI/View/Instrument/InstrumentListModel.cpp +++ b/GUI/View/Instrument/InstrumentListModel.cpp @@ -20,32 +20,27 @@ namespace { /// Get the default name for an instrument (i.e. the name a newly created instrument should get) -template <typename T> -QString defaultInstrumentName() +template <typename T> QString defaultInstrumentName() { return "Untitled"; } -template <> -QString defaultInstrumentName<SpecularInstrumentItem>() +template <> QString defaultInstrumentName<SpecularInstrumentItem>() { return "Specular"; } -template <> -QString defaultInstrumentName<DepthprobeInstrumentItem>() +template <> QString defaultInstrumentName<DepthprobeInstrumentItem>() { return "Depthprobe"; } -template <> -QString defaultInstrumentName<GISASInstrumentItem>() +template <> QString defaultInstrumentName<GISASInstrumentItem>() { return "GISAS"; } -template <> -QString defaultInstrumentName<OffspecInstrumentItem>() +template <> QString defaultInstrumentName<OffspecInstrumentItem>() { return "Offspec"; } @@ -160,8 +155,7 @@ QModelIndex InstrumentListModel::copyInstrument(const InstrumentItem* source) return createIndex(row, 0); } -template <class Instrument> -QModelIndex InstrumentListModel::addNewInstrument() +template <class Instrument> QModelIndex InstrumentListModel::addNewInstrument() { const QString name = m_notifier->instrumentModel()->suggestInstrumentName(defaultInstrumentName<Instrument>()); diff --git a/GUI/View/Instrument/InstrumentListModel.h b/GUI/View/Instrument/InstrumentListModel.h index 61a1395005a5b795829adef3af669da4c7cc9bc2..8e13984d7ac2f14df14df7ebdaecc81784226939 100644 --- a/GUI/View/Instrument/InstrumentListModel.h +++ b/GUI/View/Instrument/InstrumentListModel.h @@ -46,8 +46,7 @@ public: QModelIndex copyInstrument(const InstrumentItem* source); private: - template <class Instrument> - QModelIndex addNewInstrument(); + template <class Instrument> QModelIndex addNewInstrument(); void onInstrumentNameChanged(const InstrumentItem* instrument); MultiInstrumentNotifier* m_notifier; diff --git a/GUI/View/Numeric/ComboUtil.h b/GUI/View/Numeric/ComboUtil.h index ff22305d6a9c1146edd87ffdda2324b0f3dad5f9..beb9d414beb7914e78d419c52eac133a18bdd8e2 100644 --- a/GUI/View/Numeric/ComboUtil.h +++ b/GUI/View/Numeric/ComboUtil.h @@ -50,9 +50,9 @@ QComboBox* createStringComboBox(const QStringList& list, std::function<QString() //! //! Changes in the combobox will be notified to the SelectionProperty already. The additional (and //! optional) slot can be used to be notified about an already executed change. -template <typename T> -QComboBox* createComboBoxFromProperty(SelectionProperty<T>& d, std::function<void(int)> slot, - bool inScrollArea) +template <typename T> QComboBox* createComboBoxFromProperty(SelectionProperty<T>& d, + std::function<void(int)> slot, + bool inScrollArea) { QComboBox* combo = new QComboBox; combo->addItems(d.options()); diff --git a/GUI/View/Sample/HeinzFormLayout.h b/GUI/View/Sample/HeinzFormLayout.h index cc7f95a32aef412c583943dc8e7f072143478bec..9e8be2e217f74657194052c077ee3cd367a4e759 100644 --- a/GUI/View/Sample/HeinzFormLayout.h +++ b/GUI/View/Sample/HeinzFormLayout.h @@ -57,8 +57,7 @@ public: //! sufficient. It has to be done "manually". //! For more details, see SelectionContainerForm. //! Returns the newly added row. - template <typename T> - void addSelection(SelectionProperty<T>& d) + template <typename T> void addSelection(SelectionProperty<T>& d) { addBoldRow(d.label(), new SelectionContainerForm(QFormLayout::parentWidget(), d, m_ec)); } @@ -121,8 +120,7 @@ public: void addStructureEditingRow(QPushButton* button); //! Find a widget in the given position. - template <typename T> - T widgetAt(int row, QFormLayout::ItemRole role) + template <typename T> T widgetAt(int row, QFormLayout::ItemRole role) { return qobject_cast<T>(QFormLayout::itemAt(row, role)->widget()); } diff --git a/GUI/View/Sample/SelectionContainerForm.h b/GUI/View/Sample/SelectionContainerForm.h index 09a8c89afad2e4fa0b48d0ac506043a81572d372..a82dfd3d6ac22f1aab220a6649bee82a12429723 100644 --- a/GUI/View/Sample/SelectionContainerForm.h +++ b/GUI/View/Sample/SelectionContainerForm.h @@ -34,8 +34,7 @@ public: protected: ISelectionContainerForm(QWidget* parent, SampleEditorController* ec); - template <typename T> - void initUI(SelectionProperty<T>& d) + template <typename T> void initUI(SelectionProperty<T>& d) { m_gridLayout = new QGridLayout(this); m_gridLayout->setContentsMargins(0, 0, 0, 0); diff --git a/Param/Node/INode.h b/Param/Node/INode.h index aa050bf096657bd97adf427b6fea6816c6399752..8db6fbca734c09d247d5d13678d2d3a9e12f7c44 100644 --- a/Param/Node/INode.h +++ b/Param/Node/INode.h @@ -83,18 +83,16 @@ protected: #ifndef SWIG -template <class T> -std::vector<const INode*>& operator<<(std::vector<const INode*>& v_node, - const std::unique_ptr<T>& node) +template <class T> std::vector<const INode*>& operator<<(std::vector<const INode*>& v_node, + const std::unique_ptr<T>& node) { if (node) v_node.push_back(node.get()); return v_node; } -template <class T> -std::vector<const INode*>& operator<<(std::vector<const INode*>&& v_node, - const std::unique_ptr<T>& node) +template <class T> std::vector<const INode*>& operator<<(std::vector<const INode*>&& v_node, + const std::unique_ptr<T>& node) { if (node) v_node.push_back(node.get()); diff --git a/Param/Node/NodeUtil.h b/Param/Node/NodeUtil.h index 4ec1f31782e5a293dc325ff5ee3fd6ea2d351646..8f95fdb6145c5beda465206e25f8a3fab93b4dc4 100644 --- a/Param/Node/NodeUtil.h +++ b/Param/Node/NodeUtil.h @@ -25,8 +25,7 @@ namespace NodeUtil { -template <typename T> -std::vector<const T*> ChildNodesOfType(const INode& node) +template <typename T> std::vector<const T*> ChildNodesOfType(const INode& node) { std::vector<const T*> result; for (const auto& p_child : node.nodeChildren()) { @@ -36,8 +35,7 @@ std::vector<const T*> ChildNodesOfType(const INode& node) return result; } -template <typename T> -const T* OnlyChildOfType(const INode& node) +template <typename T> const T* OnlyChildOfType(const INode& node) { const auto list = ChildNodesOfType<T>(node); if (list.size() != 1) @@ -45,8 +43,7 @@ const T* OnlyChildOfType(const INode& node) return list.front(); } -template <typename T> -std::vector<const T*> AllDescendantsOfType(const INode& node) +template <typename T> std::vector<const T*> AllDescendantsOfType(const INode& node) { std::vector<const T*> result; for (const auto* child : node.nodeChildren()) { diff --git a/PyCore/Embed/PyInterpreter.cpp b/PyCore/Embed/PyInterpreter.cpp index 44ccfac0bd9b974fa5ce95913e99e85c5a1714cf..d56c36bb687debd039459879f5d683982efd9225 100644 --- a/PyCore/Embed/PyInterpreter.cpp +++ b/PyCore/Embed/PyInterpreter.cpp @@ -102,9 +102,9 @@ std::vector<std::string> toVectorString(PyObject* py_object) // auxiliary function to convert a Numpy array data of real type `real_t` // to vector<double>. -template <typename real_t> -inline void _realArray2DToDouble(PyArrayObject* const npArray_ptr, npy_intp rowIdxMax, - npy_intp colIdxMax, std::vector<double>& vector_out) +template <typename real_t> inline void _realArray2DToDouble(PyArrayObject* const npArray_ptr, + npy_intp rowIdxMax, npy_intp colIdxMax, + std::vector<double>& vector_out) { std::size_t idx = 0; for (npy_intp i_row = 0; i_row < rowIdxMax; ++i_row) { diff --git a/Resample/Interparticle/IInterparticleStrategy.h b/Resample/Interparticle/IInterparticleStrategy.h index b959663627d2b34dc58b691f75e2c082bd511877..5f66591d46dcf571d77d827964828c8f95c7160b 100644 --- a/Resample/Interparticle/IInterparticleStrategy.h +++ b/Resample/Interparticle/IInterparticleStrategy.h @@ -24,8 +24,7 @@ #include <memory> #include <vector> -template <class T> -class IntegratorMCMiser; +template <class T> class IntegratorMCMiser; class CoheringSubparticles; class DiffuseElement; diff --git a/Sample/ComponentBuilder/IRegistry.h b/Sample/ComponentBuilder/IRegistry.h index e9aeae684d64700a37dfc42e952390660a11e859..4e0b40a46c1d27394216a710b5aafb92f1f51464 100644 --- a/Sample/ComponentBuilder/IRegistry.h +++ b/Sample/ComponentBuilder/IRegistry.h @@ -26,8 +26,7 @@ //! Templated object registry. -template <class T> -class IRegistry { +template <class T> class IRegistry { public: const T* getItem(const std::string& key) const { diff --git a/Sample/Material/MaterialUtil.cpp b/Sample/Material/MaterialUtil.cpp index 85ca3dbbf34d27f55ab9f6fe878e8a7af7d64f35..71ce5592bd9c2807f111fafdde96b733c391b7c4 100644 --- a/Sample/Material/MaterialUtil.cpp +++ b/Sample/Material/MaterialUtil.cpp @@ -36,9 +36,9 @@ const SpinMatrix Pauli_Z(1, 0, 0, -1); } // namespace -template <typename T> -SpinMatrix MaterialUtil::MagnetizationCorrection(complex_t unit_factor, double magnetic_factor, - Vec3<T> polarization) +template <typename T> SpinMatrix MaterialUtil::MagnetizationCorrection(complex_t unit_factor, + double magnetic_factor, + Vec3<T> polarization) { SpinMatrix result = unit_factor * SpinMatrix::One() + magnetic_factor diff --git a/Sample/Material/MaterialUtil.h b/Sample/Material/MaterialUtil.h index f0e7aaff4904cf17d1d64e484d9238304bedc731..297efa3913f1033407e9891bf12497d32d90d594 100644 --- a/Sample/Material/MaterialUtil.h +++ b/Sample/Material/MaterialUtil.h @@ -38,9 +38,8 @@ SpinMatrix PolarizedReducedPotential(complex_t n, R3 b_field, R3 k, double n_ref // Utility to compute magnetization correction for reduced potential and scattering length density. // Used with T = double, complex_t. -template <typename T> -SpinMatrix MagnetizationCorrection(complex_t unit_factor, double magnetic_factor, - Vec3<T> polarization); +template <typename T> SpinMatrix +MagnetizationCorrection(complex_t unit_factor, double magnetic_factor, Vec3<T> polarization); //! Checks if all non-default materials in _materials_ are of the same type and returns this type. //! If several types of materials are involved, InvalidMaterialType identifier is returned. diff --git a/Sim/Export/ComponentKeyHandler.h b/Sim/Export/ComponentKeyHandler.h index ecd45ec847a47b9272c5669fc9eec34544ecc106..77d0e4947d50db906cec825696bb15972ff416ca 100644 --- a/Sim/Export/ComponentKeyHandler.h +++ b/Sim/Export/ComponentKeyHandler.h @@ -30,16 +30,14 @@ class ComponentKeyHandler { public: void insertModel(const std::string& tag, const INode* s); - template <class T> - std::vector<const T*> objectsOfType() const; + template <class T> std::vector<const T*> objectsOfType() const; std::string obj2key(const INode* s) const; private: std::map<std::string, std::vector<const INode*>> m_objects; }; -template <class T> -std::vector<const T*> ComponentKeyHandler::objectsOfType() const +template <class T> std::vector<const T*> ComponentKeyHandler::objectsOfType() const { std::vector<const T*> result; for (const auto& it : m_objects) diff --git a/Sim/Fitting/FitObserver.h b/Sim/Fitting/FitObserver.h index 54b10fd53e8defbee69751542ac670f4a4965ca9..a2cf9b3ee1ddc4cb5e894085c918d0801f899e7c 100644 --- a/Sim/Fitting/FitObserver.h +++ b/Sim/Fitting/FitObserver.h @@ -25,8 +25,7 @@ //! Contains collection of observers and call them at specified intervals. //! Each observer will be called at first iteration and every-nth iterations. -template <class T> -class FitObserver { +template <class T> class FitObserver { public: using observer_t = std::function<void(const T&)>; FitObserver(); @@ -64,8 +63,7 @@ private: int m_notify_count; //! Total number of notify calls }; -template <class T> -FitObserver<T>::FitObserver() +template <class T> FitObserver<T>::FitObserver() : m_notify_count(0) { } @@ -76,8 +74,7 @@ void FitObserver<T>::addObserver(int every_nth, FitObserver<T>::observer_t&& obs m_observers.emplace_back(ObserverData(every_nth, observer)); } -template <class T> -void FitObserver<T>::notify(const T& data) +template <class T> void FitObserver<T>::notify(const T& data) { for (const auto& observer : m_observers) { if (need_notify(observer.m_every_nth)) @@ -87,8 +84,7 @@ void FitObserver<T>::notify(const T& data) m_notify_count++; } -template <class T> -void FitObserver<T>::notify_all(const T& data) +template <class T> void FitObserver<T>::notify_all(const T& data) { for (const auto& observer : m_observers) observer.m_observer(data); @@ -96,8 +92,7 @@ void FitObserver<T>::notify_all(const T& data) m_notify_count++; } -template <class T> -bool FitObserver<T>::need_notify(int every_nth) +template <class T> bool FitObserver<T>::need_notify(int every_nth) { return every_nth && m_notify_count % every_nth == 0; } diff --git a/Sim/Fitting/ObjectiveMetric.cpp b/Sim/Fitting/ObjectiveMetric.cpp index 48abfa40f566ac8aaba2440c0f0b3961806c35e0..8b0151c6600f087af283c88e8dd5928443786647 100644 --- a/Sim/Fitting/ObjectiveMetric.cpp +++ b/Sim/Fitting/ObjectiveMetric.cpp @@ -27,8 +27,7 @@ const double double_max = std::numeric_limits<double>::max(); const double double_min = std::numeric_limits<double>::min(); const double ln10 = std::log(10.0); -template <class T> -T* copyMetric(const T& metric) +template <class T> T* copyMetric(const T& metric) { auto* result = new T; result->setNorm(metric.norm()); diff --git a/Sim/Fitting/ObjectiveMetricUtil.cpp b/Sim/Fitting/ObjectiveMetricUtil.cpp index 433cca5ee120e556939b09c63b00d97919838b7f..1c31ddc46f79ac83ea2d78c58187d44ab39e1fc0 100644 --- a/Sim/Fitting/ObjectiveMetricUtil.cpp +++ b/Sim/Fitting/ObjectiveMetricUtil.cpp @@ -36,8 +36,7 @@ const std::map<std::string, std::function<double(double)>> norm_factory = {{"l1" {"l2", l2_norm}}; const std::string default_norm_name = "l2"; -template <class U> -std::vector<std::string> keys(const std::map<std::string, U>& map) +template <class U> std::vector<std::string> keys(const std::map<std::string, U>& map) { std::vector<std::string> result; result.reserve(map.size()); diff --git a/Tests/Unit/GUI/Utils.h b/Tests/Unit/GUI/Utils.h index ba4c3e88db43ba7c8f1648f57e00695f32d20813..73e7d6cf06f62120702f744780c5507374e22ae7 100644 --- a/Tests/Unit/GUI/Utils.h +++ b/Tests/Unit/GUI/Utils.h @@ -41,8 +41,7 @@ bool isTheSame(const Datafield& data1, const Datafield& data2); bool isTheSame(const QString& fname, const Datafield& data); //! Exports class data to project file as XML data -template <typename T> -void writeXMLFile(QString path, const T& model, QString tag) +template <typename T> void writeXMLFile(QString path, const T& model, QString tag) { // open file to write QFile file(path); @@ -58,8 +57,7 @@ void writeXMLFile(QString path, const T& model, QString tag) } //! Imports class data from XML data of project file -template <typename T> -void readXMLFile(QString path, T& model, QString tag) +template <typename T> void readXMLFile(QString path, T& model, QString tag) { // open file to read QFile file(path);