From 30a457d96b156fa1c7e05b86e5df0d874787c427 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Mon, 6 May 2019 11:10:55 +0200 Subject: [PATCH] Add explicit return type for lambdas --- src/amdis/BoundaryManager.hpp | 2 +- src/amdis/ProblemStat.inc.hpp | 18 +++++++++--------- .../ConvectionDiffusionOperator.hpp | 4 ++-- src/amdis/typetree/Traversal.hpp | 2 +- src/amdis/typetree/TreeData.hpp | 16 ++++++++++------ src/amdis/utility/QuadratureFactory.hpp | 4 ++-- 6 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/amdis/BoundaryManager.hpp b/src/amdis/BoundaryManager.hpp index c1f17acb..9e9191eb 100644 --- a/src/amdis/BoundaryManager.hpp +++ b/src/amdis/BoundaryManager.hpp @@ -146,7 +146,7 @@ namespace AMDiS if (!segment.boundary()) continue; - Dune::Hybrid::ifElse(Dune::Std::is_detected{}, [&](auto id) { + Dune::Hybrid::ifElse(Dune::Std::is_detected{}, [&](auto id) -> void { auto index = segment.boundarySegmentIndex(); boundaryIds_[index] = id(segment).boundaryId(); }); diff --git a/src/amdis/ProblemStat.inc.hpp b/src/amdis/ProblemStat.inc.hpp index eab90170..48686e05 100644 --- a/src/amdis/ProblemStat.inc.hpp +++ b/src/amdis/ProblemStat.inc.hpp @@ -179,7 +179,7 @@ void ProblemStat::createMatricesAndVectors() rhs_ = std::make_shared(globalBasis_, DataTransferOperation::NO_OPERATION); auto localView = globalBasis_->localView(); - for_each_node(localView.tree(), [&,this](auto const& node, auto treePath) + for_each_node(localView.tree(), [&,this](auto const& node, auto treePath) -> void { std::string i = to_string(treePath); estimates_[i].resize(globalBasis_->gridView().indexSet().size(0)); @@ -207,7 +207,7 @@ void ProblemStat::createMarker() { marker_.clear(); auto localView = globalBasis_->localView(); - for_each_node(localView.tree(), [&,this](auto const& node, auto treePath) + for_each_node(localView.tree(), [&,this](auto const& node, auto treePath) -> void { std::string componentName = name_ + "->marker[" + to_string(treePath) + "]"; @@ -228,7 +228,7 @@ void ProblemStat::createFileWriter() { filewriter_.clear(); auto localView = globalBasis_->localView(); - for_each_node(localView.tree(), [&,this](auto const& node, auto treePath) + for_each_node(localView.tree(), [&,this](auto const& node, auto treePath) -> void { std::string componentName = name_ + "->output[" + to_string(treePath) + "]"; @@ -380,11 +380,11 @@ globalRefine(int refCount) Dune::Timer t; bool adapted = false; Dune::Hybrid::ifElse(Dune::Std::is_detected{}, - /*then*/ [&](auto id) { + /*then*/ [&](auto id) -> void { // TODO(FM): Add a way to pass a GridTransfer as ADH with *globalBasis_ argument id(grid_)->globalRefine(refCount, GridTransferManager::gridTransfer(*grid_)); }, - /*else*/ [&](auto id) { + /*else*/ [&](auto id) -> void { for (int i = 0; i < refCount; ++i) { // mark all entities for grid refinement for (const auto& element : elements(grid_->leafGridView())) @@ -423,9 +423,9 @@ buildAfterAdapt(AdaptInfo& /*adaptInfo*/, Flag /*flag*/, bool asmMatrix, bool as rhs_->init(asmVector); auto localView = globalBasis_->localView(); - for_each_node(localView.tree(), [&,this](auto const& rowNode, auto rowTp) { + for_each_node(localView.tree(), [&,this](auto const& rowNode, auto rowTp) -> void { auto rowBasis = Dune::Functions::subspaceBasis(*globalBasis_, rowTp); - for_each_node(localView.tree(), [&,this](auto const& colNode, auto colTp) { + for_each_node(localView.tree(), [&,this](auto const& colNode, auto colTp) -> void { auto colBasis = Dune::Functions::subspaceBasis(*globalBasis_, colTp); for (auto bc : dirichletBCs_[rowNode][colNode]) bc->init(rowBasis, colBasis); @@ -451,8 +451,8 @@ buildAfterAdapt(AdaptInfo& /*adaptInfo*/, Flag /*flag*/, bool asmMatrix, bool as systemMatrix_->finish(asmMatrix); rhs_->finish(asmVector); - for_each_node(localView.tree(), [&,this](auto const& rowNode, auto row_tp) { - for_each_node(localView.tree(), [&,this](auto const& colNode, auto col_tp) { + for_each_node(localView.tree(), [&,this](auto const& rowNode, auto row_tp) -> void { + for_each_node(localView.tree(), [&,this](auto const& colNode, auto col_tp) -> void { // finish boundary condition for (auto bc : dirichletBCs_[rowNode][colNode]) bc->fillBoundaryCondition(*systemMatrix_, *solution_, *rhs_, rowNode, row_tp, colNode, col_tp); diff --git a/src/amdis/localoperators/ConvectionDiffusionOperator.hpp b/src/amdis/localoperators/ConvectionDiffusionOperator.hpp index a03c70a3..0728f497 100644 --- a/src/amdis/localoperators/ConvectionDiffusionOperator.hpp +++ b/src/amdis/localoperators/ConvectionDiffusionOperator.hpp @@ -184,8 +184,8 @@ namespace AMDiS { using Concept = Dune::Std::is_detected; return Dune::Hybrid::ifElse(Concept{}, - [&](auto id) { return order(id(localFct)); }, - [] (auto) { return 0; }); + [&](auto id) -> int { return order(id(localFct)); }, + [] (auto) -> int { return 0; }); } template diff --git a/src/amdis/typetree/Traversal.hpp b/src/amdis/typetree/Traversal.hpp index 8dfd9cdf..396822c5 100644 --- a/src/amdis/typetree/Traversal.hpp +++ b/src/amdis/typetree/Traversal.hpp @@ -96,7 +96,7 @@ namespace AMDiS { if constexpr(visitChild) applyToTree(child, childTP, visitor); #else // AMDIS_HAS_CXX_CONSTEXPR_IF - Dune::Hybrid::ifElse(bool_t{}, [&] (auto /*id*/) { + Dune::Hybrid::ifElse(bool_t{}, [&] (auto /*id*/) -> void { applyToTree(child, childTP, visitor); }); #endif // AMDIS_HAS_CXX_CONSTEXPR_IF diff --git a/src/amdis/typetree/TreeData.hpp b/src/amdis/typetree/TreeData.hpp index d6ecfe62..c297dd4f 100644 --- a/src/amdis/typetree/TreeData.hpp +++ b/src/amdis/typetree/TreeData.hpp @@ -120,7 +120,9 @@ namespace AMDiS assert(initialized_); assert(data_.size() > node.treeIndex()); using NodePtr = NodeData*; - return *NodePtr(data_[node.treeIndex()]); + auto* nodePtr = NodePtr(data_[node.treeIndex()]); + assert(nodePtr); + return *nodePtr; } //! Get reference to data associated to given node @@ -130,7 +132,9 @@ namespace AMDiS assert(initialized_); assert(data_.size() > node.treeIndex()); using NodePtr = NodeData*; - return *NodePtr(data_[node.treeIndex()]); + auto* nodePtr = NodePtr(data_[node.treeIndex()]); + assert(nodePtr); + return *nodePtr; } //! Swap tree and data container with `other` @@ -152,12 +156,12 @@ namespace AMDiS void initData() { std::size_t s = 0; - apply([&s](const auto& node, auto) { + apply([&s](const auto& node, auto) -> void { s = std::max(s, node.treeIndex()+1); }); data_.resize(s, nullptr); - apply([this](const auto& node, auto) { + apply([this](const auto& node, auto) -> void { using Node = std::remove_reference_t; data_[node.treeIndex()] = new NodeData; }); @@ -167,7 +171,7 @@ namespace AMDiS // Deep copy of node data void copyData(const TreeData& other) { - apply([&other,this](const auto& node, auto) { + apply([&other,this](const auto& node, auto) -> void { (*this)[node] = other[node]; }); } @@ -175,7 +179,7 @@ namespace AMDiS // For each node, delete the allocated node data void destroyData() { - apply([this](const auto& node, auto) { + apply([this](const auto& node, auto) -> void { using Node = std::remove_reference_t; using NodePtr = NodeData*; auto* p = NodePtr(data_[node.treeIndex()]); diff --git a/src/amdis/utility/QuadratureFactory.hpp b/src/amdis/utility/QuadratureFactory.hpp index a4a20524..865c6cd8 100644 --- a/src/amdis/utility/QuadratureFactory.hpp +++ b/src/amdis/utility/QuadratureFactory.hpp @@ -57,8 +57,8 @@ namespace AMDiS void bind(LocalFunction const& localFct) final { order_ = Dune::Hybrid::ifElse(Concept{}, - [&](auto id) { return AMDiS::order(id(localFct)); }, - [] (auto) { return -1; }); + [&](auto id) -> int { return AMDiS::order(id(localFct)); }, + [] (auto) -> int { return -1; }); } int order() const final { return order_; } -- GitLab