0

I can use any version of C++ (up to 20).

Having a function implemented in assembly language as GCC's extended asm

static inline void foo(){
    __asm__ __volatile__("Some asm code" ::: "some clobbers");
}

how to write a template which would generate a code repeating the foo's n times?

Something like this:

template<int n>
static void bar(){
   //repeat inlined foo's code n times
}
Some Name
  • 8,555
  • 5
  • 27
  • 77
  • Does the code really need to be repeated verbatim? Or do you need one piece of code repeated multiple times (like a loop calling a function)? What is the actual problem you need to solve? Why do you think this solution to your unknown problem is the only viable solution? What else have you tried? Please refresh about [the XY problem](http://xyproblem.info/) as I think this is a grand example of it. – Some programmer dude May 12 '20 at 05:10
  • 1
    @Someprogrammerdude Yes, exatcly verbatim. The actual problem is to profile a particular assembly code. I need such template because it became too verbose to implement in by hand in assembly language (which is currently implemented with macro) so I'm considering switching to C++ templates to generate the number of repeats as specified in the template parameters. – Some Name May 12 '20 at 05:12

0 Answers0