Pure functions in C++
https://medium.com/software-design/pure-functions-in-c-fc102fd9c5e0
C++ is not a functional programming language. Functions causing side-effects is the norm. If a compiler does not see the body of a function, it assumes that the function causes side effects. This can result in missed optimization opportunities.
Consider the following code. Here the main function for (some reason) computes the square of the total number of arguments twice and returns the sum of the squares.
Pure functions in C++
Dec 19, 2018, 4:46am UTC
https://medium.com/software-design/pure-functions-in-c-fc102fd9c5e0
>C++ is not a functional programming language. Functions causing side-effects is the norm. If a compiler does not see the body of a function, it assumes that the function causes side effects. This can result in missed optimization opportunities.
>Consider the following code. Here the main function for (some reason) computes the square of the total number of arguments twice and returns the sum of the squares.