mardi 16 octobre 2018

Is that possible to have a for loop in compile time with runtime or even compile time limit condition in c++11?

I would like to know if it is possible to have a for loop in compile time with runtime or even compile time limit condition in c++11? I start with a silly try to find out what I need.

for (uint32_t i = 0; i < n; ++i)
  {
    templated_func<i>();
  }

consider I have a class with a private member variable n, and I want to call a template function with a different number that iterates from 0 to n (for the case of runtime limit condition) I've had studies on the "Template Metaprogramming" and "Constexpr If" (c++17) but I have not gotten any results, can anyone help me?

Aucun commentaire:

Enregistrer un commentaire