Serac  0.1
Serac is an implicit thermal strucural mechanics simulation code.
Functions
metaprogramming.hpp File Reference

Utilities for C++ metaprogramming. More...

#include <tuple>
#include <utility>
#include <type_traits>
#include "serac/infrastructure/accelerator.hpp"
Include dependency graph for metaprogramming.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<int I, int... n>
constexpr auto get (std::integer_sequence< int, n... >)
 return the Ith integer in {n...}
 
template<int... n, typename lambda >
constexpr SERAC_HOST_DEVICE void for_constexpr (lambda &&f)
 multidimensional loop tool that evaluates the lambda body inside the innermost loop. More...
 

Detailed Description

Utilities for C++ metaprogramming.

Definition in file metaprogramming.hpp.

Function Documentation

◆ for_constexpr()

template<int... n, typename lambda >
constexpr SERAC_HOST_DEVICE void for_constexpr ( lambda &&  f)
constexpr

multidimensional loop tool that evaluates the lambda body inside the innermost loop.

Template Parameters
ninteger template arguments describing the shape of the iteration space
lambdathe type of the functor object to be executed in the loop
Note
for_constexpr< 2, 3 >([](auto i, auto j) { std::cout << i << " " << j << std::endl; }
will print:
0 0
0 1
0 2
1 0
1 1
1 2
latter integer template parameters correspond to more nested loops
The lambda function should be a callable object taking sizeof ... (n) arguments. Anything returned from f() will be discarded note: this forces multidimensional loop unrolling, which can be beneficial for runtime performance, but can hurt compile time and executable size as the loop dimensions become larger.

Definition at line 97 of file metaprogramming.hpp.