Lets have following code in C++14:
using namespace std;
void foo(int a)
{
cout << a;
}
int main()
{
//version1
foo(13);
//version2
static constexpr int tmp = 13;
foo(tmp);
return 0;
}
Will the compiler automatically optimize version2 to version1 so that static constexpr
variable will be inlined (something like defines are handled during processor in C)? If so, what are the rules for this? Will it be still inlined if it would be only constexpr
or static const
?