This appears to be legal
template<const int& x, int y>void fn() {}
However how do I call it? If it is the y type only fn<1>() seems to work (but not fn<intvar>()). The const& is confusing me especially when intvar doesn't seem to work with int y. Is this completely wrong/illegal? I'm using clang 3.2
External linkage is required for references & pointers for template parameters (for C++11, internal linkage, but static storage duration is required)
So if you have to use const int & as a template argument, you need to have it as extern in global scope.
extern const int a = 2;
fn<a,1>();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With