1
0
Fork 0
mirror of https://github.com/cosmo-sims/monofonIC.git synced 2024-09-19 17:03:45 +02:00

revert back to C++14 by replacing inline lambdas with template funcs

This commit is contained in:
Oliver Hahn 2019-10-24 17:12:43 +02:00
parent 07ce5fcc10
commit 4de579ca78
2 changed files with 23 additions and 6 deletions

View file

@ -84,7 +84,7 @@ file( GLOB PLUGINS
add_executable(${PRGNAME} ${SOURCES} ${PLUGINS})
target_setup_class(${PRGNAME})
set_target_properties(${PRGNAME} PROPERTIES CXX_STANDARD 17)
set_target_properties(${PRGNAME} PROPERTIES CXX_STANDARD 14)
# mpi flags
if(MPI_CXX_FOUND)

View file

@ -1,9 +1,26 @@
#pragma once
namespace op{
inline auto assign_to = [](auto &g){return [&](auto i, auto v){ g[i] = v; };};
inline auto add_to = [](auto &g){return [&](auto i, auto v){ g[i] += v; };};
inline auto add_twice_to = [](auto &g){return [&](auto i, auto v){ g[i] += 2*v; };};
inline auto subtract_from = [](auto &g){return [&](auto i, auto v){ g[i] -= v; };};
inline auto subtract_twice_from = [](auto &g){return [&](auto i, auto v){ g[i] -= 2*v; };};
template< typename grid>
inline auto assign_to( grid& g ){return [&](auto i, auto v){ g[i] = v; };}
template< typename grid>
inline auto add_to( grid& g ){return [&](auto i, auto v){ g[i] += v; };}
template< typename grid>
inline auto add_twice_to( grid& g ){return [&](auto i, auto v){ g[i] += 2*v; };}
template< typename grid>
inline auto subtract_from( grid& g ){return [&](auto i, auto v){ g[i] -= v; };}
template< typename grid>
inline auto subtract_twice_from( grid& g ){return [&](auto i, auto v){ g[i] -= 2*v; };}
// above template functions can be written as C++17 inline lambdas... but we're using C++14...
// inline auto assign_to = [](auto &g){return [&](auto i, auto v){ g[i] = v; };};
// inline auto add_to = [](auto &g){return [&](auto i, auto v){ g[i] += v; };};
// inline auto add_twice_to = [](auto &g){return [&](auto i, auto v){ g[i] += 2*v; };};
// inline auto subtract_from = [](auto &g){return [&](auto i, auto v){ g[i] -= v; };};
// inline auto subtract_twice_from = [](auto &g){return [&](auto i, auto v){ g[i] -= 2*v; };};
}