c++ - Can a function return the same value inside a loop, and return different values outside of loops? -


it acts this.

fun();//return 1; (int i=0;i++;i<100)     fun();//return 2; fun();//return 3; 

i don't want manually, like:

static int i=0; fun(){return i}; main() {     i++;     fun();//return 1;     i++;     (int i=0;i++;i<100)         fun();//return 2;     i++;     fun();//return 3; } 

new classes , static variables allowed.

i trying design cache replacement algorithm. of time use lru algorithm, but, if use lru algorithm inside loop cache thrashing.

https://en.wikipedia.org/wiki/thrashing_(computer_science)

i need know if inside loop. can use lfu algorithm avoid thrashing.

an obvious way of doing using __line__ macro. return source code line number, different throughout function.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -