Loading TemplateTest/main.cpp +30 −10 Original line number Diff line number Diff line Loading @@ -516,23 +516,43 @@ void testOperator() { } int main() { /*Base b1(0.0); void applyFunc(function_ptr<int, int>::type f, int arg) { DBGVAR(f(arg)); } void applyFunc(std::function<int(int)>&f, int arg) { DBGVAR(f(arg)); } template <typename Functor> void applyFunc1(const Functor&f, int arg) { static_assert (std::is_assignable<std::function<void(int)>,Functor>::value, "The Functor must be a function with one argument int and return type int"); DBGVAR(f(arg)); } void testFunction() { Base b1(0.0); Base b2(std::pair<char,int>{'1',3}); DBGVAR(b2.first,b2.second); */ testOperator(); std::function<int(int)> fce ( [&b1](int i)->int{return b1.data + 42 + i;}); applyFunc(fce, 2); applyFunc([](int i){return 42 + i;},2); applyFunc1([&b1](int i)->double{return b1.data + 42.15 + i;}, 2); } int main() { //testOperator(); //testMemberRef(); //testConstrucorOrder(); /* std::function<int(int)> fce = [&b1](int i){return b1.data + 42 + i;}; std::cout << fce(2); */ testFunction(); return 0; } Loading Unstructured_mesh/UnstructuredMesh/MeshFunctions/MeshFunctions.h +6 −3 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ #include "../MeshDataContainer/MeshDataContainer.h" #include "../../Vector.h" #include <valarray> #include <functional> #include <set> #include <map> Loading Loading @@ -531,11 +532,13 @@ struct MeshRun<1, StartDimension, TargetDimension, MeshDimension, false, Descend template <unsigned int CurrentDimension,unsigned int StartDimension, unsigned int TargetDimension, unsigned int MeshDimension, bool Descend> struct MeshRun<CurrentDimension, StartDimension, TargetDimension, MeshDimension, true, Descend> { template<typename Func, typename IndexType, typename Real, unsigned int ...Reserve> template<typename Functor, typename IndexType, typename Real, unsigned int ...Reserve> static void run(MeshElements<MeshDimension, IndexType, Real, Reserve...>& , IndexType origElementIndex, IndexType index, Func fun){ Functor fun){ static_assert (std::is_assignable<std::function<void(IndexType, IndexType)>,Functor>::value, "The Functor fun must be a function with void return type and two arguments of IndexType, the first is index of StartDimension element and the second is the index of the TargetDimension element"); if(Descend){ fun(origElementIndex, index); }else{ Loading @@ -559,7 +562,7 @@ struct MeshApply { (StartDimension > TargetDimension) ? StartDimension : TargetDimension, (StartDimension > TargetDimension) ? TargetDimension : StartDimension, MeshDimension, false, StartDimension == TargetDimension, (StartDimension > TargetDimension)>::run(mesh, startElement.getIndex(), startElement.getIndex(), f); } } Loading Unstructured_mesh/Unstructured_mesh.pro.user +1 −1 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE QtCreatorProject> <!-- Written by QtCreator 4.10.0, 2019-11-10T13:53:17. --> <!-- Written by QtCreator 4.10.0, 2019-11-17T15:57:17. --> <qtcreator> <data> <variable>EnvironmentId</variable> Loading Loading
TemplateTest/main.cpp +30 −10 Original line number Diff line number Diff line Loading @@ -516,23 +516,43 @@ void testOperator() { } int main() { /*Base b1(0.0); void applyFunc(function_ptr<int, int>::type f, int arg) { DBGVAR(f(arg)); } void applyFunc(std::function<int(int)>&f, int arg) { DBGVAR(f(arg)); } template <typename Functor> void applyFunc1(const Functor&f, int arg) { static_assert (std::is_assignable<std::function<void(int)>,Functor>::value, "The Functor must be a function with one argument int and return type int"); DBGVAR(f(arg)); } void testFunction() { Base b1(0.0); Base b2(std::pair<char,int>{'1',3}); DBGVAR(b2.first,b2.second); */ testOperator(); std::function<int(int)> fce ( [&b1](int i)->int{return b1.data + 42 + i;}); applyFunc(fce, 2); applyFunc([](int i){return 42 + i;},2); applyFunc1([&b1](int i)->double{return b1.data + 42.15 + i;}, 2); } int main() { //testOperator(); //testMemberRef(); //testConstrucorOrder(); /* std::function<int(int)> fce = [&b1](int i){return b1.data + 42 + i;}; std::cout << fce(2); */ testFunction(); return 0; } Loading
Unstructured_mesh/UnstructuredMesh/MeshFunctions/MeshFunctions.h +6 −3 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ #include "../MeshDataContainer/MeshDataContainer.h" #include "../../Vector.h" #include <valarray> #include <functional> #include <set> #include <map> Loading Loading @@ -531,11 +532,13 @@ struct MeshRun<1, StartDimension, TargetDimension, MeshDimension, false, Descend template <unsigned int CurrentDimension,unsigned int StartDimension, unsigned int TargetDimension, unsigned int MeshDimension, bool Descend> struct MeshRun<CurrentDimension, StartDimension, TargetDimension, MeshDimension, true, Descend> { template<typename Func, typename IndexType, typename Real, unsigned int ...Reserve> template<typename Functor, typename IndexType, typename Real, unsigned int ...Reserve> static void run(MeshElements<MeshDimension, IndexType, Real, Reserve...>& , IndexType origElementIndex, IndexType index, Func fun){ Functor fun){ static_assert (std::is_assignable<std::function<void(IndexType, IndexType)>,Functor>::value, "The Functor fun must be a function with void return type and two arguments of IndexType, the first is index of StartDimension element and the second is the index of the TargetDimension element"); if(Descend){ fun(origElementIndex, index); }else{ Loading @@ -559,7 +562,7 @@ struct MeshApply { (StartDimension > TargetDimension) ? StartDimension : TargetDimension, (StartDimension > TargetDimension) ? TargetDimension : StartDimension, MeshDimension, false, StartDimension == TargetDimension, (StartDimension > TargetDimension)>::run(mesh, startElement.getIndex(), startElement.getIndex(), f); } } Loading
Unstructured_mesh/Unstructured_mesh.pro.user +1 −1 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE QtCreatorProject> <!-- Written by QtCreator 4.10.0, 2019-11-10T13:53:17. --> <!-- Written by QtCreator 4.10.0, 2019-11-17T15:57:17. --> <qtcreator> <data> <variable>EnvironmentId</variable> Loading